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:net.duckling.falcon.api.boostrap.BootstrapDao.java
private void closeAll(Connection conn, Statement stmt, ResultSet rs) throws SQLException { if (rs != null) { rs.close(); }// w ww . j ava 2 s.co m if (stmt != null) { stmt.close(); } if (conn != null) { conn.close(); } }
From source file:com.liferay.geoipusersmap.util.LPortalConnectionPool.java
private void _cleanUp(Connection con, Statement s, ResultSet rs) { try {//from w ww . ja va 2s .com if (rs != null) { rs.close(); } } catch (SQLException sqle) { _log.error(sqle); } try { if (s != null) { s.close(); } } catch (SQLException sqle) { _log.error(sqle); } try { if (con != null) { con.close(); } } catch (SQLException sqle) { _log.error(sqle); } }
From source file:com.att.pirates.controller.GlobalDataController.java
public static List<String> GetAllPRISMIDs() { List<String> apps = new ArrayList<String>(); ResultSet rs = null; Connection conn = null;//www . jav a2s .com PreparedStatement preparedStatement = null; try { conn = DBUtility.getDBConnection(); // SQL query command String SQL = " SELECT [PRISMId] " + " FROM [Projects] "; preparedStatement = conn.prepareStatement(SQL); rs = preparedStatement.executeQuery(); while (rs.next()) { String appName = rs.getString("PRISMId"); apps.add(appName); } } catch (SQLException e) { logger.error(e.getMessage()); } catch (Exception e) { logger.error(e.getMessage()); } finally { try { if (rs != null) rs.close(); } catch (Exception e) { } ; try { if (preparedStatement != null) preparedStatement.close(); } catch (Exception e) { } ; try { if (conn != null) conn.close(); } catch (Exception e) { } ; } return apps; }
From source file:ems.util.DataHandler.java
public static List<MyModel> getWardList() { List<MyModel> myModels = new LinkedList<>(); String sqlQuery = "select distinct ward_no from bmc_history order by 1"; Connection con = getConnection(); Statement s = null;//from ww w .j a v a 2s .com ResultSet rs = null; try { s = con.createStatement(); rs = s.executeQuery(sqlQuery); myModels.add(new MyModel("0", "Choose Ward No.")); while (rs.next()) { myModels.add(new MyModel(rs.getString(1), rs.getString(1))); } } catch (Exception e) { log.error("getWardList: " + e.getMessage()); } finally { try { if (rs != null) { rs.close(); } if (s != null) { s.close(); } if (con != null) { con.close(); } } catch (SQLException ex) { log.error("getWardList: " + ex.getMessage()); } } return myModels; }
From source file:ems.util.DataHandler.java
public static List<MyModel> getCommunityList() { List<MyModel> myModels = new LinkedList<>(); String sqlQuery = "select distinct cast_nm from e_details where cast_nm is not null and cast_nm <>'' order by 1"; Connection con = getConnection(); Statement s = null;/*from w ww . jav a 2s . c o m*/ ResultSet rs = null; try { s = con.createStatement(); rs = s.executeQuery(sqlQuery); myModels.add(new MyModel("0", "Choose Community")); while (rs.next()) { myModels.add(new MyModel(rs.getString(1), rs.getString(1))); } } catch (Exception e) { log.error("getWardList: " + e.getMessage()); } finally { try { if (rs != null) { rs.close(); } if (s != null) { s.close(); } if (con != null) { con.close(); } } catch (SQLException ex) { log.error("getWardList: " + ex.getMessage()); } } return myModels; }
From source file:ems.util.DataHandler.java
public static List<MyModel> getBoothList() { List<MyModel> myModels = new LinkedList<>(); String sqlQuery = "select distinct booth_no, booth_id from booth_master order by 1"; Connection con = getConnection(); Statement s = null;//from ww w .j a va2 s . c o m ResultSet rs = null; try { s = con.createStatement(); rs = s.executeQuery(sqlQuery); myModels.add(new MyModel("0", "Choose Booth No.")); while (rs.next()) { myModels.add(new MyModel(rs.getString(1), rs.getString(2))); } } catch (Exception e) { log.error("getBoothList: " + e.getMessage()); } finally { try { if (rs != null) { rs.close(); } if (s != null) { s.close(); } if (con != null) { con.close(); } } catch (SQLException ex) { log.error("getBoothList: " + ex.getMessage()); } } return myModels; }
From source file:TestAppletNetscape.java
public void paint(Graphics g) { System.out.println("paint(): querying the database"); try {/*www .j av a 2 s. co m*/ PrivilegeManager.enablePrivilege("UniversalConnect"); Statement stmt = conn.createStatement(); ResultSet rset = stmt.executeQuery("select 'Hello '||initcap(USER) result from dual"); while (rset.next()) g.drawString(rset.getString(1), 10, 10); rset.close(); stmt.close(); } catch (SQLException e) { System.err.println("paint(): SQLException: " + e.getMessage()); } }
From source file:com.glaf.report.jxls.ReportManagerImpl.java
public List<?> exec(String sql) throws SQLException { try {/* w w w .ja v a 2 s .c o m*/ sql = evaluate(sql, beans); } catch (Exception ex) { log.error(sql); ex.printStackTrace(); } sql = sql.replaceAll("'", "'"); Statement stmt = connection.createStatement(); ResultSet rs = stmt.executeQuery(sql); RowSetDynaClass rsdc = new RowSetDynaClass(rs, false, true); stmt.close(); rs.close(); return rsdc.getRows(); }
From source file:com.hangum.tadpole.engine.sql.util.OracleObjectCompileUtils.java
/** * other object compile/*from ww w. j a v a2 s.c om*/ * * @param actionType * @param objType * @param objName * @param userDB */ public static String otherObjectCompile(PublicTadpoleDefine.QUERY_DDL_TYPE actionType, String objType, Map<String, String> paramMap, UserDBDAO userDB, boolean isDebug) throws Exception { String withDebugOption = ""; if (isDebug) withDebugOption = "DEBUG"; String sqlQuery = "ALTER " + objType + " " + paramMap.get("full_name") + " COMPILE " + withDebugOption; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ java.sql.Connection javaConn = null; Statement statement = null; ResultSet rs = null; try { SqlMapClient client = TadpoleSQLManager.getInstance(userDB); javaConn = client.getDataSource().getConnection(); statement = javaConn.createStatement(); statement.execute(sqlQuery); sqlQuery = "Select * From all_Errors where owner = nvl('" + paramMap.get("schema_name") //$NON-NLS-1$//$NON-NLS-2$ + "', user) and name='" + paramMap.get("object_name") + "' and type = '" + objType //$NON-NLS-1$ + "' order by type, sequence "; rs = statement.executeQuery(sqlQuery); StringBuffer result = new StringBuffer(); while (rs.next()) { result.append(prettyMsg(rs.getString("line"), rs.getString("position"), rs.getString("text"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ } return result.toString(); } finally { try { rs.close(); } catch (Exception e) { } try { statement.close(); } catch (Exception e) { } try { javaConn.close(); } catch (Exception e) { } } }
From source file:com.alibaba.dubbo.governance.status.DatabaseStatusChecker.java
public Status check() { boolean ok;// w ww . j a va 2 s . co m try { Connection connection = dataSource.getConnection(); try { DatabaseMetaData metaData = connection.getMetaData(); ResultSet resultSet = metaData.getTypeInfo(); try { ok = resultSet.next(); } finally { resultSet.close(); } if (message == null) { message = metaData.getURL() + " (" + metaData.getDatabaseProductName() + " " + metaData.getDatabaseProductVersion() + ", " + getIsolation(metaData.getDefaultTransactionIsolation()) + ")"; } if (version == 0) { version = metaData.getDatabaseMajorVersion(); } } finally { connection.close(); } } catch (Throwable e) { logger.error(e.getMessage(), e); ok = false; } return new Status(!ok ? Status.Level.ERROR : (version < 5 ? Status.Level.WARN : Status.Level.OK), message); }