public
void cerca_U(String codicef) throws IOException{
String s = codicef;
String query;
PreparedStatement ps;
ResultSet rs =
null;
try{
String driver =
"sun.jdbc.odbc.JdbcOdbcDriver";
Class.forName(driver);
String url =
"jdbc:odbc:MY_DATA1";
Connection con = DriverManager.getConnection(url,
"username", "password");
query=
"SELECT * FROM Anagrafica WHERE codiceF=?";
ps = con.prepareStatement(query);
ps.setString(1, s);
rs = ps.executeQuery();
while(rs.next()){
//FOTO
foto_e = new File("new_" + rs.getString("nome_foto"));
OutputStream fos =
new java.io.FileOutputStream(foto_e);
InputStream fin = rs.getBinaryStream(
"FOTO");
byte[] b = newbyte[20971520];
fin.read(b);
fos.write(b);
this.foto = foto_e;
fos.flush();
fos.close();
//DOCUMENTO
documento_e = new File("new_" + rs.getString("nome_documento"));
fos =
new java.io.FileOutputStream(documento_e);
fin = rs.getBinaryStream(
"DOCUMENTO");
b =
newbyte[20971520];
fin.read(b);
fos.write(b);
this.documento = documento_e;
fos.flush();
fos.close();
}
}
catch(SQLException | ClassNotFoundException | IOException e){
e.printStackTrace();
}
}