/** * Resets the store by deleting the contents of the tables and reinitialising them. * @throws BlockStoreException If the tables couldn't be cleared and initialised. */ public void resetStore() throws BlockStoreException { maybeConnect(); try { deleteStore(); createTables(); initFromDatabase(); } catch (SQLException ex) { throw new RuntimeException(ex); } }
@Override public StoredBlock getOnceUndoableStoredBlock(Sha256Hash hash) throws BlockStoreException { return get(hash, true); }
Class.forName(getDatabaseDriverClass()); log.info(getDatabaseDriverClass() + " loaded. "); } catch (ClassNotFoundException e) { log.error("check CLASSPATH for database driver jar ", e); maybeConnect(); if (!tablesExists()) { createTables(); } else { checkCompatibility(); initFromDatabase(); } catch (SQLException e) { throw new BlockStoreException(e);
Statement s = conn.get().createStatement(); for (String sql : getCreateTablesSQL()) { if (log.isDebugEnabled()) { log.debug("DatabaseFullPrunedBlockStore : CREATE table [SQL= {0}]", sql); for (String sql : getCreateIndexesSQL()) { if (log.isDebugEnabled()) { log.debug("DatabaseFullPrunedBlockStore : CREATE index [SQL= {0}]", sql); PreparedStatement ps = conn.get().prepareStatement(getInsertSettingsSQL()); ps.setString(1, CHAIN_HEAD_SETTING); ps.setNull(2, Types.BINARY); ps.execute(); ps.close(); createNewStore(params);
PreparedStatement ps = conn.get().prepareStatement(getSelectSettingsSQL()); ResultSet rs; ps.setString(1, CHAIN_HEAD_SETTING); this.chainHeadBlock = get(hash); this.chainHeadHash = hash; if (this.chainHeadBlock == null) { rs.close(); ps.close(); this.verifiedChainHeadBlock = get(hash); this.verifiedChainHeadHash = hash; if (this.verifiedChainHeadBlock == null) {
maybeConnect(); PreparedStatement s = null; try { s = conn.get().prepareStatement(getBalanceSelectSQL()); s.setString(1, address.toString()); ResultSet rs = s.executeQuery();
/** * Check that the database is compatible with this version of the {@link DatabaseFullPrunedBlockStore}. * @throws BlockStoreException If the database is not compatible. */ private void checkCompatibility() throws SQLException, BlockStoreException { for(String sql : getCompatibilitySQL()) { PreparedStatement ps = null; try { ps = conn.get().prepareStatement(sql); ResultSet results = ps.executeQuery(); results.close(); } catch (SQLException ex) { throw new BlockStoreException("Database block store is not compatible with the current release. " + "See bitcoinj release notes for further information: " + ex.getMessage()); } finally { if (ps != null && !ps.isClosed()) { ps.close(); } } } }
for (String sql : getCreateSchemeSQL()) { s.execute(sql);
Class.forName(getDatabaseDriverClass()); log.info(getDatabaseDriverClass() + " loaded. "); } catch (ClassNotFoundException e) { log.error("check CLASSPATH for database driver jar ", e); maybeConnect(); if (!tablesExists()) { createTables(); } else { checkCompatibility(); initFromDatabase(); } catch (SQLException e) { throw new BlockStoreException(e);
Statement s = conn.get().createStatement(); for (String sql : getCreateTablesSQL()) { if (log.isDebugEnabled()) { log.debug("DatabaseFullPrunedBlockStore : CREATE table [SQL= {0}]", sql); for (String sql : getCreateIndexesSQL()) { if (log.isDebugEnabled()) { log.debug("DatabaseFullPrunedBlockStore : CREATE index [SQL= {0}]", sql); PreparedStatement ps = conn.get().prepareStatement(getInsertSettingsSQL()); ps.setString(1, CHAIN_HEAD_SETTING); ps.setNull(2, Types.BINARY); ps.execute(); ps.close(); createNewStore(params);
PreparedStatement ps = conn.get().prepareStatement(getSelectSettingsSQL()); ResultSet rs; ps.setString(1, CHAIN_HEAD_SETTING); this.chainHeadBlock = get(hash); this.chainHeadHash = hash; if (this.chainHeadBlock == null) { rs.close(); ps.close(); this.verifiedChainHeadBlock = get(hash); this.verifiedChainHeadHash = hash; if (this.verifiedChainHeadBlock == null) {
maybeConnect(); PreparedStatement s = null; try { s = conn.get().prepareStatement(getBalanceSelectSQL()); s.setString(1, address.toString()); ResultSet rs = s.executeQuery();
/** * Check that the database is compatible with this version of the {@link DatabaseFullPrunedBlockStore}. * @throws BlockStoreException If the database is not compatible. */ private void checkCompatibility() throws SQLException, BlockStoreException { for(String sql : getCompatibilitySQL()) { PreparedStatement ps = null; try { ps = conn.get().prepareStatement(sql); ResultSet results = ps.executeQuery(); results.close(); } catch (SQLException ex) { throw new BlockStoreException("Database block store is not compatible with the current release. " + "See bitcoinj release notes for further information: " + ex.getMessage()); } finally { if (ps != null && !ps.isClosed()) { ps.close(); } } } }
for (String sql : getCreateSchemeSQL()) { s.execute(sql);
Class.forName(getDatabaseDriverClass()); log.info(getDatabaseDriverClass() + " loaded. "); } catch (ClassNotFoundException e) { log.error("check CLASSPATH for database driver jar ", e); maybeConnect(); if (!tablesExists()) { createTables(); } else { checkCompatibility(); initFromDatabase(); } catch (SQLException e) { throw new BlockStoreException(e);
/** * Resets the store by deleting the contents of the tables and reinitialising them. * @throws BlockStoreException If the tables couldn't be cleared and initialised. */ public void resetStore() throws BlockStoreException { maybeConnect(); try { deleteStore(); createTables(); initFromDatabase(); } catch (SQLException ex) { throw new RuntimeException(ex); } }
Statement s = conn.get().createStatement(); for (String sql : getCreateTablesSQL()) { if (log.isDebugEnabled()) { log.debug("DatabaseFullPrunedBlockStore : CREATE table [SQL= {0}]", sql); for (String sql : getCreateIndexesSQL()) { if (log.isDebugEnabled()) { log.debug("DatabaseFullPrunedBlockStore : CREATE index [SQL= {0}]", sql); PreparedStatement ps = conn.get().prepareStatement(getInsertSettingsSQL()); ps.setString(1, CHAIN_HEAD_SETTING); ps.setNull(2, Types.BINARY); ps.execute(); ps.close(); createNewStore(params);
PreparedStatement ps = conn.get().prepareStatement(getSelectSettingsSQL()); ResultSet rs; ps.setString(1, CHAIN_HEAD_SETTING); this.chainHeadBlock = get(hash); this.chainHeadHash = hash; if (this.chainHeadBlock == null) { rs.close(); ps.close(); this.verifiedChainHeadBlock = get(hash); this.verifiedChainHeadHash = hash; if (this.verifiedChainHeadBlock == null) {
maybeConnect(); PreparedStatement s = null; try { s = conn.get().prepareStatement(getBalanceSelectSQL()); s.setString(1, address.toString()); ResultSet rs = s.executeQuery();
@Override public StoredBlock get(Sha256Hash hash) throws BlockStoreException { return get(hash, false); }