/** static method testing jdbc framework with an update statement */ public static void testUpdate() { SQLExecutor sqlExec = new SQLExecutor(getConnectionPool()); sqlExec.setAutoCommit(true); sqlExec.addParam(new Integer(7)); sqlExec.runQueryCloseCon("UPDATE JDBC_TEST SET CODE = 'Z' WHERE TEST_ID = ?"); System.out.println(sqlExec.getNumRecordsUpdated() + " record(s) updated"); }
public static void testThis() { String sql = "UPDATE JEFF_TEST SET HEIGHT = ? WHERE EMPID < 4"; SQLExecutor sqlExec = new SQLExecutor(getConnectionPool()); sqlExec.addParam(55); sqlExec.runQueryCloseCon(sql); System.out.println(sqlExec.getNumRecordsUpdated() + " records updated"); }
/** static method testing jdbc framework with a delete and an insert statement */ public static void testDeleteAndInsert() { SQLExecutor sqlExec1 = new SQLExecutor(getConnectionPool()); sqlExec1.setAutoCommit(true); sqlExec1.addParam(new Integer(7)); sqlExec1.runQueryCloseCon("DELETE FROM JDBC_TEST WHERE TEST_ID = ?"); System.out.println(sqlExec1.getNumRecordsUpdated() + " record(s) deleted"); SQLExecutor sqlExec2 = new SQLExecutor(getConnectionPool()); sqlExec2.setAutoCommit(true); String sql = "INSERT INTO JDBC_TEST (TEST_ID, NOTES, TEST_DT, AMOUNT, CODE) " + "VALUES (7, 'seven', SYSDATE+2, 25.245, 'E')"; // "VALUES (7, 'seven', CURRENT_DATE, 25.245, 'E')"; MySQL version sqlExec2.runQueryCloseCon(sql); System.out.println(sqlExec2.getNumRecordsUpdated() + " record(s) inserted"); }