Package org.apache.jackrabbit.core.persistence.bundle.util

Examples of org.apache.jackrabbit.core.persistence.bundle.util.ConnectionRecoveryManager


    /**
     * {@inheritDoc}
     */
    public Iterator<DataIdentifier> getAllIdentifiers() throws DataStoreException {
        ConnectionRecoveryManager conn = getConnection();
        ArrayList<DataIdentifier> list = new ArrayList<DataIdentifier>();
        ResultSet rs = null;
        try {
            // SELECT ID FROM DATASTORE
            PreparedStatement prep = conn.executeStmt(selectAllSQL, new Object[0]);
            rs = prep.getResultSet();
            while (rs.next()) {
                String id = rs.getString(1);
                if (!id.startsWith(TEMP_PREFIX)) {
                    DataIdentifier identifier = new DataIdentifier(id);
View Full Code Here


    /**
     * {@inheritDoc}
     */
    public DataRecord getRecordIfStored(DataIdentifier identifier) throws DataStoreException {
        ConnectionRecoveryManager conn = getConnection();
        usesIdentifier(identifier);
        ResultSet rs = null;
        try {
            String id = identifier.toString();
            // SELECT LENGTH, LAST_MODIFIED FROM DATASTORE WHERE ID = ?
            PreparedStatement prep = conn.executeStmt(selectMetaSQL, new Object[]{id});
            rs = prep.getResultSet();
            if (!rs.next()) {
                throw new DataStoreException("Record not found: " + identifier);
            }
            long length = rs.getLong(1);
View Full Code Here

     * @param identifier data identifier
     * @throws DataStoreException if the data store could not be accessed,
     *          or if the given identifier is invalid
     */   
    InputStream openStream(DbInputStream inputStream, DataIdentifier identifier) throws DataStoreException {
        ConnectionRecoveryManager conn = null;
        ResultSet rs = null;
        try {
            conn = getConnection();
            // SELECT ID, DATA FROM DATASTORE WHERE ID = ?
            PreparedStatement prep = conn.executeStmt(selectDataSQL, new Object[]{identifier.toString()});
            rs = prep.getResultSet();
            if (!rs.next()) {
                throw new DataStoreException("Record not found: " + identifier);
            }
            InputStream stream = rs.getBinaryStream(2);
View Full Code Here

     */
    public synchronized void init(String homeDir) throws DataStoreException {
        try {
            initDatabaseType();
            connectionPool = new Pool(this, maxConnections);
            ConnectionRecoveryManager conn = getConnection();
            DatabaseMetaData meta = conn.getConnection().getMetaData();
            log.info("Using JDBC driver " + meta.getDriverName() + " " + meta.getDriverVersion());
            meta.getDriverVersion();
            ResultSet rs = meta.getTables(null, null, schemaObjectPrefix + tableSQL, null);
            boolean exists = rs.next();
            rs.close();
            if (!exists) {
                // CREATE TABLE DATASTORE(ID VARCHAR(255) PRIMARY KEY,
                // LENGTH BIGINT, LAST_MODIFIED BIGINT, DATA BLOB)
                conn.executeStmt(createTableSQL, null);
            }
            putBack(conn);
        } catch (Exception e) {
            throw convert("Can not init data store, driver=" + driver + " url=" + url + " user=" + user +
                    " schemaObjectPrefix=" + schemaObjectPrefix + " tableSQL=" + tableSQL + " createTableSQL=" + createTableSQL, e);
View Full Code Here

    private long updateLastModifiedDate(String key, long lastModified) throws DataStoreException {
        if (lastModified < minModifiedDate) {
            long now = System.currentTimeMillis();
            Long n = new Long(now);
            ConnectionRecoveryManager conn = getConnection();
            try {
                // UPDATE DATASTORE SET LAST_MODIFIED = ? WHERE ID = ? AND LAST_MODIFIED < ?
                conn.executeStmt(updateLastModifiedSQL, new Object[]{
                        n, key, n
                });
                return now;
            } catch (Exception e) {
                throw convert("Can not update lastModified", e);
View Full Code Here

        }
    }

    protected ConnectionRecoveryManager getConnection() throws DataStoreException {
        try {
            ConnectionRecoveryManager conn = (ConnectionRecoveryManager) connectionPool.get();
            conn.setAutoReconnect(true);
            return conn;
        } catch (InterruptedException e) {
            throw new DataStoreException("Interrupted", e);
        } catch (RepositoryException e) {
            throw new DataStoreException("Can not open a new connection", e);
View Full Code Here

     * Create a new connection.
     *
     * @return the new connection
     */
    public ConnectionRecoveryManager createNewConnection() throws RepositoryException {
        ConnectionRecoveryManager conn = new ConnectionRecoveryManager(false, driver, url, user, password);
        return conn;
    }
View Full Code Here

        }
        super.init(context);

        this.name = context.getHomeDir().getName();

        connectionManager = new ConnectionRecoveryManager(blockOnConnectionLoss,
                getDriver(), getUrl(), getUser(), getPassword());

        // make sure schemaObjectPrefix consists of legal name characters only
        prepareSchemaObjectPrefix();
View Full Code Here

        }
        super.init(context);

        this.name = context.getHomeDir().getName();

        connectionManager = new ConnectionRecoveryManager(blockOnConnectionLoss,
                getDriver(), getUrl(), getUser(), getPassword());

        // make sure schemaObjectPrefix consists of legal name characters only
        prepareSchemaObjectPrefix();
View Full Code Here

        }
        super.init(context);

        this.name = context.getHomeDir().getName();

        connectionManager = new ConnectionRecoveryManager(blockOnConnectionLoss,
                getDriver(), getUrl(), getUser(), getPassword());

        // make sure schemaObjectPrefix consists of legal name characters only
        prepareSchemaObjectPrefix();
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.core.persistence.bundle.util.ConnectionRecoveryManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.