Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrescobar2010-09-28 22:24:10 -0400
committerRyan D. Brooks2010-09-28 22:24:10 -0400
commita7e8c79fe7385f5bceac77563b1bb9b607204432 (patch)
treee513acc1ce15a79ff347f7ce08de3672956bd2a1 /plugins/org.eclipse.osee.framework.database
parent11392aa3f5f6a47439c0d92c27cabeac31c185df (diff)
downloadorg.eclipse.osee-a7e8c79fe7385f5bceac77563b1bb9b607204432.tar.gz
org.eclipse.osee-a7e8c79fe7385f5bceac77563b1bb9b607204432.tar.xz
org.eclipse.osee-a7e8c79fe7385f5bceac77563b1bb9b607204432.zip
feature[bgz_326568]: Add H2 Database support
Diffstat (limited to 'plugins/org.eclipse.osee.framework.database')
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/ConnectionHandler.java16
-rw-r--r--plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/SupportedDatabase.java5
2 files changed, 16 insertions, 5 deletions
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/ConnectionHandler.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/ConnectionHandler.java
index 2c122d64d7..4e37a2d7cc 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/ConnectionHandler.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/ConnectionHandler.java
@@ -155,11 +155,19 @@ public final class ConnectionHandler {
* Cause constraint checking to be deferred until the end of the current transaction.
*/
public static void deferConstraintChecking(OseeConnection connection) throws OseeCoreException {
- if (SupportedDatabase.getDatabaseType(connection.getMetaData()) == SupportedDatabase.derby) {
- return;
+ SupportedDatabase dbType = SupportedDatabase.getDatabaseType(connection.getMetaData());
+ switch (dbType) {
+ case derby:
+ // Derby Does not support deferring constraints
+ break;
+ case h2:
+ runPreparedUpdate(connection, "SET REFERENTIAL_INTEGRITY = FALSE");
+ break;
+ default:
+ // NOTE: this must be a PreparedStatement to play correctly with DB Transactions.
+ runPreparedUpdate(connection, "SET CONSTRAINTS ALL DEFERRED");
+ break;
}
- // NOTE: this must be a PreparedStatement to play correctly with DB Transactions.
- runPreparedUpdate(connection, "SET CONSTRAINTS ALL DEFERRED");
}
public static DatabaseMetaData getMetaData() throws OseeCoreException {
diff --git a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/SupportedDatabase.java b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/SupportedDatabase.java
index 618f666860..589b794486 100644
--- a/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/SupportedDatabase.java
+++ b/plugins/org.eclipse.osee.framework.database/src/org/eclipse/osee/framework/database/core/SupportedDatabase.java
@@ -17,6 +17,7 @@ import org.eclipse.osee.framework.core.exception.OseeDataStoreException;
import org.eclipse.osee.framework.core.exception.OseeExceptions;
public enum SupportedDatabase {
+ h2,
oracle,
derby,
foxpro,
@@ -28,7 +29,9 @@ public enum SupportedDatabase {
try {
String dbName = metaData.getDatabaseProductName();
String lowerCaseName = dbName.toLowerCase();
- if (lowerCaseName.contains(SupportedDatabase.derby.toString())) {
+ if (lowerCaseName.contains(SupportedDatabase.h2.toString())) {
+ toReturn = SupportedDatabase.h2;
+ } else if (lowerCaseName.contains(SupportedDatabase.derby.toString())) {
toReturn = SupportedDatabase.derby;
} else if (lowerCaseName.contains(SupportedDatabase.oracle.toString())) {
toReturn = SupportedDatabase.oracle;

Back to the top