summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-08-16 15:40:05 (EDT)
committerEike Stepper2007-08-16 15:40:05 (EDT)
commit2fbb584822d382ee8be2ab5d3757683beb9b8e8e (patch)
tree8ed753ab422b47d2bf3165c66df53842f2c68674
parent18f8c4427355e1b2a0782be90a4a674c555cd4c1 (diff)
downloadcdo-2fbb584822d382ee8be2ab5d3757683beb9b8e8e.zip
cdo-2fbb584822d382ee8be2ab5d3757683beb9b8e8e.tar.gz
cdo-2fbb584822d382ee8be2ab5d3757683beb9b8e8e.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreWriter.java20
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBAdapter.java5
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBAdapter.java28
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBSchema.java15
4 files changed, 38 insertions, 30 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreWriter.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreWriter.java
index 49afdbb..7fb909c 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreWriter.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreWriter.java
@@ -25,7 +25,6 @@ import org.eclipse.net4j.db.DBUtil;
import org.eclipse.net4j.db.IDBTable;
import java.sql.SQLException;
-import java.sql.Statement;
/**
* @author Eike Stepper
@@ -90,24 +89,7 @@ public class DBStoreWriter extends DBStoreReader implements IStoreWriter
IMappingStrategy mappingStrategy = store.getMappingStrategy();
IDBTable[] affectedTables = mappingStrategy.map(cdoPackage);
- Statement statement = null;
-
- try
- {
- statement = connection.createStatement();
- for (IDBTable table : affectedTables)
- {
- store.getDBAdapter().createTable(table, statement);
- }
- }
- catch (SQLException ex)
- {
- throw new DBException(ex);
- }
- finally
- {
- DBUtil.close(statement);
- }
+ store.getDBAdapter().createTables(affectedTables, connection);
}
public void writeClass(CDOClassImpl cdoClass)
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBAdapter.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBAdapter.java
index f9d6c14..f8ac2af 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBAdapter.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBAdapter.java
@@ -13,6 +13,7 @@ package org.eclipse.net4j.db;
import org.eclipse.net4j.internal.db.DBAdapterRegistry;
import org.eclipse.net4j.util.registry.IRegistry;
+import java.sql.Connection;
import java.sql.Driver;
import java.sql.Statement;
@@ -29,5 +30,7 @@ public interface IDBAdapter
public Driver getJDBCDriver();
- public void createTable(IDBTable table, Statement statement);
+ public void createTables(IDBTable[] tables, Connection connection) throws DBException;
+
+ public void createTable(IDBTable table, Statement statement) throws DBException;
}
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBAdapter.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBAdapter.java
index 4fdcaa4..b00a56a 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBAdapter.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBAdapter.java
@@ -12,11 +12,13 @@ package org.eclipse.net4j.internal.db;
import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBType;
+import org.eclipse.net4j.db.DBUtil;
import org.eclipse.net4j.db.IDBAdapter;
import org.eclipse.net4j.db.IDBTable;
import org.eclipse.net4j.internal.db.bundle.OM;
import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
+import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
@@ -49,7 +51,29 @@ public abstract class DBAdapter implements IDBAdapter
return version;
}
- public void createTable(IDBTable table, Statement statement)
+ public void createTables(IDBTable[] tables, Connection connection) throws DBException
+ {
+ Statement statement = null;
+
+ try
+ {
+ statement = connection.createStatement();
+ for (IDBTable table : tables)
+ {
+ createTable(table, statement);
+ }
+ }
+ catch (SQLException ex)
+ {
+ throw new DBException(ex);
+ }
+ finally
+ {
+ DBUtil.close(statement);
+ }
+ }
+
+ public void createTable(IDBTable table, Statement statement) throws DBException
{
try
{
@@ -143,7 +167,7 @@ public abstract class DBAdapter implements IDBAdapter
throw new IllegalArgumentException("Unknown type: " + type);
}
- protected void validateTable(DBTable table, Statement statement)
+ protected void validateTable(DBTable table, Statement statement) throws DBException
{
try
{
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBSchema.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBSchema.java
index d259590..a2ca7c6 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBSchema.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBSchema.java
@@ -14,12 +14,12 @@ import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBUtil;
import org.eclipse.net4j.db.IDBAdapter;
import org.eclipse.net4j.db.IDBSchema;
+import org.eclipse.net4j.db.IDBTable;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;
-import java.sql.Statement;
import java.util.HashMap;
import java.util.Map;
@@ -80,16 +80,11 @@ public class DBSchema implements IDBSchema
public void create(IDBAdapter dbAdapter, DataSource dataSource)
{
Connection connection = null;
- Statement statement = null;
try
{
connection = dataSource.getConnection();
- statement = connection.createStatement();
- for (DBTable table : tables.values())
- {
- dbAdapter.createTable(table, statement);
- }
+ create(dbAdapter, connection);
}
catch (SQLException ex)
{
@@ -97,11 +92,15 @@ public class DBSchema implements IDBSchema
}
finally
{
- DBUtil.close(statement);
DBUtil.close(connection);
}
}
+ public void create(IDBAdapter dbAdapter, Connection connection)
+ {
+ dbAdapter.createTables(tables.values().toArray(new IDBTable[tables.size()]), connection);
+ }
+
@Override
public String toString()
{