@Override public long determineServerTimeDifferenceMillis() { Connection connection = null; try { connection = this.ch.getROConnection(); long result = this.db.determineServerTimeDifferenceMillis(connection); connection.commit(); return result; } catch (SQLException ex) { LOG.error("Trying to determine time difference to server", ex); throw asDocumentStoreException(ex, "Trying to determine time difference to server"); } finally { this.ch.closeConnection(connection); } }
private <T extends Document> void delete(Collection<T> collection, String id) { Connection connection = null; RDBTableMetaData tmd = getTable(collection); Stopwatch watch = startWatch(); try { connection = this.ch.getRWConnection(); db.delete(connection, tmd, Collections.singletonList(id)); connection.commit(); } catch (Exception ex) { this.ch.rollbackConnection(connection); throw handleException("removing " + id, ex, collection, id); } finally { this.ch.closeConnection(connection); stats.doneRemove(watch.elapsed(TimeUnit.NANOSECONDS), collection, 1); } }
Connection con = null; try { con = this.ch.getRWConnection(); Statement stmt = null; try { LOG.debug("attempting to drop: " + tname, ex); } finally { this.ch.closeConnection(con); this.ch.close(); } catch (IOException ex) { LOG.error("closing connection handler", ex);
/** * Obtain a {@link Connection} suitable for read-only operations. */ public @NotNull Connection getROConnection() throws SQLException { Connection c = getConnection(); c.setAutoCommit(false); setReadOnly(c, true); return c; }
@Override protected void mark(BlockId blockId) throws Exception { Connection con = this.ch.getRWConnection(); PreparedStatement prep = null; try { if (minLastModified == 0) { return; } String id = StringUtils.convertBytesToHex(blockId.getDigest()); prep = con.prepareStatement("update " + this.tnMeta + " set LASTMOD = ? where ID = ? and LASTMOD < ?"); prep.setLong(1, System.currentTimeMillis()); prep.setString(2, id); prep.setLong(3, minLastModified); prep.executeUpdate(); prep.close(); } finally { closeStatement(prep); con.commit(); this.ch.closeConnection(con); } }
Map<String, String> result = new HashMap<String, String>(); try { con = ch.getROConnection(); String conSchema = ch.getSchema(con); closeResultSet(rs); closeStatement(stmt); ch.closeConnection(con);
connection = this.ch.getROConnection(); PreparedStatement prep = null; ResultSet rs = null; closeStatement(prep); connection.commit(); this.ch.closeConnection(connection); this.ch.rollbackConnection(connection); this.ch.closeConnection(connection); return false;
this.tnMeta = RDBJDBCTools.createTableName(options.getTablePrefix(), "DATASTORE_META"); this.ch = new RDBConnectionHandler(ds); Connection con = this.ch.getRWConnection(); } finally { closeStatement(createStatement); this.ch.closeConnection(con);
this.ch = new RDBConnectionHandler(ds); Connection con = this.ch.getRWConnection(); String catalog = con.getCatalog(); DatabaseMetaData md = con.getMetaData();
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 Connection getROConnection() throws SQLException { cnt.incrementAndGet(); return super.getROConnection(); }
@Override protected void finalize() throws Throwable { if (!this.ch.isClosed() && this.callStack != null) { LOG.debug("finalizing RDBDocumentStore that was not disposed", this.callStack); } super.finalize(); }
@NotNull private Connection getConnection() throws IllegalStateException, SQLException { long ts = System.currentTimeMillis(); Connection c = getDataSource().getConnection(); if (LOG.isDebugEnabled()) { long elapsed = System.currentTimeMillis() - ts; if (elapsed >= 100) { LOG.debug("Obtaining a new connection from " + this.ds + " took " + elapsed + "ms"); } } return c; }
@Override protected void mark(BlockId blockId) throws Exception { Connection con = this.ch.getRWConnection(); PreparedStatement prep = null; try { if (minLastModified == 0) { return; } String id = StringUtils.convertBytesToHex(blockId.getDigest()); prep = con.prepareStatement("update " + this.tnMeta + " set LASTMOD = ? where ID = ? and LASTMOD < ?"); prep.setLong(1, System.currentTimeMillis()); prep.setString(2, id); prep.setLong(3, minLastModified); prep.executeUpdate(); prep.close(); } finally { closeStatement(prep); con.commit(); this.ch.closeConnection(con); } }
Map<String, String> result = new HashMap<String, String>(); try { con = ch.getROConnection(); String conSchema = ch.getSchema(con); closeResultSet(rs); closeStatement(stmt); ch.closeConnection(con);
connection = this.ch.getROConnection(); PreparedStatement prep = null; ResultSet rs = null; closeStatement(prep); connection.commit(); this.ch.closeConnection(connection); this.ch.rollbackConnection(connection); this.ch.closeConnection(connection); return false;
this.tnMeta = RDBJDBCTools.createTableName(options.getTablePrefix(), "DATASTORE_META"); this.ch = new RDBConnectionHandler(ds); Connection con = this.ch.getRWConnection(); } finally { closeStatement(createStatement); this.ch.closeConnection(con);
this.ch = new RDBConnectionHandler(ds); Connection con = this.ch.getRWConnection(); String catalog = con.getCatalog(); DatabaseMetaData md = con.getMetaData();
/** * Obtain a {@link Connection} suitable for read-write operations. */ public @NotNull Connection getRWConnection() throws SQLException { Connection c = getConnection(); c.setAutoCommit(false); setReadOnly(c, false); return c; }
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"); } } }