private void internalClose() { this.rs = closeResultSet(this.rs); this.stmt = closeStatement(this.stmt); this.ch.closeConnection(this.connection); this.connection = null; if (LOG.isDebugEnabled()) { LOG.debug(this.message + " -> " + this.cnt + " results in " + elapsed + "ms"); } } }
private void internalClose() { this.rs = closeResultSet(this.rs); this.stmt = closeStatement(this.stmt); this.ch.closeConnection(this.connection); this.connection = null; if (LOG.isDebugEnabled()) { LOG.debug(this.message + " -> " + this.cnt + " results in " + elapsed + "ms"); } } }
@Override public String getAdditionalDiagnostics(RDBConnectionHandler ch, String tableName) { Connection con = null; PreparedStatement stmt = null; ResultSet rs = null; Map<String, String> result = new HashMap<String, String>(); try { con = ch.getROConnection(); String cat = con.getCatalog(); stmt = con.prepareStatement("SELECT pg_encoding_to_char(encoding), datcollate FROM pg_database WHERE datname=?"); stmt.setString(1, cat); rs = stmt.executeQuery(); while (rs.next()) { result.put("pg_encoding_to_char(encoding)", rs.getString(1)); result.put("datcollate", rs.getString(2)); } con.commit(); } catch (SQLException ex) { LOG.debug("while getting diagnostics", ex); } finally { closeResultSet(rs); closeStatement(stmt); ch.closeConnection(con); } return result.toString(); }
public long getLong(Connection connection, RDBTableMetaData tmd, String aggregate, String field, String minId, String maxId, List<String> excludeKeyPatterns, List<QueryCondition> conditions) throws SQLException { PreparedStatement stmt = null; ResultSet rs = null; long start = System.currentTimeMillis(); long result = -1; String selector = aggregate + "(" + ("*".equals(field) ? "*" : INDEXED_PROP_MAPPING.get(field)) + ")"; try { stmt = prepareQuery(connection, tmd, selector, minId, maxId, excludeKeyPatterns, conditions, Integer.MAX_VALUE, null); rs = stmt.executeQuery(); result = rs.next() ? rs.getLong(1) : -1; return result; } finally { closeStatement(stmt); closeResultSet(rs); if (LOG.isDebugEnabled()) { long elapsed = System.currentTimeMillis() - start; String params = String.format("params minid '%s' maxid '%s' excludeKeyPatterns %s conditions %s.", minId, maxId, excludeKeyPatterns, conditions); LOG.debug("Aggregate query " + selector + " on " + tmd.getName() + " with " + params + " -> " + result + ", took " + elapsed + "ms"); } } }
@Override public String getAdditionalDiagnostics(RDBConnectionHandler ch, String tableName) { Connection con = null; PreparedStatement stmt = null; ResultSet rs = null; Map<String, String> result = new HashMap<String, String>(); try { con = ch.getROConnection(); String cat = con.getCatalog(); stmt = con.prepareStatement("SELECT collation_name FROM sys.databases WHERE name=?"); stmt.setString(1, cat); rs = stmt.executeQuery(); while (rs.next()) { result.put("collation_name", rs.getString(1)); } rs.close(); stmt.close(); con.commit(); } catch (SQLException ex) { LOG.debug("while getting diagnostics", ex); } finally { closeResultSet(rs); closeStatement(stmt); ch.closeConnection(con); } return result.toString(); }
@Override public String getAdditionalDiagnostics(RDBConnectionHandler ch, String tableName) { Connection con = null; Statement stmt = null; ResultSet rs = null; Map<String, String> result = new HashMap<String, String>(); try { con = ch.getROConnection(); stmt = con.createStatement(); rs = stmt .executeQuery("SELECT PARAMETER, VALUE from NLS_DATABASE_PARAMETERS WHERE PARAMETER IN ('NLS_COMP', 'NLS_CHARACTERSET')"); while (rs.next()) { result.put(rs.getString(1), rs.getString(2)); } stmt.close(); con.commit(); } catch (SQLException ex) { LOG.debug("while getting diagnostics", ex); } finally { closeResultSet(rs); closeStatement(stmt); ch.closeConnection(con); } return result.toString(); }
@Override public String getAdditionalDiagnostics(RDBConnectionHandler ch, String tableName) { Connection con = null; PreparedStatement stmt = null; ResultSet rs = null; Map<String, String> result = new HashMap<String, String>(); try { con = ch.getROConnection(); String cat = con.getCatalog(); stmt = con.prepareStatement("SELECT collation_name FROM sys.databases WHERE name=?"); stmt.setString(1, cat); rs = stmt.executeQuery(); while (rs.next()) { result.put("collation_name", rs.getString(1)); } rs.close(); stmt.close(); con.commit(); } catch (SQLException ex) { LOG.debug("while getting diagnostics", ex); } finally { closeResultSet(rs); closeStatement(stmt); ch.closeConnection(con); } return result.toString(); }
@Override public String getAdditionalDiagnostics(RDBConnectionHandler ch, String tableName) { Connection con = null; Statement stmt = null; ResultSet rs = null; Map<String, String> result = new HashMap<String, String>(); try { con = ch.getROConnection(); stmt = con.createStatement(); rs = stmt .executeQuery("SELECT PARAMETER, VALUE from NLS_DATABASE_PARAMETERS WHERE PARAMETER IN ('NLS_COMP', 'NLS_CHARACTERSET')"); while (rs.next()) { result.put(rs.getString(1), rs.getString(2)); } stmt.close(); con.commit(); } catch (SQLException ex) { LOG.debug("while getting diagnostics", ex); } finally { closeResultSet(rs); closeStatement(stmt); ch.closeConnection(con); } return result.toString(); }
@Override public String getAdditionalDiagnostics(RDBConnectionHandler ch, String tableName) { Connection con = null; PreparedStatement stmt = null; ResultSet rs = null; Map<String, String> result = new HashMap<String, String>(); try { con = ch.getROConnection(); String cat = con.getCatalog(); stmt = con.prepareStatement("SELECT pg_encoding_to_char(encoding), datcollate FROM pg_database WHERE datname=?"); stmt.setString(1, cat); rs = stmt.executeQuery(); while (rs.next()) { result.put("pg_encoding_to_char(encoding)", rs.getString(1)); result.put("datcollate", rs.getString(2)); } con.commit(); } catch (SQLException ex) { LOG.debug("while getting diagnostics", ex); } finally { closeResultSet(rs); closeStatement(stmt); ch.closeConnection(con); } return result.toString(); }
LOG.debug("while getting diagnostics", ex); } finally { closeResultSet(rs); closeStatement(stmt); ch.closeConnection(con);
public long getLong(Connection connection, RDBTableMetaData tmd, String aggregate, String field, String minId, String maxId, List<String> excludeKeyPatterns, List<QueryCondition> conditions) throws SQLException { PreparedStatement stmt = null; ResultSet rs = null; long start = System.currentTimeMillis(); long result = -1; String selector = aggregate + "(" + ("*".equals(field) ? "*" : INDEXED_PROP_MAPPING.get(field)) + ")"; try { stmt = prepareQuery(connection, tmd, selector, minId, maxId, excludeKeyPatterns, conditions, Integer.MAX_VALUE, null); rs = stmt.executeQuery(); result = rs.next() ? rs.getLong(1) : -1; return result; } finally { closeStatement(stmt); closeResultSet(rs); if (LOG.isDebugEnabled()) { long elapsed = System.currentTimeMillis() - start; String params = String.format("params minid '%s' maxid '%s' excludeKeyPatterns %s conditions %s.", minId, maxId, excludeKeyPatterns, conditions); LOG.debug("Aggregate query " + selector + " on " + tmd.getName() + " with " + params + " -> " + result + ", took " + elapsed + "ms"); } } }
LOG.debug("while getting diagnostics", ex); } finally { closeResultSet(rs); closeStatement(stmt); ch.closeConnection(con);
protected byte[] readBlockFromBackend(byte[] digest) throws Exception { String id = StringUtils.convertBytesToHex(digest); Connection con = this.ch.getROConnection(); byte[] data; try { PreparedStatement prep = con.prepareStatement("select DATA from " + this.tnData + " where ID = ?"); ResultSet rs = null; try { prep.setString(1, id); rs = prep.executeQuery(); if (!rs.next()) { throw new IOException("Datastore block " + id + " not found"); } data = rs.getBytes(1); } finally { closeResultSet(rs); closeStatement(prep); } } finally { con.commit(); this.ch.closeConnection(con); } return data; }
protected byte[] readBlockFromBackend(byte[] digest) throws Exception { String id = StringUtils.convertBytesToHex(digest); Connection con = this.ch.getROConnection(); byte[] data; try { PreparedStatement prep = con.prepareStatement("select DATA from " + this.tnData + " where ID = ?"); ResultSet rs = null; try { prep.setString(1, id); rs = prep.executeQuery(); if (!rs.next()) { throw new IOException("Datastore block " + id + " not found"); } data = rs.getBytes(1); } finally { closeResultSet(rs); closeStatement(prep); } } finally { con.commit(); this.ch.closeConnection(con); } return data; }
ex.getErrorCode(), ex.getSQLState()); } finally { closeResultSet(rs);
ex.getErrorCode(), ex.getSQLState()); } finally { closeResultSet(rs);
sdMaxRevTime, data, bdata); } else { this.rs = closeResultSet(this.rs); this.stmt = closeStatement(this.stmt); this.connection.commit();
private static void getTableMetaData(Connection con, Collection<? extends Document> col, RDBTableMetaData tmd) throws SQLException { Statement checkStatement = null; ResultSet checkResultSet = null; try { checkStatement = con.createStatement(); checkResultSet = checkStatement.executeQuery("select * from " + tmd.getName() + " where ID = '0'"); // try to discover size of DATA column and binary-ness of ID ResultSetMetaData met = checkResultSet.getMetaData(); obtainFlagsFromResultSetMeta(met, tmd); String tableInfo = RDBJDBCTools.dumpResultSetMeta(met); tmd.setSchemaInfo(tableInfo); String indexInfo = dumpIndexData(con.getMetaData(), met, tmd.getName(), null); tmd.setIndexInfo(indexInfo); } finally { closeResultSet(checkResultSet); closeStatement(checkStatement); } }
private static void getTableMetaData(Connection con, Collection<? extends Document> col, RDBTableMetaData tmd) throws SQLException { Statement checkStatement = null; ResultSet checkResultSet = null; try { checkStatement = con.createStatement(); checkResultSet = checkStatement.executeQuery("select * from " + tmd.getName() + " where ID = '0'"); // try to discover size of DATA column and binary-ness of ID ResultSetMetaData met = checkResultSet.getMetaData(); obtainFlagsFromResultSetMeta(met, tmd); String tableInfo = RDBJDBCTools.dumpResultSetMeta(met); tmd.setSchemaInfo(tableInfo); String indexInfo = dumpIndexData(con.getMetaData(), met, tmd.getName(), null); tmd.setIndexInfo(indexInfo); } finally { closeResultSet(checkResultSet); closeStatement(checkStatement); } }
public static boolean isDataEntryPresent(RDBBlobStore ds, byte[] digest) throws Exception { String id = StringUtils.convertBytesToHex(digest); Connection con = ds.ch.getROConnection(); PreparedStatement prep = null; ResultSet rs = null; try { prep = con.prepareStatement("select ID from " + ds.tnData + " where ID = ?"); prep.setString(1, id); rs = prep.executeQuery(); return rs.next(); } finally { closeResultSet(rs); closeStatement(prep); con.commit(); ds.ch.closeConnection(con); } }