List of usage examples for java.sql Statement close
void close() throws SQLException;
Statement
object's database and JDBC resources immediately instead of waiting for this to happen when it is automatically closed. From source file:edu.jhu.pha.vospace.DbPoolServlet.java
public static void close(Statement s) { if (s != null) { try {/*w w w.ja v a 2s .c om*/ s.close(); } catch (Exception ignored) { } } }
From source file:jeeves.utils.IO.java
public static void closeQuietly(Statement stmt) { if (stmt != null) { try {//w w w . j a v a2s .c om stmt.close(); } catch (Throwable t) { // ignore } } }
From source file:com.invariantproperties.udt.AbstractDatabaseTest.java
/** * Unload jar file containing our user-defined types. * //from w ww. j a v a 2 s. c o m * @throws SQLException */ @AfterClass public static void unloadJarFile() throws SQLException { Connection conn = ds.getConnection(); Statement stmt = conn.createStatement(); stmt.execute("select sqlj.remove_jar('ip_udt', true)"); stmt.execute("drop schema invariantproperties"); stmt.close(); conn.close(); }
From source file:jdbc.JdbcUtils.java
/** * Close the given JDBC Statement and ignore any thrown exception. This is * useful for typical finally blocks in manual JDBC code. * //from www . j a v a 2 s . c o m * @param stmt * the JDBC Statement to close (may be <code>null</code>) */ public static void closeStatement(Statement stmt) { if (stmt != null) { try { stmt.close(); stmt = null; } catch (SQLException ex) { logger.warn("Could not close JDBC Statement", ex); } catch (Throwable ex) { // We don't trust the JDBC driver: It might throw // RuntimeException or Error. logger.error("Unexpected exception on closing JDBC Statement", ex); } } }
From source file:com.espertech.esperio.db.SupportDatabaseService.java
public static void truncateTable(String tableName) throws SQLException { Connection connection = getConnection(PARTURL, DBUSER, DBPWD); connection.setAutoCommit(true);//from w ww. j ava 2 s .com Statement stmt = connection.createStatement(); String sql = "delete from " + tableName; log.info("Executing sql : " + sql); stmt.executeUpdate(sql); stmt.close(); connection.close(); }
From source file:at.molindo.dbcopy.util.Utils.java
public static <T> T execute(Connection c, String query, ResultSetHandler<T> handler) throws SQLException { Statement stmt = c.createStatement(); try {// w w w . j a v a2s . c o m ResultSet rs = stmt.executeQuery(query); return handle(rs, handler); } finally { stmt.close(); } }
From source file:com.test.db.MySqlConnection.java
/** * Closes active MySQL connection/*from www .j a va 2 s . c o m*/ * * @param statement the active connection */ public static void close(Statement statement) { if (statement == null) return; try { if (statement.isClosed()) return; statement.close(); } catch (SQLException e) { LOGGER.error(e.getMessage(), e); } }
From source file:gridool.mapred.db.DBReduceJob.java
public static void createView(final String dstDbUrl, final String createTables, final String createView, final DBMapReduceJobConf jobConf) throws SQLException { final Connection conn; try {/* w ww. j a v a 2 s . c o m*/ conn = jobConf.getConnection(dstDbUrl, true); } catch (ClassNotFoundException e) { throw new SQLException(e); } try { Statement st = conn.createStatement(); st.executeUpdate(createTables); st.executeUpdate(createView); st.close(); conn.commit(); if (LOG.isInfoEnabled()) { LOG.info(createTables); LOG.info(createView); } } catch (SQLException sqle) { conn.rollback(); throw sqle; } finally { conn.close(); } }
From source file:mangotiger.sql.SQL.java
public static void close(final Statement statement) { try {/*from w w w . jav a 2 s . c o m*/ if (null != statement) statement.close(); } catch (SQLException ignore) { log().error("exception closing statement", ignore); } }
From source file:com.p6spy.engine.spy.P6TestUtil.java
public static void execute(Connection con, String sql) throws SQLException { Statement stmt = null; try {//www. j a va 2 s . co m stmt = con.createStatement(); stmt.execute(sql); } finally { if (stmt != null) try { stmt.close(); } catch (Exception e) { } } }