long test(Connection con, int n) throws SQLException { ResultSet rs = null; try { long start; long end; start = System.currentTimeMillis(); for (int i = 0; i < n; ++i) rs = con.getMetaData().getTables( null, null, "PROBABLYNOT", new String[] {"TABLE"} ); end = System.currentTimeMillis(); return end - start; } finally { ResultSetUtils.attemptClose( rs ); } } }
long test(Connection con, int n) throws SQLException { ResultSet rs = null; try { long start; long end; start = System.currentTimeMillis(); for (int i = 0; i < n; ++i) rs = con.getMetaData().getTables( null, null, "PROBABLYNOT", new String[] {"TABLE"} ); end = System.currentTimeMillis(); return end - start; } finally { ResultSetUtils.attemptClose( rs ); } } }
static void executeDelete(Connection con, Random random) throws SQLException { PreparedStatement pstmt = null; ResultSet rs = null; try { pstmt = con.prepareStatement(DELETE_STMT); int deleted = pstmt.executeUpdate(); System.out.println("DELETE [" + deleted + " rows]"); } finally { ResultSetUtils.attemptClose( rs ); StatementUtils.attemptClose( pstmt ); } }
static void executeDelete(Connection con, Random random) throws SQLException { PreparedStatement pstmt = null; ResultSet rs = null; try { pstmt = con.prepareStatement(DELETE_STMT); int deleted = pstmt.executeUpdate(); System.out.println("DELETE [" + deleted + " rows]"); } finally { ResultSetUtils.attemptClose( rs ); StatementUtils.attemptClose( pstmt ); } }
static void executeSelect(Connection con, Random random) throws SQLException { long l = System.currentTimeMillis(); PreparedStatement pstmt = null; ResultSet rs = null; try { pstmt = con.prepareStatement(SELECT_STMT); rs = pstmt.executeQuery(); rs.next(); //we assume one row, one col System.out.println("SELECT [count=" + rs.getInt(1) + ", time=" + (System.currentTimeMillis() - l) + " msecs]"); } finally { ResultSetUtils.attemptClose( rs ); StatementUtils.attemptClose( pstmt ); } }
static void executeSelect(Connection con) throws SQLException { long l = System.currentTimeMillis(); PreparedStatement pstmt = null; ResultSet rs = null; try { pstmt = con.prepareStatement(SELECT_STMT); rs = pstmt.executeQuery(); rs.next(); //we assume one row, one col System.out.println("SELECT [count=" + rs.getInt(1) + ", time=" + (System.currentTimeMillis() - l) + " msecs]"); } finally { ResultSetUtils.attemptClose( rs ); StatementUtils.attemptClose( pstmt ); } }
static void executeSelect(Connection con) throws SQLException { long l = System.currentTimeMillis(); Statement stmt = null; ResultSet rs = null; try { stmt = con.createStatement(); rs = stmt.executeQuery("SELECT count(*) FROM testpbds"); rs.next(); //we assume one row, one col System.out.println("SELECT [count=" + rs.getInt(1) + ", time=" + (System.currentTimeMillis() - l) + " msecs]"); } finally { ResultSetUtils.attemptClose( rs ); StatementUtils.attemptClose( stmt ); } }
static void executeSelect(Connection con, Random random) throws SQLException { long l = System.currentTimeMillis(); PreparedStatement pstmt = null; ResultSet rs = null; try { pstmt = con.prepareStatement(SELECT_STMT); rs = pstmt.executeQuery(); rs.next(); //we assume one row, one col System.out.println("SELECT [count=" + rs.getInt(1) + ", time=" + (System.currentTimeMillis() - l) + " msecs]"); } finally { ResultSetUtils.attemptClose( rs ); StatementUtils.attemptClose( pstmt ); } }
static void executeSelect(Connection con) throws SQLException { long l = System.currentTimeMillis(); PreparedStatement pstmt = null; ResultSet rs = null; try { pstmt = con.prepareStatement(SELECT_STMT); rs = pstmt.executeQuery(); rs.next(); //we assume one row, one col System.out.println("SELECT [count=" + rs.getInt(1) + ", time=" + (System.currentTimeMillis() - l) + " msecs]"); } finally { ResultSetUtils.attemptClose( rs ); StatementUtils.attemptClose( pstmt ); } }
static void executeSelect(Connection con) throws SQLException { long l = System.currentTimeMillis(); Statement stmt = null; ResultSet rs = null; try { stmt = con.createStatement(); rs = stmt.executeQuery("SELECT count(*) FROM testpbds"); rs.next(); //we assume one row, one col System.out.println("SELECT [count=" + rs.getInt(1) + ", time=" + (System.currentTimeMillis() - l) + " msecs]"); } finally { ResultSetUtils.attemptClose( rs ); StatementUtils.attemptClose( stmt ); } }
public static void main(String[] argv) { try { InitialContext ctx = new InitialContext(); DataSource ds = (DataSource) ctx.lookup(argv[0]); System.err.println( ds.getClass() ); Connection con = null; ResultSet rs = null; try { con = ds.getConnection(); DatabaseMetaData md = con.getMetaData(); rs = md.getTables( null, null, "%", null); while (rs.next()) System.out.println(rs.getString(3)); } finally { ResultSetUtils.attemptClose( rs ); ConnectionUtils.attemptClose( con ); } } catch (Exception e) { e.printStackTrace(); } } }
public static void main(String[] argv) { try { InitialContext ctx = new InitialContext(); DataSource ds = (DataSource) ctx.lookup(argv[0]); System.err.println( ds.getClass() ); Connection con = null; ResultSet rs = null; try { con = ds.getConnection(); DatabaseMetaData md = con.getMetaData(); rs = md.getTables( null, null, "%", null); while (rs.next()) System.out.println(rs.getString(3)); } finally { ResultSetUtils.attemptClose( rs ); ConnectionUtils.attemptClose( con ); } } catch (Exception e) { e.printStackTrace(); } } }
ResultSetUtils.attemptClose( rs ); StatementUtils.attemptClose( pstmt ); ConnectionUtils.attemptClose( con );
ResultSetUtils.attemptClose( rs ); StatementUtils.attemptClose( pstmt ); ConnectionUtils.attemptClose( con );
ResultSetUtils.attemptClose( rs );
ResultSetUtils.attemptClose( rs );
ResultSetUtils.attemptClose( rs );
ResultSetUtils.attemptClose( rs );
ResultSetUtils.attemptClose( mdrs ); ResultSetUtils.attemptClose( rs ); StatementUtils.attemptClose( testStmt ); StatementUtils.attemptClose( createStmt );
ResultSetUtils.attemptClose( mdrs ); ResultSetUtils.attemptClose( rs ); StatementUtils.attemptClose( testStmt ); StatementUtils.attemptClose( createStmt );