List of usage examples for java.sql Connection createStatement
Statement createStatement() throws SQLException;
Statement
object for sending SQL statements to the database. From source file:net.sf.jdbcwrappers.trim.TrimmingTest.java
public static void testProc(ResultSet[] resultSet) throws SQLException { Connection connection = DriverManager.getConnection("jdbc:default:connection"); resultSet[0] = connection.createStatement().executeQuery("SELECT * FROM TEST"); }
From source file:CountRows_MySQL.java
public static int countRows(Connection conn, String tableName) throws SQLException { // select the number of rows in the table Statement stmt = null;/*from w ww . j a v a2 s . c o m*/ ResultSet rs = null; int rowCount = -1; try { stmt = conn.createStatement(); rs = stmt.executeQuery("SELECT COUNT(*) FROM " + tableName); // get the number of rows from the result set rs.next(); rowCount = rs.getInt(1); } finally { rs.close(); stmt.close(); } return rowCount; }
From source file:com.p6spy.engine.spy.P6TestUtil.java
public static int executeUpdate(Connection connection, String query) throws SQLException { Statement stmt = null;/*from w w w . j a v a 2s.c o m*/ try { stmt = connection.createStatement(); return stmt.executeUpdate(query); } finally { if (stmt != null) try { stmt.close(); } catch (Exception e) { } } }
From source file:CountRows_Oracle.java
public static int countRows(Connection conn, String tableName) throws SQLException { // select the number of rows in the table Statement stmt = null;//from ww w . ja v a2 s . c om ResultSet rs = null; int rowCount = -1; try { stmt = conn.createStatement(); rs = stmt.executeQuery("SELECT COUNT(*) FROM " + tableName); // get the number of rows from the result set rs.next(); rowCount = rs.getInt(1); } finally { rs.close(); stmt.close(); } return rowCount; }