protected long test(DataSource ds, int n) throws Exception { long start; long end; start = System.currentTimeMillis(); for (int i = 0; i < n; ++i) { Connection con = null; try { con = ds.getConnection(); } finally { ConnectionUtils.attemptClose( con ); } //System.err.print(i + "\t"); } end = System.currentTimeMillis(); return end - start; } }
private void doStatementList(List stmtList, Connection con) throws SQLException { if (stmtList != null) { Statement stmt = null; try { stmt = con.createStatement(); for (Iterator ii = stmtList.iterator(); ii.hasNext();) stmt.executeUpdate((String) ii.next()); con.commit(); } catch (SQLException e) { ConnectionUtils.attemptRollback(con); e.fillInStackTrace(); throw e; } finally {StatementUtils.attemptClose(stmt);} } }
protected long test(DataSource ds, int n) throws Exception { long start; long end; start = System.currentTimeMillis(); for (int i = 0; i < n; ++i) { Connection con = null; try { con = ds.getConnection(); } finally { ConnectionUtils.attemptClose( con ); } //System.err.print(i + "\t"); } end = System.currentTimeMillis(); return end - start; } }
protected long test(DataSource ds, int n) throws SQLException { Connection con = null; try { con = ds.getConnection(); return test( con , n ); } finally { ConnectionUtils.attemptClose( con ); } //{} }
protected long test(DataSource ds, int n) throws SQLException { Connection con = null; try { con = ds.getConnection(); return test( con , n ); } finally { ConnectionUtils.attemptClose( con ); } //{} }
static void drop(DataSource ds) throws SQLException { Connection con = null; Statement stmt = null; try { con = ds.getConnection(); stmt = con.createStatement(); stmt.executeUpdate("DROP TABLE TRSS_TABLE"); } finally { StatementUtils.attemptClose( stmt ); ConnectionUtils.attemptClose( con ); } }
static void drop(DataSource ds) throws SQLException { Connection con = null; PreparedStatement ps1 = null; try { con = ds.getConnection(); ps1 = con.prepareStatement(EMPTY_TABLE_DROP); ps1.executeUpdate(); } finally { StatementUtils.attemptClose( ps1 ); ConnectionUtils.attemptClose( con ); } System.err.println("Test schema dropped."); } }
static void create(DataSource ds) throws SQLException { Connection con = null; Statement stmt = null; try { con = ds.getConnection(); stmt = con.createStatement(); stmt.executeUpdate("CREATE TABLE TRSS_TABLE ( a_col VARCHAR(16) )"); } finally { StatementUtils.attemptClose( stmt ); ConnectionUtils.attemptClose( con ); } }
static void create(DataSource ds) throws SQLException { Connection con = null; Statement stmt = null; try { con = ds.getConnection(); stmt = con.createStatement(); stmt.executeUpdate("CREATE TABLE TRSS_TABLE ( a_col VARCHAR(16) )"); } finally { StatementUtils.attemptClose( stmt ); ConnectionUtils.attemptClose( con ); } }
static void create(DataSource ds) throws SQLException { System.err.println("Creating test schema."); Connection con = null; PreparedStatement ps1 = null; try { con = ds.getConnection(); ps1 = con.prepareStatement(EMPTY_TABLE_CREATE); ps1.executeUpdate(); System.err.println("Test schema created."); } finally { StatementUtils.attemptClose( ps1 ); ConnectionUtils.attemptClose( con ); } }
static void drop(DataSource ds) throws SQLException { Connection con = null; Statement stmt = null; try { con = ds.getConnection(); stmt = con.createStatement(); stmt.executeUpdate("DROP TABLE TRSS_TABLE"); } finally { StatementUtils.attemptClose( stmt ); ConnectionUtils.attemptClose( con ); } }
static void create(DataSource ds) throws SQLException { System.err.println("Creating test schema."); Connection con = null; PreparedStatement ps1 = null; try { con = ds.getConnection(); ps1 = con.prepareStatement(EMPTY_TABLE_CREATE); ps1.executeUpdate(); System.err.println("Test schema created."); } finally { StatementUtils.attemptClose( ps1 ); ConnectionUtils.attemptClose( con ); } }
static void doSomething(DataSource ds) throws SQLException { Connection con = null; Statement stmt = null; try { con = ds.getConnection(); stmt = con.createStatement(); int i = stmt.executeUpdate("INSERT INTO TRSS_TABLE VALUES ('" + System.currentTimeMillis() + "')"); if (i != 1) throw new SQLException("Insert failed somehow strange!"); } finally { StatementUtils.attemptClose( stmt ); ConnectionUtils.attemptClose( con ); } }
static void create(DataSource ds) throws SQLException { System.err.println("Creating test schema."); Connection con = null; PreparedStatement ps1 = null; try { con = ds.getConnection(); ps1 = con.prepareStatement(EMPTY_TABLE_CREATE); ps1.executeUpdate(); System.err.println("Test schema created."); } finally { StatementUtils.attemptClose( ps1 ); ConnectionUtils.attemptClose( con ); } }
static void drop(DataSource ds) throws SQLException { Connection con = null; PreparedStatement ps1 = null; try { con = ds.getConnection(); ps1 = con.prepareStatement(EMPTY_TABLE_DROP); ps1.executeUpdate(); } finally { StatementUtils.attemptClose( ps1 ); ConnectionUtils.attemptClose( con ); } System.err.println("Test schema dropped."); } }
static void doSomething(DataSource ds) throws SQLException { Connection con = null; Statement stmt = null; try { con = ds.getConnection(); stmt = con.createStatement(); int i = stmt.executeUpdate("INSERT INTO TRSS_TABLE VALUES ('" + System.currentTimeMillis() + "')"); if (i != 1) throw new SQLException("Insert failed somehow strange!"); } finally { StatementUtils.attemptClose( stmt ); ConnectionUtils.attemptClose( con ); } }
static void drop(DataSource ds) throws SQLException { Connection con = null; PreparedStatement ps1 = null; try { con = ds.getConnection(); ps1 = con.prepareStatement(EMPTY_TABLE_DROP); ps1.executeUpdate(); } finally { StatementUtils.attemptClose( ps1 ); ConnectionUtils.attemptClose( con ); } System.err.println("Test schema dropped."); } }
static void create(DataSource ds) throws SQLException { System.err.println("Creating test schema."); Connection con = null; PreparedStatement ps1 = null; try { con = ds.getConnection(); ps1 = con.prepareStatement(EMPTY_TABLE_CREATE); ps1.executeUpdate(); System.err.println("Test schema created."); } finally { StatementUtils.attemptClose( ps1 ); ConnectionUtils.attemptClose( con ); } }
static void drop(DataSource ds) throws SQLException { Connection con = null; PreparedStatement ps1 = null; try { con = ds.getConnection(); ps1 = con.prepareStatement(EMPTY_TABLE_DROP); ps1.executeUpdate(); } finally { StatementUtils.attemptClose( ps1 ); ConnectionUtils.attemptClose( con ); } System.err.println("Test schema dropped."); } }
private static void perform( DataSource ds, String name ) throws SQLException { Connection c = null; PreparedStatement ps = null; try { c = ds.getConnection(); long start = System.currentTimeMillis(); for (int i = 0; i < NUM_ITERATIONS; ++i) { PreparedStatement test = c.prepareStatement( EMPTY_TABLE_CONDITIONAL_SELECT ); test.close(); } long end = System.currentTimeMillis(); System.err.println(name + " --> " + (end - start) / (float) NUM_ITERATIONS + " [" + NUM_ITERATIONS + " iterations]"); } finally { StatementUtils.attemptClose( ps ); ConnectionUtils.attemptClose( c ); } }