codice:
public void inserisci_U(){
File foto1 = this.foto;
File documento1 = this.documento;
try{
String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
Class.forName(driver);
String url = "jdbc:odbc:MY_DATA";
Connection con = DriverManager.getConnection(url, "username", "password");
String sql = new String ("INSERT INTO Anagrafica (nome,cognome,codiceF,causale,protocollo,archivio,dataNascita,data,gdf,cp,dogana,polmare,V01,V02,V04,V05,V06,V07,V08,V10,V11,V12,COLORE,DOCUMENTO,FOTO) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?");
PreparedStatement cmd = con.prepareStatement(sql);
cmd.setString(1, this.nome);
cmd.setString(2, this.cognome);
cmd.setString(3, this.codiceF);
cmd.setString(4, this.causale);
cmd.setInt(5, this.protocollo);
cmd.setString(6, this.arch);
cmd.setString(7, this.dataNascita);
cmd.setString(8, this.data);
cmd.setString(9, this.pG);
cmd.setString(10, this.pC);
cmd.setString(11, this.pD);
cmd.setString(12, this.pP);
cmd.setString(13, this.V01);
cmd.setString(14, this.V02);
cmd.setString(15, this.V04);
cmd.setString(16, this.V05);
cmd.setString(17, this.V06);
cmd.setString(18, this.V07);
cmd.setString(19, this.V08);
cmd.setString(20, this.V10);
cmd.setString(21, this.V11);
cmd.setString(22, this.V12);
cmd.setString(23, this.colore);
//Passo foto utente al database
BufferedInputStream bis=new BufferedInputStream(new FileInputStream(documento1));
int fileLength = (int)documento1.length();
cmd.setBinaryStream(24, bis, fileLength);
//Passo documento utente al database
bis=new BufferedInputStream(new FileInputStream(foto1));
fileLength = (int)foto1.length();
cmd.setBinaryStream(25, bis, fileLength);
//eseguo query
cmd.executeQuery();
}catch(SQLException | ClassNotFoundException | FileNotFoundException e){
e.printStackTrace();
}
}