Allego un esempio di insert into
codice:
try {
Connection conn = DriverManager.getConnection(URL);
// Parte per gli acquisti
String sql = "INSERT INTO acquisto VALUES(?,?,?)";
for (int i=0;i<data.getRowCount();i++){
PreparedStatement stm = conn.prepareStatement(sql);
stm.setString(1,data.getValueAt(i, 0).toString());
stm.setString(2,cod);
stm.setDouble(3, Double.parseDouble(data.getValueAt(i, 2).toString()));
stm.executeUpdate();
}
//Parte per le bolle
sql = "INSERT INTO bolla VALUES(?,?,?,?,?)";
PreparedStatement stm = conn.prepareStatement(sql);
stm.setString(1, cod);
stm.setString(2, forn);
stm.setDate(3, new java.sql.Date(y,m,g));
stm.setString(4, can);
stm.setString(5, fir);
stm.executeUpdate();
conn.close();
JOptionPane.showMessageDialog(rootPane, "Bolla inserita con successo nel cantiere " + can);
} catch (SQLException ex) {
Logger.getLogger(ins_bolle.class.getName()).log(Level.SEVERE, null, ex);
}