Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2013-03-11 15:16:21 -0400
committerEike Stepper2013-03-11 15:16:21 -0400
commitf86cc1a1116425a9bc0ace0dfc1aa1b354f51cca (patch)
treec82b79332c51553824a86e9b73777512ca4f0d1b
parent22130bee60e57723c24b63a07a777f2e9eb9c614 (diff)
downloadcdo-f86cc1a1116425a9bc0ace0dfc1aa1b354f51cca.tar.gz
cdo-f86cc1a1116425a9bc0ace0dfc1aa1b354f51cca.tar.xz
cdo-f86cc1a1116425a9bc0ace0dfc1aa1b354f51cca.zip
[401763] Make CDO Server more robust against data dictionary changes
https://bugs.eclipse.org/bugs/show_bug.cgi?id=401763
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/CDODBUtil.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStoreAccessor.java10
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IPreparedStatementCache.java7
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/AbstractTypeMapping.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IClassMapping.java22
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/ITypeMapping.java7
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java46
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java52
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DurableLockingManager.java51
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ExternalReferenceManager.java12
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MetaDataManager.java19
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/SQLQueryHandler.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractFeatureMapTableMapping.java7
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalClassMapping.java7
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalMappingStrategy.java15
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractListTableMapping.java9
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditFeatureMapTableMapping.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditFeatureMapTableMappingWithRanges.java22
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditListTableMapping.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditListTableMappingWithRanges.java24
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingFeatureMapTableMapping.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingFeatureMapTableMappingWithRanges.java22
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMapping.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMappingWithRanges.java24
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditClassMapping.java29
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingClassMapping.java33
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategy.java28
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategyWithRanges.java25
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalNonAuditClassMapping.java23
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditFeatureMapTableMapping.java15
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditListTableMapping.java29
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/ObjectTypeTable.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/verifier/DBStoreVerifier.java2
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java9
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBConnection.java (renamed from plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBTransaction.java)35
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBDatabase.java8
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBPreparedStatement.java2
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBSchemaTransaction.java2
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBConnection.java415
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBDatabase.java40
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBPreparedStatement.java6
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBSchemaTransaction.java17
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBTransaction.java193
43 files changed, 776 insertions, 524 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/CDODBUtil.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/CDODBUtil.java
index b2c7eb698e..a1f7e64488 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/CDODBUtil.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/CDODBUtil.java
@@ -24,8 +24,8 @@ import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalMappi
import org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalNonAuditMappingStrategy;
import org.eclipse.net4j.db.IDBAdapter;
+import org.eclipse.net4j.db.IDBConnection;
import org.eclipse.net4j.db.IDBConnectionProvider;
-import org.eclipse.net4j.db.IDBTransaction;
import org.eclipse.net4j.util.ObjectUtil;
import org.eclipse.net4j.util.WrappedException;
import org.eclipse.net4j.util.container.IManagedContainer;
@@ -200,7 +200,7 @@ public final class CDODBUtil
/**
* @since 2.0
- * @deprecated As of 4.2 use {@link IDBTransaction#prepareStatement(String, org.eclipse.net4j.db.IDBPreparedStatement.ReuseProbability)}.
+ * @deprecated As of 4.2 use {@link IDBConnection#prepareStatement(String, org.eclipse.net4j.db.IDBPreparedStatement.ReuseProbability)}.
*/
@Deprecated
public static IPreparedStatementCache createStatementCache()
@@ -210,7 +210,7 @@ public final class CDODBUtil
/**
* @since 2.0
- * @deprecated As of 4.2 use {@link IDBTransaction#prepareStatement(String, org.eclipse.net4j.db.IDBPreparedStatement.ReuseProbability)}.
+ * @deprecated As of 4.2 use {@link IDBConnection#prepareStatement(String, org.eclipse.net4j.db.IDBPreparedStatement.ReuseProbability)}.
*/
@Deprecated
public static IPreparedStatementCache createStatementCache(int capacity)
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStoreAccessor.java
index 9adc0d5cbe..859e88fb63 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStoreAccessor.java
@@ -12,7 +12,7 @@ package org.eclipse.emf.cdo.server.db;
import org.eclipse.emf.cdo.server.IStoreAccessor;
-import org.eclipse.net4j.db.IDBTransaction;
+import org.eclipse.net4j.db.IDBConnection;
import java.sql.Connection;
@@ -30,17 +30,13 @@ public interface IDBStoreAccessor extends IStoreAccessor.Raw
/**
* @since 4.2
*/
- public IDBTransaction getDBTransaction();
+ public IDBConnection getDBConnection();
- /**
- * @deprecated As of 4.2 use {@link #getDBTransaction()}.
- */
- @Deprecated
public Connection getConnection();
/**
* @since 2.0
- * @depreacted As of 4.2 use {@link IDBTransaction#prepareStatement(String, org.eclipse.net4j.db.IDBPreparedStatement.ReuseProbability)}.
+ * @depreacted As of 4.2 use {@link IDBConnection#prepareStatement(String, org.eclipse.net4j.db.IDBPreparedStatement.ReuseProbability)}.
*/
@Deprecated
public IPreparedStatementCache getStatementCache();
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IPreparedStatementCache.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IPreparedStatementCache.java
index b6e8648eb4..bac5bc970a 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IPreparedStatementCache.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IPreparedStatementCache.java
@@ -11,19 +11,20 @@
*/
package org.eclipse.emf.cdo.server.db;
-import org.eclipse.net4j.db.IDBTransaction;
+import org.eclipse.net4j.db.IDBConnection;
+import org.eclipse.net4j.db.IDBPreparedStatement;
import java.sql.Connection;
import java.sql.PreparedStatement;
/**
- * Caches JDBC {@link PreparedStatement statements} according to given {@link ReuseProbability reuse probabilities}.
+ * Caches JDBC {@link IDBPreparedStatement statements} according to given {@link ReuseProbability reuse probabilities}.
*
* @author Stefan Winkler
* @since 2.0
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
- * @deprecated As of 4.2 use {@link IDBTransaction}.
+ * @deprecated As of 4.2 use {@link IDBConnection}.
*/
@Deprecated
public interface IPreparedStatementCache
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/AbstractTypeMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/AbstractTypeMapping.java
index e2600732e4..4d0b24c72b 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/AbstractTypeMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/AbstractTypeMapping.java
@@ -25,6 +25,7 @@ import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
import org.eclipse.net4j.db.DBType;
import org.eclipse.net4j.db.IDBAdapter;
+import org.eclipse.net4j.db.IDBPreparedStatement;
import org.eclipse.net4j.db.ddl.IDBField;
import org.eclipse.net4j.db.ddl.IDBTable;
import org.eclipse.net4j.util.container.IManagedContainer;
@@ -222,7 +223,7 @@ public abstract class AbstractTypeMapping implements ITypeMapping
* prepared statement.
*
* @param stmt
- * the {@link PreparedStatement} which is used for DB access
+ * the {@link IDBPreparedStatement} which is used for DB access
* @param index
* the parameter index in the statement which should be set
* @param value
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IClassMapping.java
index 68dad77fe2..c49e67ae2a 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IClassMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/IClassMapping.java
@@ -35,7 +35,7 @@ import java.util.Set;
/**
* Basic interface for class mappings.
- *
+ *
* @author Eike Stepper
* @author Stefan Winkler
* @since 2.0
@@ -49,7 +49,7 @@ public interface IClassMapping
/**
* Returns all DB tables which are used by this class and all its contained features.
- *
+ *
* @return a collection of all tables of this class and all its contained features.
* @since 3.0
*/
@@ -57,7 +57,7 @@ public interface IClassMapping
/**
* Get the mapping of the many-valued feature.
- *
+ *
* @param feature
* the feature for which the mapping should be returned. <code>feature.isMany()</code> has to be
* <code>true</code>.
@@ -79,7 +79,7 @@ public interface IClassMapping
* Read a revision. The branch and timestamp to be read are derived from the branchPoint which is set to the Revision.
* Note that non-audit stores only support {@link CDOBranchPoint#UNSPECIFIED_DATE} and non-branching stores only
* support the main branch.
- *
+ *
* @param accessor
* the accessor to use.
* @param revision
@@ -95,7 +95,7 @@ public interface IClassMapping
/**
* Write the revision data to the database.
- *
+ *
* @param accessor
* the accessor to use.
* @param revision
@@ -113,7 +113,7 @@ public interface IClassMapping
/**
* Detaches (deletes) a CDO object leaving a "ghost" revision behind.
- *
+ *
* @param accessor
* the accessor to use.
* @param id
@@ -131,7 +131,7 @@ public interface IClassMapping
/**
* Create a prepared statement which returns all IDs of instances of the corresponding class.
- *
+ *
* @param accessor
* the accessor to use to create the statement
* @return the prepared statement ready to be executed using <code>result.executeQuery()</code>.
@@ -141,7 +141,7 @@ public interface IClassMapping
/**
* Create a prepared statement which returns all IDs of instances of the corresponding class.
- *
+ *
* @param accessor
* the accessor to use to create the statement
* @param folderId
@@ -171,7 +171,7 @@ public interface IClassMapping
* <li>The <code>timeStamp</code> parameter is {@link CDOBranchPoint#UNSPECIFIED_DATE} or equal to
* <code>revision.getTimeStamp()</code>.
* </ul>
- *
+ *
* @see IMappingStrategy#handleRevisions(IDBStoreAccessor, org.eclipse.emf.ecore.EClass, CDOBranch, long, boolean,
* CDORevisionHandler)
* @since 4.0
@@ -182,7 +182,7 @@ public interface IClassMapping
/**
* Returns a set of CDOIDs that have at least one revision in any of the passed branches and time ranges.
* DetachedCDORevisions must also be considered!
- *
+ *
* @see IStoreAccessor#readChangeSet(OMMonitor, CDOChangeSetSegment...)
* @since 3.0
*/
@@ -190,7 +190,7 @@ public interface IClassMapping
/**
* Retrieve cross-references from DB
- *
+ *
* @param idString
* a string of the form "(id1, id2, id3, ...)" which can be used directly in SQL to form the where-part
* "SELECT * FROM foobar WHERE foobar.target IN [idString]".
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/ITypeMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/ITypeMapping.java
index 5aec9d092c..84682cacae 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/ITypeMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/ITypeMapping.java
@@ -17,6 +17,7 @@ import org.eclipse.emf.cdo.server.internal.db.mapping.TypeMappingUtil;
import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
import org.eclipse.net4j.db.DBType;
+import org.eclipse.net4j.db.IDBPreparedStatement;
import org.eclipse.net4j.db.ddl.IDBField;
import org.eclipse.net4j.db.ddl.IDBTable;
import org.eclipse.net4j.util.factory.IFactory;
@@ -98,7 +99,7 @@ public interface ITypeMapping
public void setDBField(IDBTable table, String fieldName);
/**
- * Set the given value to the JDBC {@link PreparedStatement} using an appropriate <code>setXxx</code> method.
+ * Set the given value to the JDBC {@link IDBPreparedStatement} using an appropriate <code>setXxx</code> method.
*
* @param stmt
* the prepared statement to set the value
@@ -112,7 +113,7 @@ public interface ITypeMapping
public void setValue(PreparedStatement stmt, int index, Object value) throws SQLException;
/**
- * Set the feature's default value to the JDBC {@link PreparedStatement} using an appropriate <code>setXxx</code>
+ * Set the feature's default value to the JDBC {@link IDBPreparedStatement} using an appropriate <code>setXxx</code>
* method.
*
* @param stmt
@@ -126,7 +127,7 @@ public interface ITypeMapping
public void setDefaultValue(PreparedStatement stmt, int index) throws SQLException;
/**
- * Set a value of the given revision to the JDBC {@link PreparedStatement} using an appropriate <code>setXxx</code>
+ * Set a value of the given revision to the JDBC {@link IDBPreparedStatement} using an appropriate <code>setXxx</code>
* method. The feature from which the value is taken is determined by {@link #getFeature()}.
*
* @param stmt
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java
index 97d11ca253..f2e85abdf1 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java
@@ -42,8 +42,11 @@ import org.eclipse.emf.cdo.spi.server.StoreAccessorPool;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBUtil;
import org.eclipse.net4j.db.IDBAdapter;
+import org.eclipse.net4j.db.IDBConnection;
import org.eclipse.net4j.db.IDBConnectionProvider;
import org.eclipse.net4j.db.IDBDatabase;
+import org.eclipse.net4j.db.IDBPreparedStatement;
+import org.eclipse.net4j.db.IDBPreparedStatement.ReuseProbability;
import org.eclipse.net4j.db.IDBSchemaTransaction;
import org.eclipse.net4j.db.ddl.IDBField;
import org.eclipse.net4j.db.ddl.IDBSchema;
@@ -53,7 +56,6 @@ import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
import org.eclipse.net4j.util.om.monitor.ProgressDistributor;
import java.sql.Connection;
-import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
@@ -291,24 +293,23 @@ public class DBStore extends Store implements IDBStore, IMappingConstants, CDOAl
public Map<String, String> getPersistentProperties(Set<String> names)
{
- Connection connection = null;
- PreparedStatement selectStmt = null;
+ IDBConnection connection = database.getConnection();
+ IDBPreparedStatement stmt = null;
String sql = null;
try
{
- connection = getConnection();
Map<String, String> result = new HashMap<String, String>();
boolean allProperties = names == null || names.isEmpty();
if (allProperties)
{
sql = CDODBSchema.SQL_SELECT_ALL_PROPERTIES;
- selectStmt = connection.prepareStatement(sql);
+ stmt = connection.prepareStatement(sql, ReuseProbability.MEDIUM);
ResultSet resultSet = null;
try
{
- resultSet = selectStmt.executeQuery();
+ resultSet = stmt.executeQuery();
while (resultSet.next())
{
String key = resultSet.getString(1);
@@ -324,15 +325,15 @@ public class DBStore extends Store implements IDBStore, IMappingConstants, CDOAl
else
{
sql = CDODBSchema.SQL_SELECT_PROPERTIES;
- selectStmt = connection.prepareStatement(sql);
+ stmt = connection.prepareStatement(sql, ReuseProbability.MEDIUM);
for (String name : names)
{
- selectStmt.setString(1, name);
+ stmt.setString(1, name);
ResultSet resultSet = null;
try
{
- resultSet = selectStmt.executeQuery();
+ resultSet = stmt.executeQuery();
if (resultSet.next())
{
String value = resultSet.getString(1);
@@ -354,24 +355,22 @@ public class DBStore extends Store implements IDBStore, IMappingConstants, CDOAl
}
finally
{
- DBUtil.close(selectStmt);
+ DBUtil.close(stmt);
DBUtil.close(connection);
}
}
public void setPersistentProperties(Map<String, String> properties)
{
- Connection connection = null;
- PreparedStatement deleteStmt = null;
- PreparedStatement insertStmt = null;
+ IDBConnection connection = database.getConnection();
+ IDBPreparedStatement deleteStmt = connection.prepareStatement(CDODBSchema.SQL_DELETE_PROPERTIES,
+ ReuseProbability.MEDIUM);
+ IDBPreparedStatement insertStmt = connection.prepareStatement(CDODBSchema.SQL_INSERT_PROPERTIES,
+ ReuseProbability.MEDIUM);
String sql = null;
try
{
- connection = getConnection();
- deleteStmt = connection.prepareStatement(CDODBSchema.SQL_DELETE_PROPERTIES);
- insertStmt = connection.prepareStatement(CDODBSchema.SQL_INSERT_PROPERTIES);
-
for (Entry<String, String> entry : properties.entrySet())
{
String name = entry.getKey();
@@ -412,18 +411,15 @@ public class DBStore extends Store implements IDBStore, IMappingConstants, CDOAl
public void removePersistentProperties(Set<String> names)
{
- Connection connection = null;
- PreparedStatement deleteStmt = null;
+ IDBConnection connection = database.getConnection();
+ IDBPreparedStatement stmt = connection.prepareStatement(CDODBSchema.SQL_DELETE_PROPERTIES, ReuseProbability.MEDIUM);
try
{
- connection = getConnection();
- deleteStmt = connection.prepareStatement(CDODBSchema.SQL_DELETE_PROPERTIES);
-
for (String name : names)
{
- deleteStmt.setString(1, name);
- deleteStmt.executeUpdate();
+ stmt.setString(1, name);
+ stmt.executeUpdate();
}
connection.commit();
@@ -434,7 +430,7 @@ public class DBStore extends Store implements IDBStore, IMappingConstants, CDOAl
}
finally
{
- DBUtil.close(deleteStmt);
+ DBUtil.close(stmt);
DBUtil.close(connection);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
index 1ad99b3ca7..0e94199c24 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
@@ -66,8 +66,9 @@ import org.eclipse.emf.cdo.spi.server.StoreAccessor;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.IDBConnection;
+import org.eclipse.net4j.db.IDBPreparedStatement;
import org.eclipse.net4j.db.IDBPreparedStatement.ReuseProbability;
-import org.eclipse.net4j.db.IDBTransaction;
import org.eclipse.net4j.util.HexUtil;
import org.eclipse.net4j.util.ObjectUtil;
import org.eclipse.net4j.util.StringUtil;
@@ -113,7 +114,7 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor,
{
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, DBStoreAccessor.class);
- private IDBTransaction transaction;
+ private IDBConnection connection;
private ConnectionKeepAliveTask connectionKeepAliveTask;
@@ -137,9 +138,14 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor,
return (DBStore)super.getStore();
}
- public IDBTransaction getDBTransaction()
+ public IDBConnection getDBConnection()
{
- return transaction;
+ return connection;
+ }
+
+ public Connection getConnection()
+ {
+ return connection;
}
@Deprecated
@@ -152,12 +158,12 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor,
// Do nothing
}
- public PreparedStatement getPreparedStatement(String sql, ReuseProbability reuseProbability)
+ public IDBPreparedStatement getPreparedStatement(String sql, ReuseProbability reuseProbability)
{
org.eclipse.net4j.db.IDBPreparedStatement.ReuseProbability converted = //
org.eclipse.net4j.db.IDBPreparedStatement.ReuseProbability.values()[reuseProbability.ordinal()];
- return transaction.prepareStatement(sql, converted);
+ return connection.prepareStatement(sql, converted);
}
public void releasePreparedStatement(PreparedStatement ps)
@@ -344,7 +350,7 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor,
public void queryLobs(List<byte[]> ids)
{
- PreparedStatement stmt = transaction.prepareStatement(CDODBSchema.SQL_QUERY_LOBS, ReuseProbability.MEDIUM);
+ IDBPreparedStatement stmt = connection.prepareStatement(CDODBSchema.SQL_QUERY_LOBS, ReuseProbability.MEDIUM);
ResultSet resultSet = null;
try
@@ -380,7 +386,7 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor,
public void loadLob(byte[] id, OutputStream out) throws IOException
{
- PreparedStatement stmt = transaction.prepareStatement(CDODBSchema.SQL_LOAD_LOB, ReuseProbability.MEDIUM);
+ IDBPreparedStatement stmt = connection.prepareStatement(CDODBSchema.SQL_LOAD_LOB, ReuseProbability.MEDIUM);
ResultSet resultSet = null;
try
@@ -416,7 +422,7 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor,
public void handleLobs(long fromTime, long toTime, CDOLobHandler handler) throws IOException
{
- PreparedStatement stmt = transaction.prepareStatement(CDODBSchema.SQL_HANDLE_LOBS, ReuseProbability.LOW);
+ IDBPreparedStatement stmt = connection.prepareStatement(CDODBSchema.SQL_HANDLE_LOBS, ReuseProbability.LOW);
ResultSet resultSet = null;
try
@@ -501,7 +507,7 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor,
protected void writeCommitInfo(CDOBranch branch, long timeStamp, long previousTimeStamp, String userID,
String comment, OMMonitor monitor)
{
- PreparedStatement stmt = transaction.prepareStatement(CDODBSchema.SQL_CREATE_COMMIT_INFO, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = connection.prepareStatement(CDODBSchema.SQL_CREATE_COMMIT_INFO, ReuseProbability.HIGH);
try
{
@@ -629,12 +635,6 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor,
}
}
- @Deprecated
- public Connection getConnection()
- {
- return transaction.getConnection();
- }
-
@Override
protected CDOID getNextCDOID(CDORevision revision)
{
@@ -644,7 +644,7 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor,
@Override
protected void writeBlob(byte[] id, long size, InputStream inputStream) throws IOException
{
- PreparedStatement stmt = transaction.prepareStatement(CDODBSchema.SQL_WRITE_BLOB, ReuseProbability.MEDIUM);
+ IDBPreparedStatement stmt = connection.prepareStatement(CDODBSchema.SQL_WRITE_BLOB, ReuseProbability.MEDIUM);
try
{
@@ -667,7 +667,7 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor,
@Override
protected void writeClob(byte[] id, long size, Reader reader) throws IOException
{
- PreparedStatement stmt = transaction.prepareStatement(CDODBSchema.SQL_WRITE_CLOB, ReuseProbability.MEDIUM);
+ IDBPreparedStatement stmt = connection.prepareStatement(CDODBSchema.SQL_WRITE_CLOB, ReuseProbability.MEDIUM);
try
{
@@ -757,7 +757,7 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor,
protected void doActivate() throws Exception
{
DBStore store = getStore();
- transaction = store.getDatabase().openTransaction();
+ connection = store.getDatabase().getConnection();
connectionKeepAliveTask = new ConnectionKeepAliveTask(this);
long keepAlivePeriod = ConnectionKeepAliveTask.EXECUTION_PERIOD;
@@ -780,8 +780,8 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor,
connectionKeepAliveTask.cancel();
connectionKeepAliveTask = null;
- ObjectUtil.close(transaction);
- transaction = null;
+ ObjectUtil.close(connection);
+ connection = null;
}
@Override
@@ -841,7 +841,7 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor,
branchID = getStore().getNextLocalBranchID();
}
- PreparedStatement stmt = transaction.prepareStatement(CDODBSchema.SQL_CREATE_BRANCH, ReuseProbability.LOW);
+ IDBPreparedStatement stmt = connection.prepareStatement(CDODBSchema.SQL_CREATE_BRANCH, ReuseProbability.LOW);
try
{
@@ -867,7 +867,7 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor,
public BranchInfo loadBranch(int branchID)
{
checkBranchingSupport();
- PreparedStatement stmt = transaction.prepareStatement(CDODBSchema.SQL_LOAD_BRANCH, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = connection.prepareStatement(CDODBSchema.SQL_LOAD_BRANCH, ReuseProbability.HIGH);
ResultSet resultSet = null;
try
@@ -899,7 +899,7 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor,
public SubBranchInfo[] loadSubBranches(int baseID)
{
checkBranchingSupport();
- PreparedStatement stmt = transaction.prepareStatement(CDODBSchema.SQL_LOAD_SUB_BRANCHES, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = connection.prepareStatement(CDODBSchema.SQL_LOAD_SUB_BRANCHES, ReuseProbability.HIGH);
ResultSet resultSet = null;
try
@@ -940,7 +940,7 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor,
public int loadBranches(int startID, int endID, CDOBranchHandler handler)
{
int count = 0;
- PreparedStatement stmt = transaction.prepareStatement(CDODBSchema.SQL_LOAD_BRANCHES, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = connection.prepareStatement(CDODBSchema.SQL_LOAD_BRANCHES, ReuseProbability.HIGH);
ResultSet resultSet = null;
InternalRepository repository = getSession().getManager().getRepository();
@@ -1032,7 +1032,7 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor,
builder.append(count < 0 || CDOBranchPoint.UNSPECIFIED_DATE <= endTime && endTime <= startTime ? " DESC" : " ASC"); //$NON-NLS-1$
String sql = builder.toString();
- PreparedStatement stmt = transaction.prepareStatement(sql, ReuseProbability.MEDIUM);
+ IDBPreparedStatement stmt = connection.prepareStatement(sql, ReuseProbability.MEDIUM);
ResultSet resultSet = null;
InternalRepository repository = getStore().getRepository();
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DurableLockingManager.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DurableLockingManager.java
index 64a74335bb..008c792df2 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DurableLockingManager.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DurableLockingManager.java
@@ -30,6 +30,7 @@ import org.eclipse.net4j.db.DBType;
import org.eclipse.net4j.db.DBUtil;
import org.eclipse.net4j.db.IDBDatabase;
import org.eclipse.net4j.db.IDBDatabase.RunnableWithSchema;
+import org.eclipse.net4j.db.IDBPreparedStatement;
import org.eclipse.net4j.db.IDBPreparedStatement.ReuseProbability;
import org.eclipse.net4j.db.ddl.IDBIndex;
import org.eclipse.net4j.db.ddl.IDBSchema;
@@ -40,7 +41,6 @@ import org.eclipse.net4j.util.om.monitor.OMMonitor;
import java.io.IOException;
import java.sql.Connection;
-import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Collection;
@@ -132,7 +132,7 @@ public class DurableLockingManager extends Lifecycle
}
}
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlInsertLockArea, ReuseProbability.LOW);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlInsertLockArea, ReuseProbability.LOW);
try
{
@@ -158,14 +158,14 @@ public class DurableLockingManager extends Lifecycle
insertLocks(accessor, durableLockingID, locks);
}
- accessor.getDBTransaction().commit();
+ commit(accessor);
return CDOLockUtil.createLockArea(durableLockingID, userID, branchPoint, readOnly, locks);
}
private void insertLocks(DBStoreAccessor accessor, String durableLockingID, Map<CDOID, LockGrade> locks)
{
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlInsertLock, ReuseProbability.MEDIUM);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlInsertLock, ReuseProbability.MEDIUM);
try
{
@@ -194,7 +194,7 @@ public class DurableLockingManager extends Lifecycle
public LockArea getLockArea(DBStoreAccessor accessor, String durableLockingID) throws LockAreaNotFoundException
{
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlSelectLockArea, ReuseProbability.MEDIUM);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlSelectLockArea, ReuseProbability.MEDIUM);
ResultSet resultSet = null;
try
@@ -227,18 +227,18 @@ public class DurableLockingManager extends Lifecycle
public void getLockAreas(DBStoreAccessor accessor, String userIDPrefix, Handler handler)
{
- PreparedStatement stmt = null;
+ IDBPreparedStatement stmt = null;
ResultSet resultSet = null;
try
{
if (userIDPrefix.length() == 0)
{
- stmt = accessor.getDBTransaction().prepareStatement(sqlSelectAllLockAreas, ReuseProbability.MEDIUM);
+ stmt = accessor.getDBConnection().prepareStatement(sqlSelectAllLockAreas, ReuseProbability.MEDIUM);
}
else
{
- stmt = accessor.getDBTransaction().prepareStatement(sqlSelectLockAreas, ReuseProbability.MEDIUM);
+ stmt = accessor.getDBConnection().prepareStatement(sqlSelectLockAreas, ReuseProbability.MEDIUM);
stmt.setString(1, userIDPrefix + "%");
}
@@ -273,7 +273,7 @@ public class DurableLockingManager extends Lifecycle
{
unlockWithoutCommit(accessor, durableLockingID);
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlDeleteLockArea, ReuseProbability.LOW);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlDeleteLockArea, ReuseProbability.LOW);
try
{
@@ -289,7 +289,7 @@ public class DurableLockingManager extends Lifecycle
DBUtil.close(stmt);
}
- accessor.getDBTransaction().commit();
+ commit(accessor);
}
public void updateLockArea(DBStoreAccessor accessor, LockArea area)
@@ -297,8 +297,7 @@ public class DurableLockingManager extends Lifecycle
String areaID = area.getDurableLockingID();
unlockWithoutCommit(accessor, areaID);
insertLocks(accessor, areaID, area.getLocks());
-
- accessor.getDBTransaction().commit();
+ commit(accessor);
}
public void lock(DBStoreAccessor accessor, String durableLockingID, LockType type,
@@ -316,12 +315,12 @@ public class DurableLockingManager extends Lifecycle
public void unlock(DBStoreAccessor accessor, String durableLockingID)
{
unlockWithoutCommit(accessor, durableLockingID);
- accessor.getDBTransaction().commit();
+ commit(accessor);
}
private void unlockWithoutCommit(DBStoreAccessor accessor, String durableLockingID)
{
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlDeleteLocks, ReuseProbability.MEDIUM);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlDeleteLocks, ReuseProbability.MEDIUM);
try
{
@@ -436,7 +435,7 @@ public class DurableLockingManager extends Lifecycle
private Map<CDOID, LockGrade> getLockMap(DBStoreAccessor accessor, String durableLockingID)
{
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlSelectLocks, ReuseProbability.MEDIUM);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlSelectLocks, ReuseProbability.MEDIUM);
ResultSet resultSet = null;
try
@@ -476,9 +475,11 @@ public class DurableLockingManager extends Lifecycle
String sql = on ? sqlInsertLock : sqlDeleteLock;
- PreparedStatement stmtSelect = accessor.getDBTransaction().prepareStatement(sqlSelectLock, ReuseProbability.MEDIUM);
- PreparedStatement stmtInsertOrDelete = accessor.getDBTransaction().prepareStatement(sql, ReuseProbability.MEDIUM);
- PreparedStatement stmtUpdate = accessor.getDBTransaction().prepareStatement(sqlUpdateLock, ReuseProbability.MEDIUM);
+ IDBPreparedStatement stmtSelect = accessor.getDBConnection().prepareStatement(sqlSelectLock,
+ ReuseProbability.MEDIUM);
+ IDBPreparedStatement stmtInsertOrDelete = accessor.getDBConnection().prepareStatement(sql, ReuseProbability.MEDIUM);
+ IDBPreparedStatement stmtUpdate = accessor.getDBConnection().prepareStatement(sqlUpdateLock,
+ ReuseProbability.MEDIUM);
ResultSet resultSet = null;
try
@@ -520,7 +521,7 @@ public class DurableLockingManager extends Lifecycle
}
}
- accessor.getDBTransaction().commit();
+ accessor.getDBConnection().commit();
}
catch (SQLException e)
{
@@ -565,4 +566,16 @@ public class DurableLockingManager extends Lifecycle
monitor.done();
}
}
+
+ private static void commit(DBStoreAccessor accessor)
+ {
+ try
+ {
+ accessor.getDBConnection().commit();
+ }
+ catch (SQLException ex)
+ {
+ throw new DBException(ex);
+ }
+ }
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ExternalReferenceManager.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ExternalReferenceManager.java
index 908e73f83b..b23ff9ccfd 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ExternalReferenceManager.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ExternalReferenceManager.java
@@ -28,6 +28,7 @@ import org.eclipse.net4j.db.DBType;
import org.eclipse.net4j.db.DBUtil;
import org.eclipse.net4j.db.IDBDatabase;
import org.eclipse.net4j.db.IDBDatabase.RunnableWithSchema;
+import org.eclipse.net4j.db.IDBPreparedStatement;
import org.eclipse.net4j.db.IDBPreparedStatement.ReuseProbability;
import org.eclipse.net4j.db.ddl.IDBIndex;
import org.eclipse.net4j.db.ddl.IDBSchema;
@@ -38,7 +39,6 @@ import org.eclipse.net4j.util.om.monitor.OMMonitor;
import java.io.IOException;
import java.sql.Connection;
-import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.concurrent.atomic.AtomicLong;
@@ -109,7 +109,7 @@ public class ExternalReferenceManager extends Lifecycle
public String unmapURI(IDBStoreAccessor accessor, long mappedId)
{
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlSelectByLongID, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlSelectByLongID, ReuseProbability.HIGH);
ResultSet resultSet = null;
try
@@ -138,7 +138,7 @@ public class ExternalReferenceManager extends Lifecycle
public long lookupByURI(IDBStoreAccessor accessor, String uri)
{
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlSelectByURI, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlSelectByURI, ReuseProbability.HIGH);
ResultSet resultSet = null;
try
@@ -207,7 +207,7 @@ public class ExternalReferenceManager extends Lifecycle
String sql = "SELECT MIN(" + EXTERNAL_REFS_ID + ") FROM " + table;
IDBStoreAccessor writer = store.getWriter(null);
- PreparedStatement stmt = writer.getDBTransaction().prepareStatement(sql, ReuseProbability.LOW);
+ IDBPreparedStatement stmt = writer.getDBConnection().prepareStatement(sql, ReuseProbability.LOW);
ResultSet resultSet = null;
try
@@ -223,7 +223,7 @@ public class ExternalReferenceManager extends Lifecycle
}
catch (SQLException ex)
{
- writer.getDBTransaction().rollback();
+ writer.getDBConnection().rollback();
throw new DBException(ex);
}
finally
@@ -243,7 +243,7 @@ public class ExternalReferenceManager extends Lifecycle
private long insertNew(IDBStoreAccessor accessor, String uri, long commitTime)
{
long newMappedID = lastMappedID.decrementAndGet();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlInsert, ReuseProbability.MEDIUM);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlInsert, ReuseProbability.MEDIUM);
try
{
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MetaDataManager.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MetaDataManager.java
index 7355da320a..038407aeec 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MetaDataManager.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MetaDataManager.java
@@ -33,6 +33,9 @@ import org.eclipse.emf.cdo.spi.common.model.InternalCDOPackageUnit;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.IDBConnection;
+import org.eclipse.net4j.db.IDBPreparedStatement;
+import org.eclipse.net4j.db.IDBPreparedStatement.ReuseProbability;
import org.eclipse.net4j.db.IDBRowHandler;
import org.eclipse.net4j.util.lifecycle.Lifecycle;
import org.eclipse.net4j.util.om.monitor.Monitor;
@@ -49,7 +52,6 @@ import org.eclipse.emf.ecore.util.EcoreUtil;
import java.io.IOException;
import java.sql.Connection;
-import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
@@ -136,7 +138,7 @@ public class MetaDataManager extends Lifecycle implements IMetaDataManager
try
{
monitor.begin(2);
- fillSystemTables(connection, packageUnits, monitor.fork());
+ fillSystemTables((IDBConnection)connection, packageUnits, monitor.fork());
}
finally
{
@@ -222,7 +224,7 @@ public class MetaDataManager extends Lifecycle implements IMetaDataManager
return EMFUtil.getEPackageBytes(ePackage, ZIP_PACKAGE_BYTES, getPackageRegistry());
}
- private void fillSystemTables(Connection connection, InternalCDOPackageUnit packageUnit, OMMonitor monitor)
+ private void fillSystemTables(IDBConnection connection, InternalCDOPackageUnit packageUnit, OMMonitor monitor)
{
if (TRACER.isEnabled())
{
@@ -237,12 +239,11 @@ public class MetaDataManager extends Lifecycle implements IMetaDataManager
{
String sql = "INSERT INTO " + CDODBSchema.PACKAGE_UNITS + " VALUES (?, ?, ?, ?)"; //$NON-NLS-1$ //$NON-NLS-2$
DBUtil.trace(sql);
- PreparedStatement stmt = null;
+ IDBPreparedStatement stmt = connection.prepareStatement(sql, ReuseProbability.MEDIUM);
try
{
async = monitor.forkAsync();
- stmt = connection.prepareStatement(sql);
stmt.setString(1, packageUnit.getID());
stmt.setInt(2, packageUnit.getOriginalType().ordinal());
stmt.setLong(3, packageUnit.getTimeStamp());
@@ -282,7 +283,7 @@ public class MetaDataManager extends Lifecycle implements IMetaDataManager
}
}
- private void fillSystemTables(Connection connection, InternalCDOPackageUnit[] packageUnits, OMMonitor monitor)
+ private void fillSystemTables(IDBConnection connection, InternalCDOPackageUnit[] packageUnits, OMMonitor monitor)
{
try
{
@@ -298,7 +299,7 @@ public class MetaDataManager extends Lifecycle implements IMetaDataManager
}
}
- private void fillSystemTables(Connection connection, InternalCDOPackageInfo packageInfo, OMMonitor monitor)
+ private void fillSystemTables(IDBConnection connection, InternalCDOPackageInfo packageInfo, OMMonitor monitor)
{
if (TRACER.isEnabled())
{
@@ -311,12 +312,12 @@ public class MetaDataManager extends Lifecycle implements IMetaDataManager
String sql = "INSERT INTO " + CDODBSchema.PACKAGE_INFOS + " VALUES (?, ?, ?)"; //$NON-NLS-1$ //$NON-NLS-2$
DBUtil.trace(sql);
- PreparedStatement stmt = null;
+
+ IDBPreparedStatement stmt = connection.prepareStatement(sql, ReuseProbability.MEDIUM);
Async async = monitor.forkAsync();
try
{
- stmt = connection.prepareStatement(sql);
stmt.setString(1, packageURI);
stmt.setString(2, parentURI);
stmt.setString(3, unitID);
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/SQLQueryHandler.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/SQLQueryHandler.java
index 1723a99bef..909c10acc0 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/SQLQueryHandler.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/SQLQueryHandler.java
@@ -21,10 +21,10 @@ import org.eclipse.emf.cdo.server.db.IIDHandler;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.IDBPreparedStatement;
import org.eclipse.net4j.db.IDBPreparedStatement.ReuseProbability;
import java.sql.Clob;
-import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
@@ -103,7 +103,7 @@ public class SQLQueryHandler implements IQueryHandler
boolean mapQuery = false;
IIDHandler idHandler = accessor.getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(query, ResultSet.TYPE_SCROLL_INSENSITIVE,
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(query, ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY, ReuseProbability.MEDIUM);
ResultSet resultSet = null;
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractFeatureMapTableMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractFeatureMapTableMapping.java
index 1249a6870d..4da987ebc3 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractFeatureMapTableMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractFeatureMapTableMapping.java
@@ -36,6 +36,7 @@ import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBType;
import org.eclipse.net4j.db.DBUtil;
import org.eclipse.net4j.db.IDBDatabase;
+import org.eclipse.net4j.db.IDBPreparedStatement;
import org.eclipse.net4j.db.IDBPreparedStatement.ReuseProbability;
import org.eclipse.net4j.db.ddl.IDBField;
import org.eclipse.net4j.db.ddl.IDBIndex;
@@ -319,7 +320,7 @@ public abstract class AbstractFeatureMapTableMapping extends AbstractBasicListTa
String sql = sqlSelectChunksPrefix + sqlOrderByIndex;
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sql, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sql, ReuseProbability.HIGH);
ResultSet resultSet = null;
try
@@ -395,7 +396,7 @@ public abstract class AbstractFeatureMapTableMapping extends AbstractBasicListTa
String sql = builder.toString();
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = chunkReader.getAccessor().getDBTransaction().prepareStatement(sql, ReuseProbability.LOW);
+ IDBPreparedStatement stmt = chunkReader.getAccessor().getDBConnection().prepareStatement(sql, ReuseProbability.LOW);
ResultSet resultSet = null;
try
@@ -488,7 +489,7 @@ public abstract class AbstractFeatureMapTableMapping extends AbstractBasicListTa
String columnName = getColumnName(tag);
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlInsert, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlInsert, ReuseProbability.HIGH);
try
{
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalClassMapping.java
index fd2e52a6de..df97a1d1bb 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalClassMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalClassMapping.java
@@ -41,6 +41,7 @@ import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBType;
import org.eclipse.net4j.db.DBUtil;
import org.eclipse.net4j.db.IDBDatabase;
+import org.eclipse.net4j.db.IDBPreparedStatement;
import org.eclipse.net4j.db.IDBPreparedStatement.ReuseProbability;
import org.eclipse.net4j.db.ddl.IDBField;
import org.eclipse.net4j.db.ddl.IDBIndex;
@@ -604,7 +605,7 @@ public abstract class AbstractHorizontalClassMapping implements IClassMapping, I
}
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(builder.toString(), ReuseProbability.LOW);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(builder.toString(), ReuseProbability.LOW);
ResultSet resultSet = null;
try
@@ -671,7 +672,7 @@ public abstract class AbstractHorizontalClassMapping implements IClassMapping, I
}
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(builder.toString(), ReuseProbability.LOW);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(builder.toString(), ReuseProbability.LOW);
ResultSet resultSet = null;
Set<CDOID> result = new HashSet<CDOID>();
@@ -857,7 +858,7 @@ public abstract class AbstractHorizontalClassMapping implements IClassMapping, I
}
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sql, ReuseProbability.MEDIUM);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sql, ReuseProbability.MEDIUM);
ResultSet resultSet = null;
try
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalMappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalMappingStrategy.java
index 8cf3ada1f6..e353179a6f 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalMappingStrategy.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalMappingStrategy.java
@@ -36,6 +36,7 @@ import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBUtil;
import org.eclipse.net4j.db.DBUtil.DeserializeRowHandler;
import org.eclipse.net4j.db.IDBAdapter;
+import org.eclipse.net4j.db.IDBConnection;
import org.eclipse.net4j.db.ddl.IDBTable;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
import org.eclipse.net4j.util.om.monitor.OMMonitor;
@@ -182,7 +183,7 @@ public abstract class AbstractHorizontalMappingStrategy extends AbstractMappingS
builder.append(toCommitTime);
String attrSuffix = builder.toString();
- Connection connection = accessor.getConnection();
+ IDBConnection connection = accessor.getDBConnection();
Collection<IClassMapping> classMappings = getClassMappings(true).values();
out.writeInt(classMappings.size());
@@ -204,8 +205,8 @@ public abstract class AbstractHorizontalMappingStrategy extends AbstractMappingS
objectTypeMapper.rawExport(connection, out, fromCommitTime, toCommitTime);
}
- protected void rawExportList(CDODataOutput out, Connection connection, IListMapping listMapping, IDBTable attrTable,
- String attrSuffix) throws IOException
+ protected void rawExportList(CDODataOutput out, IDBConnection connection, IListMapping listMapping,
+ IDBTable attrTable, String attrSuffix) throws IOException
{
for (IDBTable table : listMapping.getDBTables())
{
@@ -239,7 +240,7 @@ public abstract class AbstractHorizontalMappingStrategy extends AbstractMappingS
try
{
- Connection connection = accessor.getConnection();
+ IDBConnection connection = accessor.getDBConnection();
for (int i = 0; i < size; i++)
{
EClass eClass = (EClass)in.readCDOClassifierRefAndResolve();
@@ -283,18 +284,18 @@ public abstract class AbstractHorizontalMappingStrategy extends AbstractMappingS
}
}
- protected void rawImportUnreviseNewRevisions(Connection connection, IDBTable table, long fromCommitTime,
+ protected void rawImportUnreviseNewRevisions(IDBConnection connection, IDBTable table, long fromCommitTime,
long toCommitTime, OMMonitor monitor)
{
throw new UnsupportedOperationException("Must be overridden");
}
- protected void rawImportReviseOldRevisions(Connection connection, IDBTable table, OMMonitor monitor)
+ protected void rawImportReviseOldRevisions(IDBConnection connection, IDBTable table, OMMonitor monitor)
{
throw new UnsupportedOperationException("Must be overridden");
}
- protected void rawImportList(CDODataInput in, Connection connection, IListMapping listMapping, OMMonitor monitor)
+ protected void rawImportList(CDODataInput in, IDBConnection connection, IListMapping listMapping, OMMonitor monitor)
throws IOException
{
Collection<IDBTable> tables = listMapping.getDBTables();
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractListTableMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractListTableMapping.java
index 5df8bcaf87..de73796897 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractListTableMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractListTableMapping.java
@@ -31,6 +31,7 @@ import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBType;
import org.eclipse.net4j.db.DBUtil;
import org.eclipse.net4j.db.IDBDatabase;
+import org.eclipse.net4j.db.IDBPreparedStatement;
import org.eclipse.net4j.db.IDBPreparedStatement.ReuseProbability;
import org.eclipse.net4j.db.ddl.IDBField;
import org.eclipse.net4j.db.ddl.IDBIndex;
@@ -229,7 +230,7 @@ public abstract class AbstractListTableMapping extends AbstractBasicListTableMap
}
String sql = sqlSelectChunksPrefix + sqlOrderByIndex;
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sql, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sql, ReuseProbability.HIGH);
ResultSet resultSet = null;
try
@@ -295,7 +296,7 @@ public abstract class AbstractListTableMapping extends AbstractBasicListTableMap
builder.append(sqlOrderByIndex);
String sql = builder.toString();
- PreparedStatement stmt = chunkReader.getAccessor().getDBTransaction().prepareStatement(sql, ReuseProbability.LOW);
+ IDBPreparedStatement stmt = chunkReader.getAccessor().getDBConnection().prepareStatement(sql, ReuseProbability.LOW);
ResultSet resultSet = null;
try
@@ -379,7 +380,7 @@ public abstract class AbstractListTableMapping extends AbstractBasicListTableMap
getFeature().getName(), idx, revision.getID(), revision.getVersion(), value);
}
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlInsertEntry, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlInsertEntry, ReuseProbability.HIGH);
try
{
@@ -431,7 +432,7 @@ public abstract class AbstractListTableMapping extends AbstractBasicListTableMap
}
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sql, ReuseProbability.MEDIUM);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sql, ReuseProbability.MEDIUM);
ResultSet resultSet = null;
try
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditFeatureMapTableMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditFeatureMapTableMapping.java
index 2e5269cd53..a969bb5a99 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditFeatureMapTableMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditFeatureMapTableMapping.java
@@ -22,6 +22,7 @@ import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBType;
import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.IDBPreparedStatement;
import org.eclipse.net4j.db.IDBPreparedStatement.ReuseProbability;
import org.eclipse.emf.ecore.EClass;
@@ -84,7 +85,7 @@ public class AuditFeatureMapTableMapping extends AbstractFeatureMapTableMapping
public void rawDeleted(IDBStoreAccessor accessor, CDOID id, CDOBranch branch, int version)
{
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlClear, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlClear, ReuseProbability.HIGH);
try
{
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditFeatureMapTableMappingWithRanges.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditFeatureMapTableMappingWithRanges.java
index 21ffa9ca7b..d1918b7e32 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditFeatureMapTableMappingWithRanges.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditFeatureMapTableMappingWithRanges.java
@@ -50,6 +50,7 @@ import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBType;
import org.eclipse.net4j.db.DBUtil;
import org.eclipse.net4j.db.IDBDatabase;
+import org.eclipse.net4j.db.IDBPreparedStatement;
import org.eclipse.net4j.db.IDBPreparedStatement.ReuseProbability;
import org.eclipse.net4j.db.ddl.IDBIndex.Type;
import org.eclipse.net4j.db.ddl.IDBTable;
@@ -61,7 +62,6 @@ import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.util.FeatureMap;
-import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
@@ -405,7 +405,7 @@ public class AuditFeatureMapTableMappingWithRanges extends AbstractBasicListTabl
String sql = sqlSelectChunksPrefix + sqlOrderByIndex;
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sql, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sql, ReuseProbability.HIGH);
ResultSet resultSet = null;
try
@@ -483,7 +483,7 @@ public class AuditFeatureMapTableMappingWithRanges extends AbstractBasicListTabl
String sql = builder.toString();
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = chunkReader.getAccessor().getDBTransaction().prepareStatement(sql, ReuseProbability.LOW);
+ IDBPreparedStatement stmt = chunkReader.getAccessor().getDBConnection().prepareStatement(sql, ReuseProbability.LOW);
ResultSet resultSet = null;
try
@@ -647,9 +647,9 @@ public class AuditFeatureMapTableMappingWithRanges extends AbstractBasicListTabl
public void clearList(IDBStoreAccessor accessor, CDOID id, int oldVersion, int newVersion)
{
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmtDeleteTemp = accessor.getDBTransaction().prepareStatement(sqlDeleteList,
+ IDBPreparedStatement stmtDeleteTemp = accessor.getDBConnection().prepareStatement(sqlDeleteList,
ReuseProbability.HIGH);
- PreparedStatement stmtClear = accessor.getDBTransaction().prepareStatement(sqlClearList, ReuseProbability.HIGH);
+ IDBPreparedStatement stmtClear = accessor.getDBConnection().prepareStatement(sqlClearList, ReuseProbability.HIGH);
try
{
@@ -891,7 +891,7 @@ public class AuditFeatureMapTableMappingWithRanges extends AbstractBasicListTabl
int endIndex)
{
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlUpdateIndex, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlUpdateIndex, ReuseProbability.HIGH);
try
{
@@ -959,7 +959,7 @@ public class AuditFeatureMapTableMappingWithRanges extends AbstractBasicListTabl
int endIndex)
{
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlUpdateIndex, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlUpdateIndex, ReuseProbability.HIGH);
try
{
@@ -1039,7 +1039,7 @@ public class AuditFeatureMapTableMappingWithRanges extends AbstractBasicListTabl
String columnName = getColumnName(tag);
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlInsert, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlInsert, ReuseProbability.HIGH);
try
{
@@ -1087,7 +1087,7 @@ public class AuditFeatureMapTableMappingWithRanges extends AbstractBasicListTabl
}
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlDeleteEntry, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlDeleteEntry, ReuseProbability.HIGH);
try
{
@@ -1118,7 +1118,7 @@ public class AuditFeatureMapTableMappingWithRanges extends AbstractBasicListTabl
{
// no temporary entry found, so mark the entry as removed
DBUtil.close(stmt);
- stmt = accessor.getDBTransaction().prepareStatement(sqlRemoveEntry, ReuseProbability.HIGH);
+ stmt = accessor.getDBConnection().prepareStatement(sqlRemoveEntry, ReuseProbability.HIGH);
column = 1;
stmt.setInt(column++, newVersion);
@@ -1156,7 +1156,7 @@ public class AuditFeatureMapTableMappingWithRanges extends AbstractBasicListTabl
private FeatureMap.Entry getValue(IDBStoreAccessor accessor, CDOID id, int index)
{
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlGetValue, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlGetValue, ReuseProbability.HIGH);
try
{
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditListTableMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditListTableMapping.java
index 121664a824..21aacc6531 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditListTableMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditListTableMapping.java
@@ -21,6 +21,7 @@ import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBType;
import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.IDBPreparedStatement;
import org.eclipse.net4j.db.IDBPreparedStatement.ReuseProbability;
import org.eclipse.net4j.db.ddl.IDBTable;
@@ -86,7 +87,7 @@ public class AuditListTableMapping extends AbstractListTableMapping
public void rawDeleted(IDBStoreAccessor accessor, CDOID id, CDOBranch branch, int version)
{
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlClear, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlClear, ReuseProbability.HIGH);
try
{
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditListTableMappingWithRanges.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditListTableMappingWithRanges.java
index b222970db8..7e3d60b445 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditListTableMappingWithRanges.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditListTableMappingWithRanges.java
@@ -46,6 +46,7 @@ import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBType;
import org.eclipse.net4j.db.DBUtil;
import org.eclipse.net4j.db.IDBDatabase;
+import org.eclipse.net4j.db.IDBPreparedStatement;
import org.eclipse.net4j.db.IDBPreparedStatement.ReuseProbability;
import org.eclipse.net4j.db.ddl.IDBIndex.Type;
import org.eclipse.net4j.db.ddl.IDBTable;
@@ -57,7 +58,6 @@ import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
-import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Collection;
@@ -304,7 +304,7 @@ public class AuditListTableMappingWithRanges extends AbstractBasicListTableMappi
String sql = sqlSelectChunksPrefix + sqlOrderByIndex;
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sql, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sql, ReuseProbability.HIGH);
ResultSet resultSet = null;
try
@@ -370,7 +370,7 @@ public class AuditListTableMappingWithRanges extends AbstractBasicListTableMappi
String sql = builder.toString();
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = chunkReader.getAccessor().getDBTransaction().prepareStatement(sql, ReuseProbability.LOW);
+ IDBPreparedStatement stmt = chunkReader.getAccessor().getDBConnection().prepareStatement(sql, ReuseProbability.LOW);
ResultSet resultSet = null;
try
@@ -479,9 +479,9 @@ public class AuditListTableMappingWithRanges extends AbstractBasicListTableMappi
public void clearList(IDBStoreAccessor accessor, CDOID id, int oldVersion, int newVersion)
{
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmtDeleteTemp = accessor.getDBTransaction().prepareStatement(sqlDeleteList,
+ IDBPreparedStatement stmtDeleteTemp = accessor.getDBConnection().prepareStatement(sqlDeleteList,
ReuseProbability.HIGH);
- PreparedStatement stmtClear = accessor.getDBTransaction().prepareStatement(sqlClearList, ReuseProbability.HIGH);
+ IDBPreparedStatement stmtClear = accessor.getDBConnection().prepareStatement(sqlClearList, ReuseProbability.HIGH);
try
{
@@ -761,7 +761,7 @@ public class AuditListTableMappingWithRanges extends AbstractBasicListTableMappi
int endIndex)
{
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlUpdateIndex, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlUpdateIndex, ReuseProbability.HIGH);
try
{
@@ -829,7 +829,7 @@ public class AuditListTableMappingWithRanges extends AbstractBasicListTableMappi
int endIndex)
{
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlUpdateIndex, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlUpdateIndex, ReuseProbability.HIGH);
try
{
@@ -903,7 +903,7 @@ public class AuditListTableMappingWithRanges extends AbstractBasicListTableMappi
}
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlInsertEntry, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlInsertEntry, ReuseProbability.HIGH);
try
{
@@ -938,7 +938,7 @@ public class AuditListTableMappingWithRanges extends AbstractBasicListTableMappi
}
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlDeleteEntry, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlDeleteEntry, ReuseProbability.HIGH);
try
{
@@ -969,7 +969,7 @@ public class AuditListTableMappingWithRanges extends AbstractBasicListTableMappi
{
// no temporary entry found, so mark the entry as removed
DBUtil.close(stmt);
- stmt = accessor.getDBTransaction().prepareStatement(sqlRemoveEntry, ReuseProbability.HIGH);
+ stmt = accessor.getDBConnection().prepareStatement(sqlRemoveEntry, ReuseProbability.HIGH);
column = 1;
stmt.setInt(column++, newVersion);
@@ -1008,7 +1008,7 @@ public class AuditListTableMappingWithRanges extends AbstractBasicListTableMappi
private Object getValue(IDBStoreAccessor accessor, CDOID id, int index)
{
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlGetValue, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlGetValue, ReuseProbability.HIGH);
Object result = null;
try
@@ -1075,7 +1075,7 @@ public class AuditListTableMappingWithRanges extends AbstractBasicListTableMappi
}
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sql, ReuseProbability.MEDIUM);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sql, ReuseProbability.MEDIUM);
ResultSet resultSet = null;
try
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingFeatureMapTableMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingFeatureMapTableMapping.java
index a36531dd31..6209e44e09 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingFeatureMapTableMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingFeatureMapTableMapping.java
@@ -22,6 +22,7 @@ import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBType;
import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.IDBPreparedStatement;
import org.eclipse.net4j.db.IDBPreparedStatement.ReuseProbability;
import org.eclipse.emf.ecore.EClass;
@@ -87,7 +88,7 @@ public class BranchingFeatureMapTableMapping extends AbstractFeatureMapTableMapp
@Override
public void rawDeleted(IDBStoreAccessor accessor, CDOID id, CDOBranch branch, int version)
{
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlClear, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlClear, ReuseProbability.HIGH);
try
{
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingFeatureMapTableMappingWithRanges.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingFeatureMapTableMappingWithRanges.java
index f4d6bee411..3d2aa629c4 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingFeatureMapTableMappingWithRanges.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingFeatureMapTableMappingWithRanges.java
@@ -48,6 +48,7 @@ import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBType;
import org.eclipse.net4j.db.DBUtil;
import org.eclipse.net4j.db.IDBDatabase;
+import org.eclipse.net4j.db.IDBPreparedStatement;
import org.eclipse.net4j.db.IDBPreparedStatement.ReuseProbability;
import org.eclipse.net4j.db.ddl.IDBIndex.Type;
import org.eclipse.net4j.db.ddl.IDBTable;
@@ -59,7 +60,6 @@ import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.util.FeatureMap;
-import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
@@ -418,7 +418,7 @@ public class BranchingFeatureMapTableMappingWithRanges extends AbstractBasicList
String sql = sqlSelectChunksPrefix + sqlOrderByIndex;
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sql, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sql, ReuseProbability.HIGH);
ResultSet resultSet = null;
IStoreChunkReader baseReader = null;
@@ -536,7 +536,7 @@ public class BranchingFeatureMapTableMappingWithRanges extends AbstractBasicList
String sql = builder.toString();
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = chunkReader.getAccessor().getDBTransaction().prepareStatement(sql, ReuseProbability.LOW);
+ IDBPreparedStatement stmt = chunkReader.getAccessor().getDBConnection().prepareStatement(sql, ReuseProbability.LOW);
ResultSet resultSet = null;
IStoreChunkReader baseReader = null;
@@ -802,7 +802,7 @@ public class BranchingFeatureMapTableMappingWithRanges extends AbstractBasicList
}
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlClearList, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlClearList, ReuseProbability.HIGH);
try
{
@@ -1052,7 +1052,7 @@ public class BranchingFeatureMapTableMappingWithRanges extends AbstractBasicList
int startIndex, int endIndex)
{
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlUpdateIndex, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlUpdateIndex, ReuseProbability.HIGH);
try
{
@@ -1135,7 +1135,7 @@ public class BranchingFeatureMapTableMappingWithRanges extends AbstractBasicList
int startIndex, int endIndex)
{
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlUpdateIndex, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlUpdateIndex, ReuseProbability.HIGH);
try
{
@@ -1224,7 +1224,7 @@ public class BranchingFeatureMapTableMappingWithRanges extends AbstractBasicList
String columnName = getColumnName(tag);
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlInsert, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlInsert, ReuseProbability.HIGH);
try
{
@@ -1282,7 +1282,7 @@ public class BranchingFeatureMapTableMappingWithRanges extends AbstractBasicList
String columnName = getColumnName(tag);
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlInsert, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlInsert, ReuseProbability.HIGH);
try
{
@@ -1332,7 +1332,7 @@ public class BranchingFeatureMapTableMappingWithRanges extends AbstractBasicList
}
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlDeleteEntry, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlDeleteEntry, ReuseProbability.HIGH);
try
{
@@ -1364,7 +1364,7 @@ public class BranchingFeatureMapTableMappingWithRanges extends AbstractBasicList
{
// no temporary entry found, so mark the entry as removed
DBUtil.close(stmt);
- stmt = accessor.getDBTransaction().prepareStatement(sqlRemoveEntry, ReuseProbability.HIGH);
+ stmt = accessor.getDBConnection().prepareStatement(sqlRemoveEntry, ReuseProbability.HIGH);
column = 1;
stmt.setInt(column++, newVersion);
@@ -1412,7 +1412,7 @@ public class BranchingFeatureMapTableMappingWithRanges extends AbstractBasicList
private FeatureMap.Entry getValue(IDBStoreAccessor accessor, CDOID id, int branchId, int index, boolean getFromBase)
{
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlGetValue, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlGetValue, ReuseProbability.HIGH);
FeatureMap.Entry result = null;
try
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMapping.java
index c51a1719db..79ed6f8572 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMapping.java
@@ -22,6 +22,7 @@ import org.eclipse.emf.cdo.server.db.mapping.IMappingStrategy;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBType;
import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.IDBPreparedStatement;
import org.eclipse.net4j.db.IDBPreparedStatement.ReuseProbability;
import org.eclipse.net4j.db.ddl.IDBTable;
@@ -92,7 +93,7 @@ public class BranchingListTableMapping extends AbstractListTableMapping
public void rawDeleted(IDBStoreAccessor accessor, CDOID id, CDOBranch branch, int version)
{
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlClear, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlClear, ReuseProbability.HIGH);
try
{
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMappingWithRanges.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMappingWithRanges.java
index 16b3a96d73..5baa748f4b 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMappingWithRanges.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMappingWithRanges.java
@@ -49,6 +49,7 @@ import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBType;
import org.eclipse.net4j.db.DBUtil;
import org.eclipse.net4j.db.IDBDatabase;
+import org.eclipse.net4j.db.IDBPreparedStatement;
import org.eclipse.net4j.db.IDBPreparedStatement.ReuseProbability;
import org.eclipse.net4j.db.ddl.IDBIndex.Type;
import org.eclipse.net4j.db.ddl.IDBTable;
@@ -61,7 +62,6 @@ import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.EStructuralFeature;
-import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
@@ -323,7 +323,7 @@ public class BranchingListTableMappingWithRanges extends AbstractBasicListTableM
String sql = sqlSelectChunksPrefix + sqlOrderByIndex;
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sql, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sql, ReuseProbability.HIGH);
ResultSet resultSet = null;
ArrayList<Pair<Integer, Integer>> toReadFromBase = null; // list of chunks to be read from base revision
@@ -451,7 +451,7 @@ public class BranchingListTableMappingWithRanges extends AbstractBasicListTableM
String sql = builder.toString();
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = chunkReader.getAccessor().getDBTransaction().prepareStatement(sql, ReuseProbability.LOW);
+ IDBPreparedStatement stmt = chunkReader.getAccessor().getDBConnection().prepareStatement(sql, ReuseProbability.LOW);
ResultSet resultSet = null;
IStoreChunkReader baseReader = null;
@@ -659,7 +659,7 @@ public class BranchingListTableMappingWithRanges extends AbstractBasicListTableM
}
}
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlClearList, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlClearList, ReuseProbability.HIGH);
try
{
@@ -947,7 +947,7 @@ public class BranchingListTableMappingWithRanges extends AbstractBasicListTableM
int startIndex, int endIndex)
{
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlUpdateIndex, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlUpdateIndex, ReuseProbability.HIGH);
try
{
@@ -1031,7 +1031,7 @@ public class BranchingListTableMappingWithRanges extends AbstractBasicListTableM
int startIndex, int endIndex)
{
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlUpdateIndex, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlUpdateIndex, ReuseProbability.HIGH);
try
{
@@ -1121,7 +1121,7 @@ public class BranchingListTableMappingWithRanges extends AbstractBasicListTableM
}
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlInsertEntry, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlInsertEntry, ReuseProbability.HIGH);
try
{
@@ -1161,7 +1161,7 @@ public class BranchingListTableMappingWithRanges extends AbstractBasicListTableM
}
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlInsertEntry, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlInsertEntry, ReuseProbability.HIGH);
try
{
@@ -1198,7 +1198,7 @@ public class BranchingListTableMappingWithRanges extends AbstractBasicListTableM
}
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlDeleteEntry, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlDeleteEntry, ReuseProbability.HIGH);
try
{
@@ -1230,7 +1230,7 @@ public class BranchingListTableMappingWithRanges extends AbstractBasicListTableM
{
// no temporary entry found, so mark the entry as removed
DBUtil.close(stmt);
- stmt = accessor.getDBTransaction().prepareStatement(sqlRemoveEntry, ReuseProbability.HIGH);
+ stmt = accessor.getDBConnection().prepareStatement(sqlRemoveEntry, ReuseProbability.HIGH);
column = 1;
stmt.setInt(column++, newVersion);
@@ -1295,7 +1295,7 @@ public class BranchingListTableMappingWithRanges extends AbstractBasicListTableM
private Object getValue(IDBStoreAccessor accessor, CDOID id, int branchId, int index, boolean getFromBase)
{
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlGetValue, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlGetValue, ReuseProbability.HIGH);
Object result = null;
try
@@ -1410,7 +1410,7 @@ public class BranchingListTableMappingWithRanges extends AbstractBasicListTableM
}
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sql, ReuseProbability.MEDIUM);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sql, ReuseProbability.MEDIUM);
ResultSet resultSet = null;
try
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditClassMapping.java
index 62c7fe829d..7bcc01cf5c 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditClassMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalAuditClassMapping.java
@@ -43,6 +43,7 @@ import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionDelta;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.IDBPreparedStatement;
import org.eclipse.net4j.db.IDBPreparedStatement.ReuseProbability;
import org.eclipse.net4j.db.ddl.IDBField;
import org.eclipse.net4j.util.ImplementationError;
@@ -53,7 +54,6 @@ import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EStructuralFeature;
-import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Map;
@@ -203,21 +203,21 @@ public class HorizontalAuditClassMapping extends AbstractHorizontalClassMapping
public boolean readRevision(IDBStoreAccessor accessor, InternalCDORevision revision, int listChunk)
{
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = null;
+ IDBPreparedStatement stmt = null;
try
{
long timeStamp = revision.getTimeStamp();
if (timeStamp != CDOBranchPoint.UNSPECIFIED_DATE)
{
- stmt = accessor.getDBTransaction().prepareStatement(sqlSelectAttributesByTime, ReuseProbability.MEDIUM);
+ stmt = accessor.getDBConnection().prepareStatement(sqlSelectAttributesByTime, ReuseProbability.MEDIUM);
idHandler.setCDOID(stmt, 1, revision.getID());
stmt.setLong(2, timeStamp);
stmt.setLong(3, timeStamp);
}
else
{
- stmt = accessor.getDBTransaction().prepareStatement(sqlSelectCurrentAttributes, ReuseProbability.HIGH);
+ stmt = accessor.getDBConnection().prepareStatement(sqlSelectCurrentAttributes, ReuseProbability.HIGH);
idHandler.setCDOID(stmt, 1, revision.getID());
}
@@ -245,7 +245,7 @@ public class HorizontalAuditClassMapping extends AbstractHorizontalClassMapping
public boolean readRevisionByVersion(IDBStoreAccessor accessor, InternalCDORevision revision, int listChunk)
{
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlSelectAttributesByVersion,
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlSelectAttributesByVersion,
ReuseProbability.HIGH);
try
@@ -274,7 +274,7 @@ public class HorizontalAuditClassMapping extends AbstractHorizontalClassMapping
}
}
- public PreparedStatement createResourceQueryStatement(IDBStoreAccessor accessor, CDOID folderId, String name,
+ public IDBPreparedStatement createResourceQueryStatement(IDBStoreAccessor accessor, CDOID folderId, String name,
boolean exactMatch, CDOBranchPoint branchPoint)
{
EStructuralFeature nameFeature = EresourcePackage.eINSTANCE.getCDOResourceNode_Name();
@@ -324,7 +324,8 @@ public class HorizontalAuditClassMapping extends AbstractHorizontalClassMapping
}
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(builder.toString(), ReuseProbability.MEDIUM);
+ IDBPreparedStatement stmt = accessor.getDBConnection()
+ .prepareStatement(builder.toString(), ReuseProbability.MEDIUM);
try
{
@@ -357,21 +358,21 @@ public class HorizontalAuditClassMapping extends AbstractHorizontalClassMapping
}
}
- public PreparedStatement createObjectIDStatement(IDBStoreAccessor accessor)
+ public IDBPreparedStatement createObjectIDStatement(IDBStoreAccessor accessor)
{
if (TRACER.isEnabled())
{
TRACER.format("Created ObjectID Statement : {0}", sqlSelectAllObjectIDs); //$NON-NLS-1$
}
- return accessor.getDBTransaction().prepareStatement(sqlSelectAllObjectIDs, ReuseProbability.HIGH);
+ return accessor.getDBConnection().prepareStatement(sqlSelectAllObjectIDs, ReuseProbability.HIGH);
}
@Override
protected final void writeValues(IDBStoreAccessor accessor, InternalCDORevision revision)
{
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlInsertAttributes, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlInsertAttributes, ReuseProbability.HIGH);
try
{
@@ -437,7 +438,7 @@ public class HorizontalAuditClassMapping extends AbstractHorizontalClassMapping
OMMonitor mon)
{
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlInsertAttributes, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlInsertAttributes, ReuseProbability.HIGH);
try
{
@@ -490,8 +491,8 @@ public class HorizontalAuditClassMapping extends AbstractHorizontalClassMapping
@Override
protected void rawDeleteAttributes(IDBStoreAccessor accessor, CDOID id, CDOBranch branch, int version, OMMonitor fork)
{
- PreparedStatement stmt = accessor.getDBTransaction()
- .prepareStatement(sqlRawDeleteAttributes, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlRawDeleteAttributes,
+ ReuseProbability.HIGH);
try
{
@@ -513,7 +514,7 @@ public class HorizontalAuditClassMapping extends AbstractHorizontalClassMapping
protected void reviseOldRevision(IDBStoreAccessor accessor, CDOID id, CDOBranch branch, long revised)
{
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlReviseAttributes, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlReviseAttributes, ReuseProbability.HIGH);
try
{
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingClassMapping.java
index 218d75ed6e..f6acacf023 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingClassMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingClassMapping.java
@@ -52,6 +52,7 @@ import org.eclipse.emf.cdo.spi.server.InternalRepository;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBType;
import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.IDBPreparedStatement;
import org.eclipse.net4j.db.IDBPreparedStatement.ReuseProbability;
import org.eclipse.net4j.db.ddl.IDBField;
import org.eclipse.net4j.db.ddl.IDBTable;
@@ -63,7 +64,6 @@ import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EStructuralFeature;
-import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashSet;
@@ -349,13 +349,13 @@ public class HorizontalBranchingClassMapping extends AbstractHorizontalClassMapp
int branchID = revision.getBranch().getID();
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = null;
+ IDBPreparedStatement stmt = null;
try
{
if (timeStamp != CDOBranchPoint.UNSPECIFIED_DATE)
{
- stmt = accessor.getDBTransaction().prepareStatement(sqlSelectAttributesByTime, ReuseProbability.MEDIUM);
+ stmt = accessor.getDBConnection().prepareStatement(sqlSelectAttributesByTime, ReuseProbability.MEDIUM);
idHandler.setCDOID(stmt, 1, revision.getID());
stmt.setInt(2, branchID);
stmt.setLong(3, timeStamp);
@@ -363,7 +363,7 @@ public class HorizontalBranchingClassMapping extends AbstractHorizontalClassMapp
}
else
{
- stmt = accessor.getDBTransaction().prepareStatement(sqlSelectCurrentAttributes, ReuseProbability.HIGH);
+ stmt = accessor.getDBConnection().prepareStatement(sqlSelectCurrentAttributes, ReuseProbability.HIGH);
idHandler.setCDOID(stmt, 1, revision.getID());
stmt.setInt(2, branchID);
}
@@ -392,7 +392,7 @@ public class HorizontalBranchingClassMapping extends AbstractHorizontalClassMapp
public boolean readRevisionByVersion(IDBStoreAccessor accessor, InternalCDORevision revision, int listChunk)
{
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlSelectAttributesByVersion,
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlSelectAttributesByVersion,
ReuseProbability.HIGH);
boolean success;
@@ -423,7 +423,7 @@ public class HorizontalBranchingClassMapping extends AbstractHorizontalClassMapp
return success;
}
- public PreparedStatement createResourceQueryStatement(IDBStoreAccessor accessor, CDOID folderId, String name,
+ public IDBPreparedStatement createResourceQueryStatement(IDBStoreAccessor accessor, CDOID folderId, String name,
boolean exactMatch, CDOBranchPoint branchPoint)
{
EStructuralFeature nameFeature = EresourcePackage.eINSTANCE.getCDOResourceNode_Name();
@@ -477,7 +477,8 @@ public class HorizontalBranchingClassMapping extends AbstractHorizontalClassMapp
}
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(builder.toString(), ReuseProbability.MEDIUM);
+ IDBPreparedStatement stmt = accessor.getDBConnection()
+ .prepareStatement(builder.toString(), ReuseProbability.MEDIUM);
try
{
@@ -511,21 +512,21 @@ public class HorizontalBranchingClassMapping extends AbstractHorizontalClassMapp
}
}
- public PreparedStatement createObjectIDStatement(IDBStoreAccessor accessor)
+ public IDBPreparedStatement createObjectIDStatement(IDBStoreAccessor accessor)
{
if (TRACER.isEnabled())
{
TRACER.format("Created ObjectID Statement : {0}", sqlSelectAllObjectIDs); //$NON-NLS-1$
}
- return accessor.getDBTransaction().prepareStatement(sqlSelectAllObjectIDs, ReuseProbability.HIGH);
+ return accessor.getDBConnection().prepareStatement(sqlSelectAllObjectIDs, ReuseProbability.HIGH);
}
@Override
protected final void writeValues(IDBStoreAccessor accessor, InternalCDORevision revision)
{
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlInsertAttributes, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlInsertAttributes, ReuseProbability.HIGH);
try
{
@@ -591,7 +592,7 @@ public class HorizontalBranchingClassMapping extends AbstractHorizontalClassMapp
OMMonitor mon)
{
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlInsertAttributes, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlInsertAttributes, ReuseProbability.HIGH);
try
{
@@ -646,8 +647,8 @@ public class HorizontalBranchingClassMapping extends AbstractHorizontalClassMapp
protected void rawDeleteAttributes(IDBStoreAccessor accessor, CDOID id, CDOBranch branch, int version, OMMonitor fork)
{
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction()
- .prepareStatement(sqlRawDeleteAttributes, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlRawDeleteAttributes,
+ ReuseProbability.HIGH);
try
{
@@ -670,7 +671,7 @@ public class HorizontalBranchingClassMapping extends AbstractHorizontalClassMapp
protected void reviseOldRevision(IDBStoreAccessor accessor, CDOID id, CDOBranch branch, long revised)
{
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlReviseAttributes, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlReviseAttributes, ReuseProbability.HIGH);
try
{
@@ -838,7 +839,7 @@ public class HorizontalBranchingClassMapping extends AbstractHorizontalClassMapp
CDOBranchManager branchManager = repository.getBranchManager();
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(builder.toString(), ReuseProbability.LOW);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(builder.toString(), ReuseProbability.LOW);
ResultSet resultSet = null;
try
@@ -923,7 +924,7 @@ public class HorizontalBranchingClassMapping extends AbstractHorizontalClassMapp
}
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(builder.toString(), ReuseProbability.LOW);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(builder.toString(), ReuseProbability.LOW);
ResultSet resultSet = null;
Set<CDOID> result = new HashSet<CDOID>();
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategy.java
index de8ef13795..9a80699c5a 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategy.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategy.java
@@ -18,6 +18,9 @@ import org.eclipse.emf.cdo.server.db.mapping.IListMapping;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.IDBConnection;
+import org.eclipse.net4j.db.IDBPreparedStatement;
+import org.eclipse.net4j.db.IDBPreparedStatement.ReuseProbability;
import org.eclipse.net4j.db.ddl.IDBTable;
import org.eclipse.net4j.util.om.monitor.OMMonitor;
import org.eclipse.net4j.util.om.monitor.OMMonitor.Async;
@@ -25,8 +28,6 @@ import org.eclipse.net4j.util.om.monitor.OMMonitor.Async;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EStructuralFeature;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -102,7 +103,7 @@ public class HorizontalBranchingMappingStrategy extends AbstractHorizontalMappin
}
@Override
- protected void rawImportReviseOldRevisions(Connection connection, IDBTable table, OMMonitor monitor)
+ protected void rawImportReviseOldRevisions(IDBConnection connection, IDBTable table, OMMonitor monitor)
{
String sqlUpdate = "UPDATE " + table + " SET " + ATTRIBUTES_REVISED + "=? WHERE " + ATTRIBUTES_ID + "=? AND "
+ ATTRIBUTES_BRANCH + "=? AND " + ATTRIBUTES_VERSION + "=?";
@@ -115,15 +116,13 @@ public class HorizontalBranchingMappingStrategy extends AbstractHorizontalMappin
+ ATTRIBUTES_REVISED + "=0";
IIDHandler idHandler = getStore().getIDHandler();
- PreparedStatement stmtUpdate = null;
- PreparedStatement stmtQuery = null;
+ IDBPreparedStatement stmtUpdate = connection.prepareStatement(sqlUpdate, ReuseProbability.MEDIUM);
+ IDBPreparedStatement stmtQuery = connection.prepareStatement(sqlQuery, ResultSet.TYPE_SCROLL_INSENSITIVE,
+ ResultSet.CONCUR_READ_ONLY, ReuseProbability.MEDIUM);
ResultSet resultSet = null;
try
{
- stmtUpdate = connection.prepareStatement(sqlUpdate);
- stmtQuery = connection.prepareStatement(sqlQuery, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
-
resultSet = stmtQuery.executeQuery();
int size = DBUtil.getRowCount(resultSet);
if (size == 0)
@@ -148,6 +147,7 @@ public class HorizontalBranchingMappingStrategy extends AbstractHorizontalMappin
}
Async async = monitor.forkAsync(size);
+
try
{
stmtUpdate.executeBatch();
@@ -171,25 +171,23 @@ public class HorizontalBranchingMappingStrategy extends AbstractHorizontalMappin
}
@Override
- protected void rawImportUnreviseNewRevisions(Connection connection, IDBTable table, long fromCommitTime,
+ protected void rawImportUnreviseNewRevisions(IDBConnection connection, IDBTable table, long fromCommitTime,
long toCommitTime, OMMonitor monitor)
{
- String sqlUpdate = "UPDATE " + table + " SET " + ATTRIBUTES_REVISED + "=0 WHERE " + ATTRIBUTES_BRANCH + ">=0 AND "
+ String sql = "UPDATE " + table + " SET " + ATTRIBUTES_REVISED + "=0 WHERE " + ATTRIBUTES_BRANCH + ">=0 AND "
+ ATTRIBUTES_CREATED + "<=" + toCommitTime + " AND " + ATTRIBUTES_REVISED + ">" + toCommitTime + " AND "
+ ATTRIBUTES_VERSION + ">0";
- PreparedStatement stmtUpdate = null;
+ IDBPreparedStatement stmt = connection.prepareStatement(sql, ReuseProbability.MEDIUM);
try
{
- stmtUpdate = connection.prepareStatement(sqlUpdate);
-
monitor.begin();
Async async = monitor.forkAsync();
try
{
- stmtUpdate.executeUpdate();
+ stmt.executeUpdate();
}
finally
{
@@ -202,7 +200,7 @@ public class HorizontalBranchingMappingStrategy extends AbstractHorizontalMappin
}
finally
{
- DBUtil.close(stmtUpdate);
+ DBUtil.close(stmt);
monitor.done();
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategyWithRanges.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategyWithRanges.java
index d32d36e355..f038ac431c 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategyWithRanges.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalBranchingMappingStrategyWithRanges.java
@@ -24,6 +24,9 @@ import org.eclipse.emf.cdo.server.db.mapping.IListMapping;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBUtil;
import org.eclipse.net4j.db.DBUtil.DeserializeRowHandler;
+import org.eclipse.net4j.db.IDBConnection;
+import org.eclipse.net4j.db.IDBPreparedStatement;
+import org.eclipse.net4j.db.IDBPreparedStatement.ReuseProbability;
import org.eclipse.net4j.db.ddl.IDBField;
import org.eclipse.net4j.db.ddl.IDBTable;
import org.eclipse.net4j.util.io.ExtendedDataInput;
@@ -35,7 +38,6 @@ import org.eclipse.emf.ecore.EStructuralFeature;
import java.io.IOException;
import java.sql.Connection;
-import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Collection;
@@ -82,8 +84,8 @@ public class HorizontalBranchingMappingStrategyWithRanges extends HorizontalBran
}
@Override
- protected void rawExportList(CDODataOutput out, Connection connection, IListMapping listMapping, IDBTable attrTable,
- String attrSuffix) throws IOException
+ protected void rawExportList(CDODataOutput out, IDBConnection connection, IListMapping listMapping,
+ IDBTable attrTable, String attrSuffix) throws IOException
{
super.rawExportList(out, connection, listMapping, attrTable, attrSuffix);
@@ -93,7 +95,7 @@ public class HorizontalBranchingMappingStrategyWithRanges extends HorizontalBran
}
}
- private void rawExportListPostProcess(CDODataOutput out, Connection connection, IDBTable attrTable,
+ private void rawExportListPostProcess(CDODataOutput out, IDBConnection connection, IDBTable attrTable,
String attrSuffix, IDBTable table) throws IOException
{
StringBuilder builder = new StringBuilder();
@@ -120,12 +122,12 @@ public class HorizontalBranchingMappingStrategyWithRanges extends HorizontalBran
String sql = DBUtil.trace(builder.toString());
IIDHandler idHandler = getStore().getIDHandler();
- PreparedStatement stmt = null;
+ IDBPreparedStatement stmt = connection.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE,
+ ResultSet.CONCUR_READ_ONLY, ReuseProbability.MEDIUM);
ResultSet resultSet = null;
try
{
- stmt = connection.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
resultSet = stmt.executeQuery();
// Write resultSet size for progress monitoring
@@ -163,7 +165,7 @@ public class HorizontalBranchingMappingStrategyWithRanges extends HorizontalBran
}
@Override
- protected void rawImportList(CDODataInput in, Connection connection, IListMapping listMapping, OMMonitor monitor)
+ protected void rawImportList(CDODataInput in, IDBConnection connection, IListMapping listMapping, OMMonitor monitor)
throws IOException
{
Collection<IDBTable> tables = listMapping.getDBTables();
@@ -190,7 +192,7 @@ public class HorizontalBranchingMappingStrategyWithRanges extends HorizontalBran
}
}
- private void rawImportListPostProcess(CDODataInput in, Connection connection, IDBTable table, OMMonitor monitor)
+ private void rawImportListPostProcess(CDODataInput in, IDBConnection connection, IDBTable table, OMMonitor monitor)
throws IOException
{
int size = in.readInt();
@@ -216,13 +218,12 @@ public class HorizontalBranchingMappingStrategyWithRanges extends HorizontalBran
String sql = DBUtil.trace(builder.toString());
IIDHandler idHandler = getStore().getIDHandler();
- PreparedStatement stmt = null;
+ IDBPreparedStatement stmt = connection.prepareStatement(sql, ReuseProbability.MEDIUM);
monitor.begin(1 + 2 * size);
try
{
- stmt = connection.prepareStatement(sql);
monitor.worked();
for (int row = 0; row < size; row++)
@@ -340,7 +341,7 @@ public class HorizontalBranchingMappingStrategyWithRanges extends HorizontalBran
{
private final IIDHandler idHandler = getStore().getIDHandler();
- private PreparedStatement stmt;
+ private IDBPreparedStatement stmt;
public void handleRow(ExtendedDataInput in, Connection connection, IDBField[] fields, Object[] values)
throws SQLException, IOException
@@ -360,7 +361,7 @@ public class HorizontalBranchingMappingStrategyWithRanges extends HorizontalBran
+ " AND " + LIST_IDX + "=?" //
+ " AND " + LIST_REVISION_VERSION_ADDED + "<?" //
+ " AND " + LIST_REVISION_VERSION_REMOVED + " IS NULL";
- stmt = connection.prepareStatement(sql);
+ stmt = ((IDBConnection)connection).prepareStatement(sql, ReuseProbability.MEDIUM);
}
Object sourceID = values[0];
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalNonAuditClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalNonAuditClassMapping.java
index 912c554389..473725b3d3 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalNonAuditClassMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/HorizontalNonAuditClassMapping.java
@@ -41,6 +41,7 @@ import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevisionDelta;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.IDBPreparedStatement;
import org.eclipse.net4j.db.IDBPreparedStatement.ReuseProbability;
import org.eclipse.net4j.db.ddl.IDBField;
import org.eclipse.net4j.util.ImplementationError;
@@ -52,7 +53,6 @@ import org.eclipse.net4j.util.om.trace.ContextTracer;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EStructuralFeature;
-import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
@@ -192,7 +192,7 @@ public class HorizontalNonAuditClassMapping extends AbstractHorizontalClassMappi
protected void writeValues(IDBStoreAccessor accessor, InternalCDORevision revision)
{
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlInsertAttributes, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlInsertAttributes, ReuseProbability.HIGH);
try
{
@@ -252,17 +252,17 @@ public class HorizontalNonAuditClassMapping extends AbstractHorizontalClassMappi
}
}
- public PreparedStatement createObjectIDStatement(IDBStoreAccessor accessor)
+ public IDBPreparedStatement createObjectIDStatement(IDBStoreAccessor accessor)
{
if (TRACER.isEnabled())
{
TRACER.format("Created ObjectID Statement : {0}", sqlSelectAllObjectIDs); //$NON-NLS-1$
}
- return accessor.getDBTransaction().prepareStatement(sqlSelectAllObjectIDs, ReuseProbability.HIGH);
+ return accessor.getDBConnection().prepareStatement(sqlSelectAllObjectIDs, ReuseProbability.HIGH);
}
- public PreparedStatement createResourceQueryStatement(IDBStoreAccessor accessor, CDOID folderId, String name,
+ public IDBPreparedStatement createResourceQueryStatement(IDBStoreAccessor accessor, CDOID folderId, String name,
boolean exactMatch, CDOBranchPoint branchPoint)
{
long timeStamp = branchPoint.getTimeStamp();
@@ -300,7 +300,8 @@ public class HorizontalNonAuditClassMapping extends AbstractHorizontalClassMappi
}
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(builder.toString(), ReuseProbability.MEDIUM);
+ IDBPreparedStatement stmt = accessor.getDBConnection()
+ .prepareStatement(builder.toString(), ReuseProbability.MEDIUM);
try
{
@@ -336,7 +337,7 @@ public class HorizontalNonAuditClassMapping extends AbstractHorizontalClassMappi
}
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlSelectCurrentAttributes,
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlSelectCurrentAttributes,
ReuseProbability.HIGH);
try
@@ -379,7 +380,7 @@ public class HorizontalNonAuditClassMapping extends AbstractHorizontalClassMappi
OMMonitor monitor)
{
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlDelete, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlDelete, ReuseProbability.HIGH);
try
{
@@ -564,7 +565,7 @@ public class HorizontalNonAuditClassMapping extends AbstractHorizontalClassMappi
private void updateAttributes()
{
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(buildUpdateStatement(),
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(buildUpdateStatement(),
ReuseProbability.MEDIUM);
try
@@ -631,7 +632,7 @@ public class HorizontalNonAuditClassMapping extends AbstractHorizontalClassMappi
return builder.toString();
}
- private int setUpdateAttributeValues(List<Pair<ITypeMapping, Object>> attributeChanges, PreparedStatement stmt,
+ private int setUpdateAttributeValues(List<Pair<ITypeMapping, Object>> attributeChanges, IDBPreparedStatement stmt,
int col) throws SQLException
{
for (Pair<ITypeMapping, Object> change : attributeChanges)
@@ -664,7 +665,7 @@ public class HorizontalNonAuditClassMapping extends AbstractHorizontalClassMappi
}
private int setUpdateListSizeChanges(List<Pair<EStructuralFeature, Integer>> attributeChanges,
- PreparedStatement stmt, int col) throws SQLException
+ IDBPreparedStatement stmt, int col) throws SQLException
{
for (Pair<EStructuralFeature, Integer> change : listSizeChanges)
{
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditFeatureMapTableMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditFeatureMapTableMapping.java
index 3c8d537503..2eb14aab85 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditFeatureMapTableMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditFeatureMapTableMapping.java
@@ -34,6 +34,7 @@ import org.eclipse.emf.cdo.server.db.mapping.ITypeMapping;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.IDBPreparedStatement;
import org.eclipse.net4j.db.IDBPreparedStatement.ReuseProbability;
import org.eclipse.net4j.util.ImplementationError;
@@ -215,7 +216,7 @@ public class NonAuditFeatureMapTableMapping extends AbstractFeatureMapTableMappi
public void clearList(IDBStoreAccessor accessor, CDOID id)
{
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlClear, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlClear, ReuseProbability.HIGH);
try
{
@@ -265,7 +266,7 @@ public class NonAuditFeatureMapTableMapping extends AbstractFeatureMapTableMappi
String columnName = getColumnName(tag);
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlInsert, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlInsert, ReuseProbability.HIGH);
try
{
@@ -339,7 +340,7 @@ public class NonAuditFeatureMapTableMapping extends AbstractFeatureMapTableMappi
private void updateOneIndex(IDBStoreAccessor accessor, CDOID id, int oldIndex, int newIndex)
{
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlUpdateIndex, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlUpdateIndex, ReuseProbability.HIGH);
try
{
@@ -381,7 +382,7 @@ public class NonAuditFeatureMapTableMapping extends AbstractFeatureMapTableMappi
private void move1down(IDBStoreAccessor accessor, CDOID id, int index, int upperIndex)
{
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(
upperIndex == UNBOUNDED_MOVE ? sqlMoveDown : sqlMoveDownWithLimit, ReuseProbability.HIGH);
try
@@ -412,7 +413,7 @@ public class NonAuditFeatureMapTableMapping extends AbstractFeatureMapTableMappi
private void move1up(IDBStoreAccessor accessor, CDOID id, int index, int upperIndex)
{
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(
upperIndex == UNBOUNDED_MOVE ? sqlMoveUp : sqlMoveUpWithLimit, ReuseProbability.HIGH);
try
@@ -439,7 +440,7 @@ public class NonAuditFeatureMapTableMapping extends AbstractFeatureMapTableMappi
private void deleteItem(IDBStoreAccessor accessor, CDOID id, int index)
{
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlDeleteItem, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlDeleteItem, ReuseProbability.HIGH);
try
{
@@ -478,7 +479,7 @@ public class NonAuditFeatureMapTableMapping extends AbstractFeatureMapTableMappi
String columnName = getColumnName(tag);
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlUpdateValue, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlUpdateValue, ReuseProbability.HIGH);
try
{
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditListTableMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditListTableMapping.java
index 5f85862c16..fec07870f8 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditListTableMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/NonAuditListTableMapping.java
@@ -35,6 +35,7 @@ import org.eclipse.emf.cdo.spi.common.revision.InternalCDORevision;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.IDBPreparedStatement;
import org.eclipse.net4j.db.IDBPreparedStatement.ReuseProbability;
import org.eclipse.net4j.db.ddl.IDBTable;
import org.eclipse.net4j.util.om.trace.ContextTracer;
@@ -224,7 +225,7 @@ public class NonAuditListTableMapping extends AbstractListTableMapping implement
public void clearList(IDBStoreAccessor accessor, CDOID id)
{
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlClear, ReuseProbability.HIGH);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlClear, ReuseProbability.HIGH);
try
{
@@ -250,7 +251,7 @@ public class NonAuditListTableMapping extends AbstractListTableMapping implement
public int getCurrentIndexOffset(IDBStoreAccessor accessor, CDOID id)
{
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlReadCurrentIndexOffset,
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlReadCurrentIndexOffset,
ReuseProbability.HIGH);
ResultSet rset = null;
@@ -698,10 +699,10 @@ public class NonAuditListTableMapping extends AbstractListTableMapping implement
private void writeResultToDatabase(IDBStoreAccessor accessor, CDOID id)
{
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement deleteStmt = null;
- PreparedStatement moveStmt = null;
- PreparedStatement setValueStmt = null;
- PreparedStatement insertStmt = null;
+ IDBPreparedStatement deleteStmt = null;
+ IDBPreparedStatement moveStmt = null;
+ IDBPreparedStatement setValueStmt = null;
+ IDBPreparedStatement insertStmt = null;
int deleteCounter = 0;
int moveCounter = 0;
@@ -735,7 +736,7 @@ public class NonAuditListTableMapping extends AbstractListTableMapping implement
if (deleteStmt == null)
{
- deleteStmt = accessor.getDBTransaction().prepareStatement(sqlDeleteItem, ReuseProbability.HIGH);
+ deleteStmt = accessor.getDBConnection().prepareStatement(sqlDeleteItem, ReuseProbability.HIGH);
idHandler.setCDOID(deleteStmt, 1, id);
}
@@ -757,7 +758,7 @@ public class NonAuditListTableMapping extends AbstractListTableMapping implement
*/
if (moveStmt == null)
{
- moveStmt = accessor.getDBTransaction().prepareStatement(sqlUpdateIndex, ReuseProbability.HIGH);
+ moveStmt = accessor.getDBConnection().prepareStatement(sqlUpdateIndex, ReuseProbability.HIGH);
idHandler.setCDOID(moveStmt, 2, id);
}
@@ -825,7 +826,7 @@ public class NonAuditListTableMapping extends AbstractListTableMapping implement
*/
if (setValueStmt == null)
{
- setValueStmt = accessor.getDBTransaction().prepareStatement(sqlUpdateValue, ReuseProbability.HIGH);
+ setValueStmt = accessor.getDBConnection().prepareStatement(sqlUpdateValue, ReuseProbability.HIGH);
idHandler.setCDOID(setValueStmt, 2, id);
}
@@ -847,7 +848,7 @@ public class NonAuditListTableMapping extends AbstractListTableMapping implement
*/
if (insertStmt == null)
{
- insertStmt = accessor.getDBTransaction().prepareStatement(sqlInsertValue, ReuseProbability.HIGH);
+ insertStmt = accessor.getDBConnection().prepareStatement(sqlInsertValue, ReuseProbability.HIGH);
idHandler.setCDOID(insertStmt, 1, id);
}
@@ -993,7 +994,7 @@ public class NonAuditListTableMapping extends AbstractListTableMapping implement
*/
ListIterator<ShiftOperation> operationIt = shiftOperations.listIterator();
- PreparedStatement shiftDownStmt = null;
+ IDBPreparedStatement shiftDownStmt = null;
int operationCounter = 0;
try
@@ -1005,7 +1006,7 @@ public class NonAuditListTableMapping extends AbstractListTableMapping implement
{
if (shiftDownStmt == null)
{
- shiftDownStmt = accessor.getDBTransaction().prepareStatement(sqlShiftDownIndex, ReuseProbability.HIGH);
+ shiftDownStmt = accessor.getDBConnection().prepareStatement(sqlShiftDownIndex, ReuseProbability.HIGH);
idHandler.setCDOID(shiftDownStmt, 2, id);
}
@@ -1034,7 +1035,7 @@ public class NonAuditListTableMapping extends AbstractListTableMapping implement
close(shiftDownStmt);
}
- PreparedStatement shiftUpStmt = null;
+ IDBPreparedStatement shiftUpStmt = null;
operationCounter = 0;
try
@@ -1045,7 +1046,7 @@ public class NonAuditListTableMapping extends AbstractListTableMapping implement
ShiftOperation operation = operationIt.previous();
if (shiftUpStmt == null)
{
- shiftUpStmt = accessor.getDBTransaction().prepareStatement(sqlShiftUpIndex, ReuseProbability.HIGH);
+ shiftUpStmt = accessor.getDBConnection().prepareStatement(sqlShiftUpIndex, ReuseProbability.HIGH);
idHandler.setCDOID(shiftUpStmt, 2, id);
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/ObjectTypeTable.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/ObjectTypeTable.java
index 6b75d7cf5c..85e7fc26e1 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/ObjectTypeTable.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/ObjectTypeTable.java
@@ -27,6 +27,7 @@ import org.eclipse.net4j.db.DBType;
import org.eclipse.net4j.db.DBUtil;
import org.eclipse.net4j.db.IDBDatabase;
import org.eclipse.net4j.db.IDBDatabase.RunnableWithSchema;
+import org.eclipse.net4j.db.IDBPreparedStatement;
import org.eclipse.net4j.db.IDBPreparedStatement.ReuseProbability;
import org.eclipse.net4j.db.ddl.IDBIndex;
import org.eclipse.net4j.db.ddl.IDBSchema;
@@ -37,7 +38,6 @@ import org.eclipse.emf.ecore.EClass;
import java.io.IOException;
import java.sql.Connection;
-import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
@@ -63,7 +63,7 @@ public class ObjectTypeTable extends AbstractObjectTypeMapper implements IMappin
public final CDOClassifierRef getObjectType(IDBStoreAccessor accessor, CDOID id)
{
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlSelect, ReuseProbability.MAX);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlSelect, ReuseProbability.MAX);
try
{
@@ -104,7 +104,7 @@ public class ObjectTypeTable extends AbstractObjectTypeMapper implements IMappin
{
IDBStore store = getMappingStrategy().getStore();
IIDHandler idHandler = store.getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlInsert, ReuseProbability.MAX);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlInsert, ReuseProbability.MAX);
try
{
@@ -141,7 +141,7 @@ public class ObjectTypeTable extends AbstractObjectTypeMapper implements IMappin
public final void removeObjectType(IDBStoreAccessor accessor, CDOID id)
{
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlDelete, ReuseProbability.MAX);
+ IDBPreparedStatement stmt = accessor.getDBConnection().prepareStatement(sqlDelete, ReuseProbability.MAX);
try
{
diff --git a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/verifier/DBStoreVerifier.java b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/verifier/DBStoreVerifier.java
index c788743f76..6c3bd450c6 100644
--- a/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/verifier/DBStoreVerifier.java
+++ b/plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/verifier/DBStoreVerifier.java
@@ -82,7 +82,7 @@ public abstract class DBStoreVerifier
try
{
- return accessor.getDBTransaction().getConnection().createStatement();
+ return accessor.getDBConnection().createStatement();
}
catch (SQLException ex)
{
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java
index 2b40e97468..32f3789876 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java
@@ -15,7 +15,6 @@ import org.eclipse.net4j.db.ddl.IDBNamedElement;
import org.eclipse.net4j.db.ddl.IDBSchema;
import org.eclipse.net4j.db.ddl.IDBTable;
import org.eclipse.net4j.internal.db.DBDatabase;
-import org.eclipse.net4j.internal.db.DBTransaction;
import org.eclipse.net4j.internal.db.DataSourceConnectionProvider;
import org.eclipse.net4j.internal.db.bundle.OM;
import org.eclipse.net4j.internal.db.ddl.DBNamedElement;
@@ -239,14 +238,6 @@ public final class DBUtil
return IDBAdapter.REGISTRY.get(adapterName);
}
- /**
- * @since 4.2
- */
- public static Connection getSQLConnection(IDBTransaction dbConnection)
- {
- return ((DBTransaction)dbConnection).getConnection();
- }
-
public static Exception close(Connection connection)
{
if (connection != null)
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBTransaction.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBConnection.java
index 9a6f782469..d5d3f2a07e 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBTransaction.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBConnection.java
@@ -11,23 +11,21 @@
package org.eclipse.net4j.db;
import org.eclipse.net4j.db.IDBPreparedStatement.ReuseProbability;
-import org.eclipse.net4j.util.collection.Closeable;
import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
/**
* @since 4.2
* @author Eike Stepper
- * @see DBUtil#getSQLConnection(IDBTransaction)
* @noimplement This interface is not intended to be implemented by clients.
* @noextend This interface is not intended to be extended by clients.
*/
-public interface IDBTransaction extends Closeable
+public interface IDBConnection extends Connection
{
public IDBDatabase getDatabase();
- public Connection getConnection();
-
public IDBSchemaTransaction openSchemaTransaction();
public IDBPreparedStatement prepareStatement(String sql, ReuseProbability reuseProbability);
@@ -35,7 +33,28 @@ public interface IDBTransaction extends Closeable
public IDBPreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency,
ReuseProbability reuseProbability);
- public void commit();
-
- public void rollback();
+ /**
+ * @deprecated Not supported.
+ */
+ @Deprecated
+ public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException;
+
+ /**
+ * @deprecated Not supported.
+ */
+ @Deprecated
+ public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency,
+ int resultSetHoldability) throws SQLException;
+
+ /**
+ * @deprecated Not supported.
+ */
+ @Deprecated
+ public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException;
+
+ /**
+ * @deprecated Not supported.
+ */
+ @Deprecated
+ public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException;
}
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBDatabase.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBDatabase.java
index 3b0448d1cc..6fdc46d5df 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBDatabase.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBDatabase.java
@@ -22,7 +22,7 @@ import org.eclipse.net4j.util.event.IEvent;
* @noextend This interface is not intended to be extended by clients.
* @since 4.2
*/
-public interface IDBDatabase extends IContainer<IDBTransaction>, Closeable
+public interface IDBDatabase extends IContainer<IDBConnection>, IDBConnectionProvider, Closeable
{
public static final int DEFAULT_STATEMENT_CACHE_CAPACITY = 200;
@@ -30,17 +30,15 @@ public interface IDBDatabase extends IContainer<IDBTransaction>, Closeable
public IDBSchema getSchema();
- public IDBConnectionProvider getConnectionProvider();
-
public IDBSchemaTransaction openSchemaTransaction();
public IDBSchemaTransaction getSchemaTransaction();
public void updateSchema(RunnableWithSchema runnable);
- public IDBTransaction openTransaction();
+ public IDBConnection getConnection();
- public IDBTransaction[] getTransactions();
+ public IDBConnection[] getConnections();
public int getStatementCacheCapacity();
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBPreparedStatement.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBPreparedStatement.java
index 9b8b1a7512..805f259ffe 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBPreparedStatement.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBPreparedStatement.java
@@ -22,7 +22,7 @@ import java.sql.SQLException;
*/
public interface IDBPreparedStatement extends Comparable<IDBPreparedStatement>, PreparedStatement
{
- public IDBTransaction getTransaction();
+ public IDBConnection getTransaction();
public String getSQL();
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBSchemaTransaction.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBSchemaTransaction.java
index d782936db3..9f05dad007 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBSchemaTransaction.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBSchemaTransaction.java
@@ -31,7 +31,7 @@ public interface IDBSchemaTransaction extends Closeable
public IDBDatabase getDatabase();
- public IDBTransaction getTransaction();
+ public IDBConnection getConnection();
public IDBSchema getWorkingCopy();
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBConnection.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBConnection.java
new file mode 100644
index 0000000000..019710ff3f
--- /dev/null
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBConnection.java
@@ -0,0 +1,415 @@
+/*
+ * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.internal.db;
+
+import org.eclipse.net4j.db.DBException;
+import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.IDBConnection;
+import org.eclipse.net4j.db.IDBPreparedStatement;
+import org.eclipse.net4j.db.IDBPreparedStatement.ReuseProbability;
+import org.eclipse.net4j.db.IDBSchemaTransaction;
+import org.eclipse.net4j.util.CheckUtil;
+
+import java.sql.Array;
+import java.sql.Blob;
+import java.sql.CallableStatement;
+import java.sql.Clob;
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.NClob;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLClientInfoException;
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+import java.sql.SQLXML;
+import java.sql.Savepoint;
+import java.sql.Statement;
+import java.sql.Struct;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.NavigableMap;
+import java.util.Properties;
+import java.util.Set;
+import java.util.TreeMap;
+
+/**
+ * @author Eike Stepper
+ */
+public final class DBConnection implements IDBConnection
+{
+ private final NavigableMap<String, DBPreparedStatement> cache = new TreeMap<String, DBPreparedStatement>();
+
+ private final Set<DBPreparedStatement> checkOuts = new HashSet<DBPreparedStatement>();
+
+ private final DBDatabase database;
+
+ private final Connection delegate;
+
+ private int lastTouch;
+
+ private boolean closed;
+
+ public DBConnection(DBDatabase database, Connection delegate)
+ {
+ this.database = database;
+ this.delegate = delegate;
+
+ try
+ {
+ delegate.setAutoCommit(false);
+ }
+ catch (SQLException ex)
+ {
+ throw new DBException(ex, "SET AUTO COMMIT = false");
+ }
+ }
+
+ public DBDatabase getDatabase()
+ {
+ return database;
+ }
+
+ public void close()
+ {
+ DBUtil.close(delegate);
+ closed = true;
+ database.closeConnection(this);
+ }
+
+ public boolean isClosed()
+ {
+ return closed;
+ }
+
+ public IDBSchemaTransaction openSchemaTransaction()
+ {
+ DBSchemaTransaction schemaTransaction = database.openSchemaTransaction();
+ schemaTransaction.setConnection(this);
+ return schemaTransaction;
+ }
+
+ public IDBPreparedStatement prepareStatement(String sql, ReuseProbability reuseProbability)
+ {
+ return prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, reuseProbability);
+ }
+
+ public IDBPreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency,
+ ReuseProbability reuseProbability)
+ {
+ database.beginSchemaAccess(false);
+
+ DBPreparedStatement preparedStatement = cache.remove(sql);
+ if (preparedStatement == null)
+ {
+ try
+ {
+ PreparedStatement delegate = this.delegate.prepareStatement(sql, resultSetType, resultSetConcurrency);
+ preparedStatement = new DBPreparedStatement(this, sql, reuseProbability, delegate);
+ }
+ catch (SQLException ex)
+ {
+ throw new DBException(ex);
+ }
+ }
+
+ checkOuts.add(preparedStatement);
+ return preparedStatement;
+ }
+
+ public PreparedStatement prepareStatement(String sql) throws SQLException
+ {
+ return prepareStatement(sql, ReuseProbability.LOW);
+ }
+
+ public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency)
+ throws SQLException
+ {
+ return prepareStatement(sql, resultSetType, resultSetConcurrency, ReuseProbability.LOW);
+ }
+
+ public void releasePreparedStatement(DBPreparedStatement preparedStatement)
+ {
+ try
+ {
+ if (preparedStatement == null)
+ {
+ // Bug 276926: Silently accept preparedStatement == null and do nothing.
+ return;
+ }
+
+ checkOuts.remove(preparedStatement);
+ preparedStatement.setTouch(++lastTouch);
+
+ String sql = preparedStatement.getSQL();
+ if (cache.put(sql, preparedStatement) != null)
+ {
+ throw new IllegalStateException(sql + " already in cache"); //$NON-NLS-1$
+ }
+
+ if (cache.size() > database.getStatementCacheCapacity())
+ {
+ DBPreparedStatement old = cache.remove(cache.firstKey());
+ DBUtil.close(old.getDelegate());
+ }
+ }
+ finally
+ {
+ database.endSchemaAccess();
+ }
+ }
+
+ public void invalidateStatementCache()
+ {
+ CheckUtil.checkState(checkOuts.isEmpty(), "Statements are checked out: " + checkOuts);
+
+ // Close all statements in the cache, then clear the cache.
+ for (DBPreparedStatement preparedStatement : cache.values())
+ {
+ PreparedStatement delegate = preparedStatement.getDelegate();
+ DBUtil.close(delegate);
+ }
+
+ cache.clear();
+ }
+
+ public <T> T unwrap(Class<T> iface) throws SQLException
+ {
+ return delegate.unwrap(iface);
+ }
+
+ public boolean isWrapperFor(Class<?> iface) throws SQLException
+ {
+ return delegate.isWrapperFor(iface);
+ }
+
+ public Statement createStatement() throws SQLException
+ {
+ return delegate.createStatement();
+ }
+
+ public CallableStatement prepareCall(String sql) throws SQLException
+ {
+ return delegate.prepareCall(sql);
+ }
+
+ public String nativeSQL(String sql) throws SQLException
+ {
+ return delegate.nativeSQL(sql);
+ }
+
+ public void setAutoCommit(boolean autoCommit) throws SQLException
+ {
+ delegate.setAutoCommit(autoCommit);
+ }
+
+ public boolean getAutoCommit() throws SQLException
+ {
+ return delegate.getAutoCommit();
+ }
+
+ public void commit() throws SQLException
+ {
+ delegate.commit();
+ }
+
+ public void rollback() throws SQLException
+ {
+ delegate.rollback();
+ }
+
+ public DatabaseMetaData getMetaData() throws SQLException
+ {
+ return delegate.getMetaData();
+ }
+
+ public void setReadOnly(boolean readOnly) throws SQLException
+ {
+ delegate.setReadOnly(readOnly);
+ }
+
+ public boolean isReadOnly() throws SQLException
+ {
+ return delegate.isReadOnly();
+ }
+
+ public void setCatalog(String catalog) throws SQLException
+ {
+ delegate.setCatalog(catalog);
+ }
+
+ public String getCatalog() throws SQLException
+ {
+ return delegate.getCatalog();
+ }
+
+ public void setTransactionIsolation(int level) throws SQLException
+ {
+ delegate.setTransactionIsolation(level);
+ }
+
+ public int getTransactionIsolation() throws SQLException
+ {
+ return delegate.getTransactionIsolation();
+ }
+
+ public SQLWarning getWarnings() throws SQLException
+ {
+ return delegate.getWarnings();
+ }
+
+ public void clearWarnings() throws SQLException
+ {
+ delegate.clearWarnings();
+ }
+
+ public Statement createStatement(int resultSetType, int resultSetConcurrency) throws SQLException
+ {
+ return delegate.createStatement(resultSetType, resultSetConcurrency);
+ }
+
+ public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException
+ {
+ return delegate.prepareCall(sql, resultSetType, resultSetConcurrency);
+ }
+
+ public Map<String, Class<?>> getTypeMap() throws SQLException
+ {
+ return delegate.getTypeMap();
+ }
+
+ public void setTypeMap(Map<String, Class<?>> map) throws SQLException
+ {
+ delegate.setTypeMap(map);
+ }
+
+ public void setHoldability(int holdability) throws SQLException
+ {
+ delegate.setHoldability(holdability);
+ }
+
+ public int getHoldability() throws SQLException
+ {
+ return delegate.getHoldability();
+ }
+
+ public Savepoint setSavepoint() throws SQLException
+ {
+ return delegate.setSavepoint();
+ }
+
+ public Savepoint setSavepoint(String name) throws SQLException
+ {
+ return delegate.setSavepoint(name);
+ }
+
+ public void rollback(Savepoint savepoint) throws SQLException
+ {
+ delegate.rollback(savepoint);
+ }
+
+ public void releaseSavepoint(Savepoint savepoint) throws SQLException
+ {
+ delegate.releaseSavepoint(savepoint);
+ }
+
+ public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability)
+ throws SQLException
+ {
+ return delegate.createStatement(resultSetType, resultSetConcurrency, resultSetHoldability);
+ }
+
+ public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability)
+ throws SQLException
+ {
+ return delegate.prepareCall(sql, resultSetType, resultSetConcurrency, resultSetHoldability);
+ }
+
+ public Clob createClob() throws SQLException
+ {
+ return delegate.createClob();
+ }
+
+ public Blob createBlob() throws SQLException
+ {
+ return delegate.createBlob();
+ }
+
+ public NClob createNClob() throws SQLException
+ {
+ return delegate.createNClob();
+ }
+
+ public SQLXML createSQLXML() throws SQLException
+ {
+ return delegate.createSQLXML();
+ }
+
+ public boolean isValid(int timeout) throws SQLException
+ {
+ return delegate.isValid(timeout);
+ }
+
+ public void setClientInfo(String name, String value) throws SQLClientInfoException
+ {
+ delegate.setClientInfo(name, value);
+ }
+
+ public void setClientInfo(Properties properties) throws SQLClientInfoException
+ {
+ delegate.setClientInfo(properties);
+ }
+
+ public String getClientInfo(String name) throws SQLException
+ {
+ return delegate.getClientInfo(name);
+ }
+
+ public Properties getClientInfo() throws SQLException
+ {
+ return delegate.getClientInfo();
+ }
+
+ public Array createArrayOf(String typeName, Object[] elements) throws SQLException
+ {
+ return delegate.createArrayOf(typeName, elements);
+ }
+
+ public Struct createStruct(String typeName, Object[] attributes) throws SQLException
+ {
+ return delegate.createStruct(typeName, attributes);
+ }
+
+ @Deprecated
+ public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency,
+ int resultSetHoldability) throws SQLException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Deprecated
+ public PreparedStatement prepareStatement(String sql, int autoGeneratedKeys) throws SQLException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Deprecated
+ public PreparedStatement prepareStatement(String sql, int[] columnIndexes) throws SQLException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ @Deprecated
+ public PreparedStatement prepareStatement(String sql, String[] columnNames) throws SQLException
+ {
+ throw new UnsupportedOperationException();
+ }
+}
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBDatabase.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBDatabase.java
index 0d15706d0d..c7566e6a62 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBDatabase.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBDatabase.java
@@ -10,11 +10,12 @@
*/
package org.eclipse.net4j.internal.db;
+import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBUtil;
import org.eclipse.net4j.db.DBUtil.RunnableWithConnection;
+import org.eclipse.net4j.db.IDBConnection;
import org.eclipse.net4j.db.IDBConnectionProvider;
import org.eclipse.net4j.db.IDBDatabase;
-import org.eclipse.net4j.db.IDBTransaction;
import org.eclipse.net4j.db.ddl.IDBSchema;
import org.eclipse.net4j.db.ddl.delta.IDBSchemaDelta;
import org.eclipse.net4j.internal.db.ddl.delta.DBSchemaDelta;
@@ -31,7 +32,7 @@ import java.util.LinkedList;
/**
* @author Eike Stepper
*/
-public final class DBDatabase extends SetContainer<IDBTransaction> implements IDBDatabase
+public final class DBDatabase extends SetContainer<IDBConnection> implements IDBDatabase
{
private DBAdapter adapter;
@@ -47,7 +48,7 @@ public final class DBDatabase extends SetContainer<IDBTransaction> implements ID
public DBDatabase(final DBAdapter adapter, IDBConnectionProvider connectionProvider, final String schemaName)
{
- super(IDBTransaction.class);
+ super(IDBConnection.class);
this.adapter = adapter;
this.connectionProvider = connectionProvider;
@@ -68,11 +69,6 @@ public final class DBDatabase extends SetContainer<IDBTransaction> implements ID
return adapter;
}
- public IDBConnectionProvider getConnectionProvider()
- {
- return connectionProvider;
- }
-
public IDBSchema getSchema()
{
return schema;
@@ -91,9 +87,9 @@ public final class DBDatabase extends SetContainer<IDBTransaction> implements ID
{
beginSchemaAccess(true);
- for (IDBTransaction transaction : getTransactions())
+ for (IDBConnection transaction : getConnections())
{
- ((DBTransaction)transaction).invalidateStatementCache();
+ ((DBConnection)transaction).invalidateStatementCache();
}
fireEvent(new SchemaChangedEventImpl(delta));
@@ -126,19 +122,25 @@ public final class DBDatabase extends SetContainer<IDBTransaction> implements ID
}
}
- public DBTransaction openTransaction()
+ public DBConnection getConnection()
{
- DBTransaction transaction = new DBTransaction(this);
- addElement(transaction);
- return transaction;
+ Connection delegate = connectionProvider.getConnection();
+ if (delegate == null)
+ {
+ throw new DBException("No connection from connection provider: " + connectionProvider);
+ }
+
+ DBConnection connection = new DBConnection(this, delegate);
+ addElement(connection);
+ return connection;
}
- public void closeTransaction(DBTransaction transaction)
+ public void closeConnection(DBConnection connection)
{
- removeElement(transaction);
+ removeElement(connection);
}
- public IDBTransaction[] getTransactions()
+ public IDBConnection[] getConnections()
{
return getElements();
}
@@ -166,9 +168,9 @@ public final class DBDatabase extends SetContainer<IDBTransaction> implements ID
@Override
protected void doDeactivate() throws Exception
{
- for (IDBTransaction transaction : getTransactions())
+ for (IDBConnection connection : getConnections())
{
- transaction.close();
+ connection.close();
}
super.doDeactivate();
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBPreparedStatement.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBPreparedStatement.java
index fd5cb8b401..7078a38a3a 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBPreparedStatement.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBPreparedStatement.java
@@ -42,7 +42,7 @@ import java.util.Map;
*/
public final class DBPreparedStatement implements IDBPreparedStatement
{
- private final DBTransaction transaction;
+ private final DBConnection transaction;
private final String sql;
@@ -52,7 +52,7 @@ public final class DBPreparedStatement implements IDBPreparedStatement
private int touch;
- public DBPreparedStatement(DBTransaction transaction, String sql, ReuseProbability reuseProbability,
+ public DBPreparedStatement(DBConnection transaction, String sql, ReuseProbability reuseProbability,
PreparedStatement delegate)
{
this.transaction = transaction;
@@ -61,7 +61,7 @@ public final class DBPreparedStatement implements IDBPreparedStatement
this.delegate = delegate;
}
- public DBTransaction getTransaction()
+ public DBConnection getTransaction()
{
return transaction;
}
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBSchemaTransaction.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBSchemaTransaction.java
index 2e14a1c846..c923d68710 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBSchemaTransaction.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBSchemaTransaction.java
@@ -33,7 +33,7 @@ public final class DBSchemaTransaction implements IDBSchemaTransaction, Runnable
{
private DBDatabase database;
- private DBTransaction transaction;
+ private DBConnection connection;
private IDBSchema oldSchema;
@@ -53,14 +53,14 @@ public final class DBSchemaTransaction implements IDBSchemaTransaction, Runnable
return database;
}
- public DBTransaction getTransaction()
+ public DBConnection getConnection()
{
- return transaction;
+ return connection;
}
- public void setTransaction(DBTransaction getTransaction)
+ public void setConnection(DBConnection connection)
{
- transaction = getTransaction;
+ this.connection = connection;
}
public IDBSchema getWorkingCopy()
@@ -94,14 +94,13 @@ public final class DBSchemaTransaction implements IDBSchemaTransaction, Runnable
public DBSchemaDelta commit()
{
- if (transaction == null)
+ if (connection == null)
{
- return DBUtil.execute(database.getConnectionProvider(), this);
+ return DBUtil.execute(database, this);
}
try
{
- Connection connection = transaction.getConnection();
return run(connection);
}
catch (SQLException ex)
@@ -142,7 +141,7 @@ public final class DBSchemaTransaction implements IDBSchemaTransaction, Runnable
if (!isClosed())
{
database.closeSchemaTransaction(delta);
- transaction = null;
+ connection = null;
oldSchema = null;
workingCopy = null;
}
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBTransaction.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBTransaction.java
deleted file mode 100644
index c1ac7092e8..0000000000
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBTransaction.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * Copyright (c) 2004 - 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.net4j.internal.db;
-
-import org.eclipse.net4j.db.DBException;
-import org.eclipse.net4j.db.DBUtil;
-import org.eclipse.net4j.db.IDBConnectionProvider;
-import org.eclipse.net4j.db.IDBPreparedStatement;
-import org.eclipse.net4j.db.IDBPreparedStatement.ReuseProbability;
-import org.eclipse.net4j.db.IDBSchemaTransaction;
-import org.eclipse.net4j.db.IDBTransaction;
-import org.eclipse.net4j.util.CheckUtil;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.HashSet;
-import java.util.NavigableMap;
-import java.util.Set;
-import java.util.TreeMap;
-
-/**
- * @author Eike Stepper
- */
-public final class DBTransaction implements IDBTransaction
-{
- private final DBDatabase database;
-
- private final NavigableMap<String, DBPreparedStatement> cache = new TreeMap<String, DBPreparedStatement>();
-
- private final Set<DBPreparedStatement> checkOuts = new HashSet<DBPreparedStatement>();
-
- private int lastTouch;
-
- private Connection connection;
-
- public DBTransaction(DBDatabase database)
- {
- this.database = database;
-
- IDBConnectionProvider connectionProvider = database.getConnectionProvider();
- connection = connectionProvider.getConnection();
- if (connection == null)
- {
- throw new DBException("No connection from connection provider: " + connectionProvider);
- }
-
- try
- {
- connection.setAutoCommit(false);
- }
- catch (SQLException ex)
- {
- throw new DBException(ex, "SET AUTO COMMIT = false");
- }
- }
-
- public DBDatabase getDatabase()
- {
- return database;
- }
-
- public void close()
- {
- DBUtil.close(connection);
- connection = null;
-
- database.closeTransaction(this);
- }
-
- public boolean isClosed()
- {
- return connection != null;
- }
-
- public Connection getConnection()
- {
- return connection;
- }
-
- public IDBSchemaTransaction openSchemaTransaction()
- {
- DBSchemaTransaction schemaTransaction = database.openSchemaTransaction();
- schemaTransaction.setTransaction(this);
- return schemaTransaction;
- }
-
- public IDBPreparedStatement prepareStatement(String sql, ReuseProbability reuseProbability)
- {
- return prepareStatement(sql, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY, reuseProbability);
- }
-
- public IDBPreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency,
- ReuseProbability reuseProbability)
- {
- database.beginSchemaAccess(false);
-
- DBPreparedStatement preparedStatement = cache.remove(sql);
- if (preparedStatement == null)
- {
- try
- {
- PreparedStatement delegate = connection.prepareStatement(sql, resultSetType, resultSetConcurrency);
- preparedStatement = new DBPreparedStatement(this, sql, reuseProbability, delegate);
- }
- catch (SQLException ex)
- {
- throw new DBException(ex);
- }
- }
-
- checkOuts.add(preparedStatement);
- return preparedStatement;
- }
-
- public void releasePreparedStatement(DBPreparedStatement preparedStatement)
- {
- try
- {
- if (preparedStatement == null)
- {
- // Bug 276926: Silently accept preparedStatement == null and do nothing.
- return;
- }
-
- checkOuts.remove(preparedStatement);
- preparedStatement.setTouch(++lastTouch);
-
- String sql = preparedStatement.getSQL();
- if (cache.put(sql, preparedStatement) != null)
- {
- throw new IllegalStateException(sql + " already in cache"); //$NON-NLS-1$
- }
-
- if (cache.size() > database.getStatementCacheCapacity())
- {
- DBPreparedStatement old = cache.remove(cache.firstKey());
- DBUtil.close(old.getDelegate());
- }
- }
- finally
- {
- database.endSchemaAccess();
- }
- }
-
- public void invalidateStatementCache()
- {
- CheckUtil.checkState(checkOuts.isEmpty(), "Statements are checked out: " + checkOuts);
-
- // Close all statements in the cache, then clear the cache.
- for (DBPreparedStatement preparedStatement : cache.values())
- {
- PreparedStatement delegate = preparedStatement.getDelegate();
- DBUtil.close(delegate);
- }
-
- cache.clear();
- }
-
- public void commit()
- {
- try
- {
- connection.commit();
- }
- catch (SQLException ex)
- {
- throw new DBException("Problem during commit of " + this, ex);
- }
- }
-
- public void rollback()
- {
- try
- {
- connection.rollback();
- }
- catch (SQLException ex)
- {
- throw new DBException("Problem during rollback of " + this, ex);
- }
- }
-}

Back to the top