Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2013-03-11 14:12:00 -0400
committerEike Stepper2013-03-11 14:12:00 -0400
commit22130bee60e57723c24b63a07a777f2e9eb9c614 (patch)
tree17126fd7ad4b152738c348c41c228aeeac330adb
parent009e556a0fda4a93b878bbc7f99115f7f9e6b047 (diff)
downloadcdo-22130bee60e57723c24b63a07a777f2e9eb9c614.tar.gz
cdo-22130bee60e57723c24b63a07a777f2e9eb9c614.tar.xz
cdo-22130bee60e57723c24b63a07a777f2e9eb9c614.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/IDBStoreAccessor.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java1
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DurableLockingManager.java137
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ExternalReferenceManager.java16
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/SQLQueryHandler.java40
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractHorizontalClassMapping.java15
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AbstractListTableMapping.java16
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/AuditListTableMappingWithRanges.java16
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/horizontal/BranchingListTableMappingWithRanges.java16
-rw-r--r--plugins/org.eclipse.emf.cdo.tests.db/src/org/eclipse/emf/cdo/tests/db/verifier/DBStoreVerifier.java23
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBTransaction.java7
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBTransaction.java33
12 files changed, 163 insertions, 161 deletions
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 4f68b5a92e..9adc0d5cbe 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
@@ -32,6 +32,10 @@ public interface IDBStoreAccessor extends IStoreAccessor.Raw
*/
public IDBTransaction getDBTransaction();
+ /**
+ * @deprecated As of 4.2 use {@link #getDBTransaction()}.
+ */
+ @Deprecated
public Connection getConnection();
/**
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 f35190f8f2..1ad99b3ca7 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
@@ -629,6 +629,7 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor,
}
}
+ @Deprecated
public Connection getConnection()
{
return transaction.getConnection();
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 b7c9627340..64a74335bb 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
@@ -114,60 +114,53 @@ public class DurableLockingManager extends Lifecycle
public synchronized LockArea createLockArea(DBStoreAccessor accessor, String durableLockingID, String userID,
CDOBranchPoint branchPoint, boolean readOnly, Map<CDOID, LockGrade> locks)
{
- try
+ if (durableLockingID == null)
{
- if (durableLockingID == null)
- {
- durableLockingID = getNextDurableLockingID(accessor);
- }
- else
- {
- // If the caller is specifying the ID, make sure there is no area with this ID yet
- //
- try
- {
- getLockArea(accessor, durableLockingID);
- throw new LockAreaAlreadyExistsException(durableLockingID);
- }
- catch (LockAreaNotFoundException good)
- {
- }
- }
-
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlInsertLockArea, ReuseProbability.LOW);
-
+ durableLockingID = getNextDurableLockingID(accessor);
+ }
+ else
+ {
+ // If the caller is specifying the ID, make sure there is no area with this ID yet
+ //
try
{
- stmt.setString(1, durableLockingID);
- stmt.setString(2, userID);
- stmt.setInt(3, branchPoint.getBranch().getID());
- stmt.setLong(4, branchPoint.getTimeStamp());
- stmt.setBoolean(5, readOnly);
-
- DBUtil.update(stmt, true);
- }
- catch (SQLException e)
- {
- throw new DBException(e);
+ getLockArea(accessor, durableLockingID);
+ throw new LockAreaAlreadyExistsException(durableLockingID);
}
- finally
+ catch (LockAreaNotFoundException good)
{
- DBUtil.close(stmt);
}
+ }
- if (!locks.isEmpty())
- {
- insertLocks(accessor, durableLockingID, locks);
- }
+ PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlInsertLockArea, ReuseProbability.LOW);
- accessor.getConnection().commit();
+ try
+ {
+ stmt.setString(1, durableLockingID);
+ stmt.setString(2, userID);
+ stmt.setInt(3, branchPoint.getBranch().getID());
+ stmt.setLong(4, branchPoint.getTimeStamp());
+ stmt.setBoolean(5, readOnly);
- return CDOLockUtil.createLockArea(durableLockingID, userID, branchPoint, readOnly, locks);
+ DBUtil.update(stmt, true);
}
- catch (SQLException ex)
+ catch (SQLException e)
{
- throw new DBException(ex);
+ throw new DBException(e);
}
+ finally
+ {
+ DBUtil.close(stmt);
+ }
+
+ if (!locks.isEmpty())
+ {
+ insertLocks(accessor, durableLockingID, locks);
+ }
+
+ accessor.getDBTransaction().commit();
+
+ return CDOLockUtil.createLockArea(durableLockingID, userID, branchPoint, readOnly, locks);
}
private void insertLocks(DBStoreAccessor accessor, String durableLockingID, Map<CDOID, LockGrade> locks)
@@ -278,49 +271,34 @@ public class DurableLockingManager extends Lifecycle
public void deleteLockArea(DBStoreAccessor accessor, String durableLockingID)
{
- try
- {
- unlockWithoutCommit(accessor, durableLockingID);
-
- PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlDeleteLockArea, ReuseProbability.LOW);
+ unlockWithoutCommit(accessor, durableLockingID);
- try
- {
- stmt.setString(1, durableLockingID);
+ PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sqlDeleteLockArea, ReuseProbability.LOW);
- DBUtil.update(stmt, true);
- }
- catch (SQLException e)
- {
- throw new DBException(e);
- }
- finally
- {
- DBUtil.close(stmt);
- }
-
- accessor.getConnection().commit();
+ try
+ {
+ stmt.setString(1, durableLockingID);
+ DBUtil.update(stmt, true);
}
catch (SQLException e)
{
throw new DBException(e);
}
+ finally
+ {
+ DBUtil.close(stmt);
+ }
+
+ accessor.getDBTransaction().commit();
}
public void updateLockArea(DBStoreAccessor accessor, LockArea area)
{
- try
- {
- String areaID = area.getDurableLockingID();
- unlockWithoutCommit(accessor, areaID);
- insertLocks(accessor, areaID, area.getLocks());
+ String areaID = area.getDurableLockingID();
+ unlockWithoutCommit(accessor, areaID);
+ insertLocks(accessor, areaID, area.getLocks());
- accessor.getConnection().commit();
- }
- catch (SQLException e)
- {
- throw new DBException(e);
- }
+ accessor.getDBTransaction().commit();
}
public void lock(DBStoreAccessor accessor, String durableLockingID, LockType type,
@@ -337,15 +315,8 @@ public class DurableLockingManager extends Lifecycle
public void unlock(DBStoreAccessor accessor, String durableLockingID)
{
- try
- {
- unlockWithoutCommit(accessor, durableLockingID);
- accessor.getConnection().commit();
- }
- catch (SQLException e)
- {
- throw new DBException(e);
- }
+ unlockWithoutCommit(accessor, durableLockingID);
+ accessor.getDBTransaction().commit();
}
private void unlockWithoutCommit(DBStoreAccessor accessor, String durableLockingID)
@@ -549,7 +520,7 @@ public class DurableLockingManager extends Lifecycle
}
}
- accessor.getConnection().commit();
+ accessor.getDBTransaction().commit();
}
catch (SQLException e)
{
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 0f9464a73a..908e73f83b 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
@@ -41,7 +41,6 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
-import java.sql.Statement;
import java.util.concurrent.atomic.AtomicLong;
/**
@@ -205,18 +204,15 @@ public class ExternalReferenceManager extends Lifecycle
}
else
{
+ String sql = "SELECT MIN(" + EXTERNAL_REFS_ID + ") FROM " + table;
+
IDBStoreAccessor writer = store.getWriter(null);
- Connection connection = writer.getConnection();
- Statement statement = null;
+ PreparedStatement stmt = writer.getDBTransaction().prepareStatement(sql, ReuseProbability.LOW);
ResultSet resultSet = null;
try
{
- statement = connection.createStatement();
-
- String sql = "SELECT MIN(" + EXTERNAL_REFS_ID + ") FROM " + table;
- resultSet = statement.executeQuery(sql);
-
+ resultSet = stmt.executeQuery();
if (resultSet.next())
{
lastMappedID.set(resultSet.getLong(1));
@@ -227,13 +223,13 @@ public class ExternalReferenceManager extends Lifecycle
}
catch (SQLException ex)
{
- connection.rollback();
+ writer.getDBTransaction().rollback();
throw new DBException(ex);
}
finally
{
DBUtil.close(resultSet);
- DBUtil.close(statement);
+ DBUtil.close(stmt);
writer.release();
}
}
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 c23845dff4..1723a99bef 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,9 +21,9 @@ 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.ReuseProbability;
import java.sql.Clob;
-import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
@@ -49,16 +49,16 @@ public class SQLQueryHandler implements IQueryHandler
public static final String QUERY_STATEMENT = "queryStatement";
- private DBStoreAccessor storeAccessor;
+ private DBStoreAccessor accessor;
public SQLQueryHandler(DBStoreAccessor storeAccessor)
{
- this.storeAccessor = storeAccessor;
+ accessor = storeAccessor;
}
public DBStoreAccessor getStoreAccessor()
{
- return storeAccessor;
+ return accessor;
}
/**
@@ -94,23 +94,21 @@ public class SQLQueryHandler implements IQueryHandler
throw new IllegalArgumentException("Unsupported query language: " + language);
}
- IIDHandler idHandler = storeAccessor.getStore().getIDHandler();
- Connection connection = storeAccessor.getConnection();
- PreparedStatement statement = null;
+ HashMap<String, List<Integer>> paramMap = new HashMap<String, List<Integer>>();
+ String query = parse(info.getQueryString(), paramMap);
+
+ int firstResult = -1;
+ boolean queryStatement = true;
+ boolean objectQuery = true;
+ boolean mapQuery = false;
+
+ IIDHandler idHandler = accessor.getStore().getIDHandler();
+ PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(query, ResultSet.TYPE_SCROLL_INSENSITIVE,
+ ResultSet.CONCUR_READ_ONLY, ReuseProbability.MEDIUM);
ResultSet resultSet = null;
- String query = info.getQueryString();
try
{
- int firstResult = -1;
- boolean queryStatement = true;
- boolean objectQuery = true;
- boolean mapQuery = false;
-
- HashMap<String, List<Integer>> paramMap = new HashMap<String, List<Integer>>();
- query = parse(query, paramMap);
- statement = connection.prepareStatement(query, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
-
for (String key : info.getParameters().keySet())
{
if (FIRST_RESULT.equalsIgnoreCase(key))
@@ -189,14 +187,14 @@ public class SQLQueryHandler implements IQueryHandler
{
Object parameter = info.getParameters().get(key);
// parameter = convertToSQL(parameter);
- statement.setObject(indexes[i], parameter);
+ stmt.setObject(indexes[i], parameter);
}
}
}
if (queryStatement)
{
- resultSet = statement.executeQuery();
+ resultSet = stmt.executeQuery();
if (firstResult > -1)
{
resultSet.absolute(firstResult);
@@ -250,7 +248,7 @@ public class SQLQueryHandler implements IQueryHandler
}
else
{
- int result = statement.executeUpdate();
+ int result = stmt.executeUpdate();
context.addResult(result);
}
}
@@ -261,7 +259,7 @@ public class SQLQueryHandler implements IQueryHandler
finally
{
DBUtil.close(resultSet);
- DBUtil.close(statement);
+ DBUtil.close(stmt);
}
}
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 8d449b46ae..fd2e52a6de 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
@@ -60,7 +60,6 @@ import org.eclipse.core.runtime.Assert;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
-import java.sql.Statement;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collection;
@@ -852,20 +851,18 @@ public abstract class AbstractHorizontalClassMapping implements IClassMapping, I
builder.append(" IN ");
builder.append(idString);
String sql = builder.toString();
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Query XRefs (attributes): {0}", sql);
+ }
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
+ PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sql, ReuseProbability.MEDIUM);
ResultSet resultSet = null;
- Statement stmt = null;
try
{
- stmt = accessor.getConnection().createStatement();
- if (TRACER.isEnabled())
- {
- TRACER.format("Query XRefs (attributes): {0}", sql);
- }
-
- resultSet = stmt.executeQuery(sql);
+ resultSet = stmt.executeQuery();
while (resultSet.next())
{
CDOID sourceID = idHandler.getCDOID(resultSet, 1);
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 fa036aa9ec..5df8bcaf87 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
@@ -46,7 +46,6 @@ import org.eclipse.emf.ecore.EStructuralFeature;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
-import java.sql.Statement;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -426,19 +425,18 @@ public abstract class AbstractListTableMapping extends AbstractBasicListTableMap
builder.append(idString);
String sql = builder.toString();
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Query XRefs (list): {0}", sql);
+ }
+
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
+ PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sql, ReuseProbability.MEDIUM);
ResultSet resultSet = null;
- Statement stmt = null;
try
{
- stmt = accessor.getConnection().createStatement();
- if (TRACER.isEnabled())
- {
- TRACER.format("Query XRefs (list): {0}", sql);
- }
-
- resultSet = stmt.executeQuery(sql);
+ resultSet = stmt.executeQuery();
while (resultSet.next())
{
CDOID srcId = idHandler.getCDOID(resultSet, 1);
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 dac4007f6a..b222970db8 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
@@ -60,7 +60,6 @@ import org.eclipse.emf.ecore.EStructuralFeature;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
-import java.sql.Statement;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
@@ -1070,19 +1069,18 @@ public class AuditListTableMappingWithRanges extends AbstractBasicListTableMappi
builder.append(idString);
String sql = builder.toString();
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Query XRefs (list): {0}", sql);
+ }
+
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
+ PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sql, ReuseProbability.MEDIUM);
ResultSet resultSet = null;
- Statement stmt = null;
try
{
- stmt = accessor.getConnection().createStatement();
- if (TRACER.isEnabled())
- {
- TRACER.format("Query XRefs (list): {0}", sql);
- }
-
- resultSet = stmt.executeQuery(sql);
+ resultSet = stmt.executeQuery();
while (resultSet.next())
{
CDOID sourceID = idHandler.getCDOID(resultSet, 1);
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 79c0103604..16b3a96d73 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
@@ -64,7 +64,6 @@ import org.eclipse.emf.ecore.EStructuralFeature;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
-import java.sql.Statement;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -1405,19 +1404,18 @@ public class BranchingListTableMappingWithRanges extends AbstractBasicListTableM
builder.append(idString);
String sql = builder.toString();
+ if (TRACER.isEnabled())
+ {
+ TRACER.format("Query XRefs (list): {0}", sql);
+ }
+
IIDHandler idHandler = getMappingStrategy().getStore().getIDHandler();
+ PreparedStatement stmt = accessor.getDBTransaction().prepareStatement(sql, ReuseProbability.MEDIUM);
ResultSet resultSet = null;
- Statement stmt = null;
try
{
- stmt = accessor.getConnection().createStatement();
- if (TRACER.isEnabled())
- {
- TRACER.format("Query XRefs (list): {0}", sql);
- }
-
- resultSet = stmt.executeQuery(sql);
+ resultSet = stmt.executeQuery();
while (resultSet.next())
{
CDOID sourceID = idHandler.getCDOID(resultSet, 1);
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 585e9a2dae..c788743f76 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.getConnection().createStatement();
+ return accessor.getDBTransaction().getConnection().createStatement();
}
catch (SQLException ex)
{
@@ -307,8 +307,9 @@ public abstract class DBStoreVerifier
String tableName = mapping.getDBTables().iterator().next().getName();
TRACER.format("verifyUniqueIdVersion: {0} ...", tableName);
- String sql = "SELECT " + IMappingConstants.ATTRIBUTES_ID + "," + IMappingConstants.ATTRIBUTES_VERSION + ", count(1) FROM "
- + tableName + " GROUP BY " + IMappingConstants.ATTRIBUTES_ID + "," + IMappingConstants.ATTRIBUTES_VERSION;
+ String sql = "SELECT " + IMappingConstants.ATTRIBUTES_ID + "," + IMappingConstants.ATTRIBUTES_VERSION
+ + ", count(1) FROM " + tableName + " GROUP BY " + IMappingConstants.ATTRIBUTES_ID + ","
+ + IMappingConstants.ATTRIBUTES_VERSION;
TRACER.format(" Executing SQL: {0} ", sql);
@@ -342,7 +343,8 @@ public abstract class DBStoreVerifier
}
String tableName = mapping.getDBTables().iterator().next().getName();
- String sql = "SELECT " + IMappingConstants.ATTRIBUTES_ID + ", " + IMappingConstants.ATTRIBUTES_VERSION + " FROM " + tableName;
+ String sql = "SELECT " + IMappingConstants.ATTRIBUTES_ID + ", " + IMappingConstants.ATTRIBUTES_VERSION + " FROM "
+ + tableName;
ArrayList<Pair<Long, Integer>> idVersions = new ArrayList<Pair<Long, Integer>>();
@@ -374,9 +376,9 @@ public abstract class DBStoreVerifier
TRACER.format("verifyUniqueIdVersion: {0} for ID{1}v{2} ...", tableName, id, version);
- String sql = "SELECT " + IMappingConstants.LIST_IDX + " FROM " + tableName + " WHERE " + IMappingConstants.LIST_REVISION_ID
- + "=" + id + " AND " + IMappingConstants.LIST_REVISION_VERSION + "=" + version + " ORDER BY "
- + IMappingConstants.LIST_IDX;
+ String sql = "SELECT " + IMappingConstants.LIST_IDX + " FROM " + tableName + " WHERE "
+ + IMappingConstants.LIST_REVISION_ID + "=" + id + " AND " + IMappingConstants.LIST_REVISION_VERSION + "="
+ + version + " ORDER BY " + IMappingConstants.LIST_IDX;
TRACER.format(" Executing SQL: {0} ", sql);
@@ -490,7 +492,8 @@ public abstract class DBStoreVerifier
}
String tableName = mapping.getDBTables().iterator().next().getName();
- String sql = "SELECT " + IMappingConstants.ATTRIBUTES_ID + ", " + IMappingConstants.ATTRIBUTES_VERSION + " FROM " + tableName;
+ String sql = "SELECT " + IMappingConstants.ATTRIBUTES_ID + ", " + IMappingConstants.ATTRIBUTES_VERSION + " FROM "
+ + tableName;
ArrayList<Pair<Long, Integer>> idVersions = new ArrayList<Pair<Long, Integer>>();
@@ -519,8 +522,8 @@ public abstract class DBStoreVerifier
private void verifyCorrectIndices(IListMapping refMapping, long id) throws Exception
{
String tableName = refMapping.getDBTables().iterator().next().getName();
- String sql = "SELECT " + IMappingConstants.LIST_IDX + " FROM " + tableName + " WHERE " + IMappingConstants.LIST_REVISION_ID
- + "=" + id + " ORDER BY " + IMappingConstants.LIST_IDX;
+ String sql = "SELECT " + IMappingConstants.LIST_IDX + " FROM " + tableName + " WHERE "
+ + IMappingConstants.LIST_REVISION_ID + "=" + id + " ORDER BY " + IMappingConstants.LIST_IDX;
ResultSet resultSet = getStatement().executeQuery(sql);
int indexShouldBe = 0;
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/IDBTransaction.java
index 42b19fa0f4..9a6f782469 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/IDBTransaction.java
@@ -31,4 +31,11 @@ public interface IDBTransaction extends Closeable
public IDBSchemaTransaction openSchemaTransaction();
public IDBPreparedStatement prepareStatement(String sql, ReuseProbability reuseProbability);
+
+ public IDBPreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency,
+ ReuseProbability reuseProbability);
+
+ public void commit();
+
+ public void rollback();
}
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
index c32d1592cc..c1ac7092e8 100644
--- 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
@@ -21,6 +21,7 @@ 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;
@@ -95,6 +96,12 @@ public final class DBTransaction implements IDBTransaction
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);
@@ -102,7 +109,7 @@ public final class DBTransaction implements IDBTransaction
{
try
{
- PreparedStatement delegate = connection.prepareStatement(sql);
+ PreparedStatement delegate = connection.prepareStatement(sql, resultSetType, resultSetConcurrency);
preparedStatement = new DBPreparedStatement(this, sql, reuseProbability, delegate);
}
catch (SQLException ex)
@@ -159,4 +166,28 @@ public final class DBTransaction implements IDBTransaction
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