seguinte tenho o motodo que cadastra uma foto
public void inserir(Cliente cli, File file) throws FileNotFoundException, IOException {
FileInputStream fis = new FileInputStream(file);
String sql = "INSERT INTO cliente (nome_cliente, cpf_cliente, estado_cliente, data_cliente, nome_foto, foto_cliente) VALUES (?,?,?,?,?,?)";
try {
PreparedStatement stmt = getConexao().prepareStatement(sql);
stmt.setString(1, cli.getNome_Cliente());
stmt.setString(2, cli.getCpf_Cliente());
stmt.setString(3, cli.getEstado_Cliente());
stmt.setDate(4, new java.sql.Date(cli.getData_Cliente().getTime()));
stmt.setString(5, file.getName());
stmt.setBinaryStream(6, fis, (int)file.length());
stmt.executeUpdate();
stmt.close();
fis.close();
} catch (SQLException sQLException) {
System.out.println("Erro ao inserir Cliente." + sQLException.getMessage());
}
}
esta cadastrando certo porem nao consigo pegar devolta a imagem na consulta
tentei fazer o seguinte
public List<Cliente> getCliente(ResultSet rs) throws SQLException {
if(rs == null)
return null;
List<Cliente> lista = new ArrayList<Cliente>();
while(rs.next()) {
Cliente cli = new Cliente();
cli.setid_Cliente(rs.getInt("id_cliente"));
cli.setNome_Cliente(rs.getString("nome_cliente"));
cli.setEstado_Cliente(rs.getString("estado_cliente"));
cli.setfoto_cliente(rs.getBytes("foto_cliente"));
cli.setnome_foto(rs.getSring("nome_foto"));
try {
cli.setCpf_Cliente(rs.getString("cpf_cliente"));
} catch (excessao ex) {}
cli.setData_Cliente(new Date(rs.getDate("data_cliente").getTime()));
lista.add(cli);
}
return lista;
}
mas nao ta dando certo alguem teria alguma ideia ????????