List of usage examples for java.sql ResultSet close
void close() throws SQLException;
ResultSet
object's database and JDBC resources immediately instead of waiting for this to happen when it is automatically closed. From source file:com.autentia.tnt.bill.migration.support.MigratedInformationRecoverer.java
private static void liberaConexion(Connection con, PreparedStatement stmt, ResultSet rs) { if (rs != null) { try {/*from www .j av a 2 s . c o m*/ rs.close(); } catch (SQLException sqlex) { log.error("Error al liberar el ResultSet", sqlex); } } if (stmt != null) { try { stmt.close(); } catch (SQLException sqlex) { log.error("Error al liberar el Statement", sqlex); } } if (con != null) { try { con.close(); } catch (SQLException sqlex) { log.error("Error al liberar la conexin", sqlex); } } }
From source file:mangotiger.sql.SQL.java
public static void close(final ResultSet resultSet) { try {//w w w. j av a2 s . c o m if (null != resultSet) resultSet.close(); } catch (SQLException ignore) { log().error("exception closing result set", ignore); } }
From source file:de.griffel.confluence.plugins.plantuml.DatasourceHelper.java
private static List<String> getCatalogs(DatabaseMetaData dbmd) throws SQLException { final List<String> catalogNames = new LinkedList<String>(); final ResultSet rs = dbmd.getCatalogs(); while (rs.next()) { catalogNames.add(rs.getString(1)); }/*from w w w . j av a2 s.c o m*/ rs.close(); return catalogNames; }
From source file:de.griffel.confluence.plugins.plantuml.DatasourceHelper.java
public static List<String> getTableTypes(DatabaseMetaData dbmd) throws SQLException { final List<String> tableTypes = new LinkedList<String>(); final ResultSet rs = dbmd.getTableTypes(); while (rs.next()) { tableTypes.add(rs.getString(1)); }/*from w ww .j a va 2s.c o m*/ rs.close(); return tableTypes; }
From source file:desktop.olayinka.file.transfer.model.DerbyJDBCHelper.java
public static void cleanUp(Statement statement, ResultSet resultSet) { if (resultSet != null) try {/* w ww . j a va2s . c o m*/ resultSet.close(); } catch (Exception e) { e.printStackTrace(); } if (statement != null) try { statement.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:TestDebug_MySQL.java
public static int countRows(Connection conn, String tableName) throws SQLException { Statement stmt = null;//from w ww. j a v a 2 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: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 w w . j ava 2s . 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; }
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;/* w w w . j ava 2 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.freemedforms.openreact.db.DbSchema.java
/** * Determine if a patch has been applied yet. * // w w w . j a va 2 s . c o m * @param patchName * @return Success. */ public static boolean isPatchApplied(String patchName) { Connection c = Configuration.getConnection(); int found = 0; PreparedStatement cStmt = null; try { cStmt = c.prepareStatement("SELECT COUNT(*) FROM tPatch " + " WHERE patchName = ? " + ";"); cStmt.setString(1, patchName); boolean hadResults = cStmt.execute(); if (hadResults) { ResultSet rs = cStmt.getResultSet(); rs.next(); found = rs.getInt(1); rs.close(); } } catch (NullPointerException npe) { log.error("Caught NullPointerException", npe); } catch (Throwable e) { } finally { DbUtil.closeSafely(cStmt); DbUtil.closeSafely(c); } return (boolean) (found > 0); }
From source file:com.nabla.wapp.server.database.Database.java
public static Integer addRecord(final Connection conn, final String sql, final Object... parameters) throws SQLException { final PreparedStatement stmt = StatementFormat.prepare(conn, Statement.RETURN_GENERATED_KEYS, sql, parameters);/* w w w . ja va 2 s. co m*/ try { if (stmt.executeUpdate() != 1) { if (log.isErrorEnabled()) log.error("failed to add record"); return null; } final ResultSet rsKey = stmt.getGeneratedKeys(); try { rsKey.next(); return rsKey.getInt(1); } finally { rsKey.close(); } } finally { stmt.close(); } }