codice:
public String AddNewExp() throws Exception {
DataSource dataSource = Singleton.getInstance().getDataSource();
Connection conn = dataSource.getConnection();
if (conn != null) {
AuthenticationBean bean2 = (AuthenticationBean) ViewUtils
.eval("#{authenticationBean}");
PreparedStatement pst2 = null;
pst2 = conn .prepareStatement("INSERT INTO
esperimento(username,nometeam,piattaforma,links_url,tipoesperimento,control_liqualita,brevedescrizione,numeroibridazioni,autore,laboratorio,contatti,pr_otocolloscansione,softwareanalisi,tiponormalizzazione,scalalogaritmica,test_,parametri,fattoredicorrezione,fattore1,fattore2,fattore3,fattore4)
VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
Statement.RETURN_GENERATED_KEYS);
pst2.setString(1, bean2.getLoginName());
pst2.setString(2, bean2.getTeamName());
pst2.setString(3, platformName);
pst2.setString(4, links);
pst2.setString(5, toe);
pst2.setString(6, qcst);
pst2.setString(7, description);
pst2.setInt(8, hybridationNumbers);
pst2.setString(9, author);
pst2.setString(10, laboratory);
pst2.setString(11, contact);
pst2.setString(12, scanning);
pst2.setString(13, software);
pst2.setString(14, normalization);
pst2.setString(15, logarithmic);
pst2.setString(16, test);
pst2.setString(17, parameter);
pst2.setString(18, correction);
pst2.setString(19, factor1);
pst2.setString(20, factor2);
pst2.setString(21, factor3);
pst2.setString(22, factor4);
ResultSet rs=null;
pst2.executeUpdate();
u=2;
int autoIncKeyFromFunc = -1;
u=3;
rs = pst2.executeQuery("SELECT LAST_INSERT_ID()");
u=4;
if (rs.next()) {
u=5;
autoIncKeyFromFunc = rs.getInt(1);
u=6;
} else {u=7;
// throw an exception from here
}
rs.close();
pst2.close();
}
conn.close();
return "go";
}