### Eclipse Workspace Patch 1.0 #P jackrabbit-core Index: src/main/java/org/apache/jackrabbit/core/util/db/ConnectionHelper.java =================================================================== --- src/main/java/org/apache/jackrabbit/core/util/db/ConnectionHelper.java (revision 1181651) +++ src/main/java/org/apache/jackrabbit/core/util/db/ConnectionHelper.java (working copy) @@ -77,6 +77,8 @@ protected final DataSource dataSource; private ThreadLocal batchConnectionTl = new ThreadLocal(); + + private int fetchSize = 100; /** * @param dataSrc the {@link DataSource} on which this instance acts @@ -101,6 +103,18 @@ } /** + * @param dataSrc the {@link DataSource} on which this instance acts + * @param checkWithUserName whether the username is to be used for the {@link #tableExists(String)} method + * @param block whether the helper should transparently block on DB connection loss (otherwise it throws exceptions) + */ + protected ConnectionHelper(DataSource dataSrc, boolean checkWithUserName, boolean block, int fetchSize) { + dataSource = dataSrc; + checkTablesWithUserName = checkWithUserName; + blockOnConnectionLoss = block; + this.fetchSize = fetchSize; + } + + /** * A utility method that makes sure that identifier does only consist of characters that are * allowed in names on the target database. Illegal characters will be escaped as necessary. * @@ -326,7 +340,6 @@ * * @param sql an SQL statement string * @param params the parameters for the SQL statement - * @param returnGeneratedKeys whether generated keys should be returned * @return a {@link ResultSet} */ public final ResultSet query(String sql, Object... params) throws SQLException { @@ -369,11 +382,11 @@ stmt = con.prepareStatement(sql); } stmt.setMaxRows(maxRows); - int fetchSize = 10000; - if (0 < maxRows && maxRows < fetchSize) { - fetchSize = maxRows; // JCR-3090 + int currentFetchSize = this.fetchSize; + if (0 < maxRows && maxRows < currentFetchSize) { + currentFetchSize = maxRows; // JCR-3090 } - stmt.setFetchSize(fetchSize); + stmt.setFetchSize(currentFetchSize); execute(stmt, params); if (returnGeneratedKeys) { rs = stmt.getGeneratedKeys(); @@ -395,7 +408,7 @@ } } - /** + /** * Gets a connection based on the {@code batchMode} state of this helper. The connection should be closed * by a call to {@link #closeResources(Connection, Statement, ResultSet)} which also takes the {@code * batchMode} state into account. Index: src/main/java/org/apache/jackrabbit/core/persistence/pool/PostgreSQLPersistenceManager.java =================================================================== --- src/main/java/org/apache/jackrabbit/core/persistence/pool/PostgreSQLPersistenceManager.java (revision 1181651) +++ src/main/java/org/apache/jackrabbit/core/persistence/pool/PostgreSQLPersistenceManager.java (working copy) @@ -18,7 +18,11 @@ import java.sql.SQLException; +import javax.sql.DataSource; + import org.apache.jackrabbit.core.persistence.PMContext; +import org.apache.jackrabbit.core.util.db.ConnectionHelper; +import org.apache.jackrabbit.core.util.db.PostgreSQLConnectionHelper; /** * Extends the {@link BundleDbPersistenceManager} by PostgreSQL specific code. @@ -63,6 +67,14 @@ } /** + * {@inheritDoc} + */ + @Override + protected ConnectionHelper createConnectionHelper(DataSource dataSrc) throws Exception { + return new PostgreSQLConnectionHelper(dataSrc, blockOnConnectionLoss); + } + + /** * returns the storage model * @return the storage model */ Index: src/main/java/org/apache/jackrabbit/core/util/db/PostgreSQLConnectionHelper.java =================================================================== --- src/main/java/org/apache/jackrabbit/core/util/db/PostgreSQLConnectionHelper.java (revision 0) +++ src/main/java/org/apache/jackrabbit/core/util/db/PostgreSQLConnectionHelper.java (revision 0) @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.jackrabbit.core.util.db; + +import javax.sql.DataSource; + +/** + * The connection helper for PSQL databases. It has special fetch size handling. + */ +public final class PostgreSQLConnectionHelper extends ConnectionHelper { + + /** + * @param dataSrc the {@code DataSource} on which this helper acts + * @param block whether to block on connection loss until the db is up again + */ + public PostgreSQLConnectionHelper(DataSource dataSrc, boolean block) { + super(dataSrc, false, block, 10000); + } + +} Property changes on: src\main\java\org\apache\jackrabbit\core\util\db\PostgreSQLConnectionHelper.java ___________________________________________________________________ Added: svn:eol-style + native