private boolean insertAlignementSource(Connection conn, AlignementSource alig, int id_user) { Statement stmt; boolean status = false; try { // Get connection from pool try { stmt = conn.createStatement(); try { stmt = conn.createStatement(); String query = "Insert into alignement_source" + "(source,requete,type_rqt," + "alignement_format, id_user, description) values('" + alig.getSource() + "','" + alig.getRequete() + "','" + alig.getTypeRequete() + "','" + alig.getAlignement_format() + "','" + id_user + "','" + alig.getDescription() + "');"; stmt.execute(query); status = true; } finally { stmt.close(); } } finally { // conn.close(); } } catch (SQLException sqle) { // Log exception log.error("Error while insert new Alignement : ", sqle); } return status; }
public void update_alignementSource(HikariDataSource ds, AlignementSource alig, int id) { Statement stmt; Connection conn; try { // Get connection from pool conn = ds.getConnection(); try { stmt = conn.createStatement(); try { stmt = conn.createStatement(); String query = "update alignement_source set " + "source ='" + alig.getSource() + "', requete ='" + alig.getRequete() + "', type_rqt ='" + alig.getTypeRequete() + "', alignement_format='" + alig.getAlignement_format() + "', description ='" + alig.getDescription() + "' where id =" + id; stmt.execute(query); } finally { stmt.close(); } } finally { conn.close(); } } catch (SQLException sqle) { // Log exception log.error("Error while insert new Alignement : ", sqle); } }