summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-08-17 05:23:22 (EDT)
committerEike Stepper2007-08-17 05:23:22 (EDT)
commitb970d76bc01183a792d9e1ccfb17e1dc7e9316f2 (patch)
treec35b52cdb111f56584d436874528bd173f63394d
parentc5fee94fa2cafa9a0da36d885b11aae216471cd8 (diff)
downloadcdo-b970d76bc01183a792d9e1ccfb17e1dc7e9316f2.zip
cdo-b970d76bc01183a792d9e1ccfb17e1dc7e9316f2.tar.gz
cdo-b970d76bc01183a792d9e1ccfb17e1dc7e9316f2.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStore.java29
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IMappingStrategy.java9
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStore.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreReader.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/HorizontalMappingStrategy.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java50
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/VerticalMappingStrategy.java4
-rw-r--r--plugins/org.eclipse.net4j.db/reserved_words/ansi.txt337
-rw-r--r--plugins/org.eclipse.net4j.db/reserved_words/db2.txt376
-rw-r--r--plugins/org.eclipse.net4j.db/reserved_words/oracle.txt109
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java2
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBAdapter.java4
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBSchema.java8
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBAdapter.java10
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBSchema.java12
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBTable.java3
16 files changed, 940 insertions, 28 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStore.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStore.java
new file mode 100644
index 0000000..17d9917
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IDBStore.java
@@ -0,0 +1,29 @@
+/***************************************************************************
+ * Copyright (c) 2004 - 2007 Eike Stepper, Germany.
+ * 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.emf.cdo.server.db;
+
+import org.eclipse.emf.cdo.server.IStore;
+
+import org.eclipse.net4j.db.IDBAdapter;
+
+import javax.sql.DataSource;
+
+/**
+ * @author Eike Stepper
+ */
+public interface IDBStore extends IStore
+{
+ public IMappingStrategy getMappingStrategy();
+
+ public IDBAdapter getDBAdapter();
+
+ public DataSource getDataSource();
+}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IMappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IMappingStrategy.java
index 6aeef54..f4ea8f8 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IMappingStrategy.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/IMappingStrategy.java
@@ -11,7 +11,6 @@
package org.eclipse.emf.cdo.server.db;
import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
-import org.eclipse.emf.cdo.server.IStore;
import org.eclipse.net4j.db.IDBSchema;
import org.eclipse.net4j.db.IDBTable;
@@ -26,16 +25,16 @@ public interface IMappingStrategy
{
public String getType();
- public IStore getStore();
+ public IDBSchema getSchema();
+
+ public IDBStore getStore();
- public void setStore(IStore store);
+ public void setStore(IDBStore store);
public Properties getProperties();
public void setProperties(Properties properties);
- public IDBSchema getSchema();
-
/**
* @return A collection of the affected tables.
*/
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 c3b41a2..ff88579 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
@@ -14,6 +14,7 @@ import org.eclipse.emf.cdo.internal.server.Store;
import org.eclipse.emf.cdo.server.IStoreReader;
import org.eclipse.emf.cdo.server.IStoreWriter;
import org.eclipse.emf.cdo.server.IView;
+import org.eclipse.emf.cdo.server.db.IDBStore;
import org.eclipse.emf.cdo.server.db.IMappingStrategy;
import org.eclipse.net4j.db.DBException;
@@ -27,7 +28,7 @@ import java.sql.Connection;
/**
* @author Eike Stepper
*/
-public class DBStore extends Store
+public class DBStore extends Store implements IDBStore
{
private static final String TYPE = "db";
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreReader.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreReader.java
index ffe4f0b..88e82f6 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreReader.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreReader.java
@@ -98,7 +98,7 @@ public class DBStoreReader implements IStoreReader
public void readPackage(final CDOPackageImpl cdoPackage)
{
- String where = CDODBSchema.PACKAGES_URI.toString() + " = '" + cdoPackage.getPackageURI() + "'";
+ String where = CDODBSchema.PACKAGES_URI.getName() + " = '" + cdoPackage.getPackageURI() + "'";
Object[] values = DBUtil.select(connection, where, CDODBSchema.PACKAGES_ID, CDODBSchema.PACKAGES_NAME,
CDODBSchema.PACKAGES_ECORE);
cdoPackage.setServerInfo(new DBPackageInfo((Integer)values[0]));
@@ -129,7 +129,7 @@ public class DBStoreReader implements IStoreReader
}
};
- String where = CDODBSchema.CLASSES_PACKAGE.toString() + " = " + cdoPackage.getServerInfo();
+ String where = CDODBSchema.CLASSES_PACKAGE.getName() + " = " + cdoPackage.getServerInfo();
DBUtil.select(connection, rowHandler, where, CDODBSchema.CLASSES_ID, CDODBSchema.CLASSES_CLASSIFIER,
CDODBSchema.CLASSES_NAME, CDODBSchema.CLASSES_ABSTRACT);
}
@@ -147,7 +147,7 @@ public class DBStoreReader implements IStoreReader
}
};
- String where = CDODBSchema.SUPERTYPES_TYPE.toString() + " = " + classID;
+ String where = CDODBSchema.SUPERTYPES_TYPE.getName() + " = " + classID;
DBUtil.select(connection, rowHandler, where, CDODBSchema.SUPERTYPES_SUPERTYPE_PACKAGE,
CDODBSchema.SUPERTYPES_SUPERTYPE_CLASSIFIER);
}
@@ -184,7 +184,7 @@ public class DBStoreReader implements IStoreReader
}
};
- String where = CDODBSchema.FEATURES_CLASS.toString() + " = " + classID;
+ String where = CDODBSchema.FEATURES_CLASS.getName() + " = " + classID;
DBUtil.select(connection, rowHandler, where, CDODBSchema.FEATURES_ID, CDODBSchema.FEATURES_FEATURE,
CDODBSchema.FEATURES_NAME, CDODBSchema.FEATURES_TYPE, CDODBSchema.FEATURES_REFERENCE_PACKAGE,
CDODBSchema.FEATURES_REFERENCE_CLASSIFIER, CDODBSchema.FEATURES_MANY, CDODBSchema.FEATURES_CONTAINMENT);
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/HorizontalMappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/HorizontalMappingStrategy.java
index f3d26e6..e53e6b4 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/HorizontalMappingStrategy.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/HorizontalMappingStrategy.java
@@ -40,7 +40,7 @@ public class HorizontalMappingStrategy extends MappingStrategy
return null;
}
- IDBTable table = getSchema().addTable(cdoClass.getName());
+ IDBTable table = addTable(cdoClass);
initTable(table, true);
return table;
}
@@ -55,6 +55,6 @@ public class HorizontalMappingStrategy extends MappingStrategy
DBClassInfo classInfo = (DBClassInfo)cdoClass.getServerInfo();
IDBTable table = classInfo.getTable();
- return table.addField(cdoFeature.getName(), getDBType(cdoFeature.getType()));
+ return addField(cdoFeature, table);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java
index 97cdcd0..78c4aa3 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/MappingStrategy.java
@@ -14,10 +14,11 @@ import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
import org.eclipse.emf.cdo.protocol.model.CDOClass;
import org.eclipse.emf.cdo.protocol.model.CDOFeature;
import org.eclipse.emf.cdo.protocol.model.CDOType;
-import org.eclipse.emf.cdo.server.IStore;
+import org.eclipse.emf.cdo.server.db.IDBStore;
import org.eclipse.emf.cdo.server.db.IMappingStrategy;
import org.eclipse.emf.cdo.server.internal.db.bundle.OM;
+import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBType;
import org.eclipse.net4j.db.IDBField;
import org.eclipse.net4j.db.IDBSchema;
@@ -39,7 +40,7 @@ public abstract class MappingStrategy implements IMappingStrategy
{
private static final ContextTracer TRACER = new ContextTracer(OM.DEBUG, MappingStrategy.class);
- private IStore store;
+ private IDBStore store;
private Properties properties;
@@ -49,12 +50,12 @@ public abstract class MappingStrategy implements IMappingStrategy
{
}
- public IStore getStore()
+ public IDBStore getStore()
{
return store;
}
- public void setStore(IStore store)
+ public void setStore(IDBStore store)
{
this.store = store;
}
@@ -168,6 +169,16 @@ public abstract class MappingStrategy implements IMappingStrategy
*/
protected abstract IDBField map(CDOClass cdoClass, CDOFeature cdoFeature, Set<IDBTable> affectedTables);
+ protected String mangleTableName(String name, int attempt)
+ {
+ return store.getDBAdapter().mangleTableName(name, attempt);
+ }
+
+ protected String mangleFieldName(String name, int attempt)
+ {
+ return store.getDBAdapter().mangleFieldName(name, attempt);
+ }
+
protected IDBSchema createSchema()
{
String name = store.getRepository().getName();
@@ -183,6 +194,37 @@ public abstract class MappingStrategy implements IMappingStrategy
}
}
+ protected IDBTable addTable(CDOClass cdoClass)
+ {
+ for (int attempt = 0;; ++attempt)
+ {
+ try
+ {
+ String tableName = mangleTableName(cdoClass.getName(), attempt);
+ return getSchema().addTable(tableName);
+ }
+ catch (DBException ignore)
+ {
+ }
+ }
+ }
+
+ protected IDBField addField(CDOFeature cdoFeature, IDBTable table) throws DBException
+ {
+ for (int attempt = 0;; ++attempt)
+ {
+ try
+ {
+ String fieldName = mangleFieldName(cdoFeature.getName(), attempt);
+ DBType fieldType = getDBType(cdoFeature.getType());
+ return table.addField(fieldName, fieldType);
+ }
+ catch (DBException ignore)
+ {
+ }
+ }
+ }
+
protected DBType getDBType(CDOType type)
{
if (type == CDOType.BOOLEAN || type == CDOType.BOOLEAN_OBJECT)
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/VerticalMappingStrategy.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/VerticalMappingStrategy.java
index a2d55af..593af15 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/VerticalMappingStrategy.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/VerticalMappingStrategy.java
@@ -50,7 +50,7 @@ public class VerticalMappingStrategy extends MappingStrategy
return null;
}
- IDBTable table = getSchema().addTable(cdoClass.getName());
+ IDBTable table = addTable(cdoClass);
initTable(table, false);
return table;
}
@@ -65,6 +65,6 @@ public class VerticalMappingStrategy extends MappingStrategy
DBClassInfo classInfo = (DBClassInfo)cdoClass.getServerInfo();
IDBTable table = classInfo.getTable();
- return table.addField(cdoFeature.getName(), getDBType(cdoFeature.getType()));
+ return addField(cdoFeature, table);
}
}
diff --git a/plugins/org.eclipse.net4j.db/reserved_words/ansi.txt b/plugins/org.eclipse.net4j.db/reserved_words/ansi.txt
new file mode 100644
index 0000000..00a4009
--- /dev/null
+++ b/plugins/org.eclipse.net4j.db/reserved_words/ansi.txt
@@ -0,0 +1,337 @@
+ABSOLUTE
+ACTION
+ADD
+AFTER
+ALL
+ALLOCATE
+ALTER
+AND
+ANY
+ARE
+ARRAY
+AS
+ASC
+ASENSITIVE
+ASSERTION
+ASYMMETRIC
+AT
+ATOMIC
+AUTHORIZATION
+AVG
+BEFORE
+BEGIN
+BETWEEN
+BIGINT
+BINARY
+BIT
+BIT_LENGTH
+BLOB
+BOOLEAN
+BOTH
+BREADTH
+BY
+CALL
+CALLED
+CASCADE
+CASCADED
+CASE
+CAST
+CATALOG
+CHAR
+CHARACTER
+CHARACTER_LENGTH
+CHAR_LENGTH
+CHECK
+CLOB
+CLOSE
+COALESCE
+COLLATE
+COLLATION
+COLUMN
+COMMIT
+CONDITION
+CONNECT
+CONNECTION
+CONSTRAINT
+CONSTRAINTS
+CONSTRUCTOR
+CONTAINS
+CONTINUE
+CONVERT
+CORRESPONDING
+COUNT
+CREATE
+CROSS
+CUBE
+CURRENT
+CURRENT_DATE
+CURRENT_DEFAULT_TRANSFORM_GROUP
+CURRENT_PATH
+CURRENT_ROLE
+CURRENT_TIME
+CURRENT_TIMESTAMP
+CURRENT_TRANSFORM_GROUP_FOR_TYPE
+CURRENT_USER
+CURSOR
+CYCLE
+DATA
+DATE
+DAY
+DEALLOCATE
+DEC
+DECIMAL
+DECLARE
+DEFAULT
+DEFERRABLE
+DEFERRED
+DELETE
+DEPTH
+DEREF
+DESC
+DESCRIBE
+DESCRIPTOR
+DETERMINISTIC
+DIAGNOSTICS
+DISCONNECT
+DISTINCT
+DO
+DOMAIN
+DOUBLE
+DROP
+DYNAMIC
+EACH
+ELEMENT
+ELSE
+ELSEIF
+END
+EQUALS
+ESCAPE
+EXCEPT
+EXCEPTION
+EXEC
+EXECUTE
+EXISTS
+EXIT
+EXTERNAL
+EXTRACT
+FALSE
+FETCH
+FILTER
+FIRST
+FLOAT
+FOR
+FOREIGN
+FOUND
+FREE
+FROM
+FULL
+FUNCTION
+GENERAL
+GET
+GLOBAL
+GO
+GOTO
+GRANT
+GROUP
+GROUPING
+HANDLER
+HAVING
+HOLD
+HOUR
+IDENTITY
+IF
+IMMEDIATE
+IN
+INDICATOR
+INITIALLY
+INNER
+INOUT
+INPUT
+INSENSITIVE
+INSERT
+INT
+INTEGER
+INTERSECT
+INTERVAL
+INTO
+IS
+ISOLATION
+ITERATE
+JOIN
+KEY
+LANGUAGE
+LARGE
+LAST
+LATERAL
+LEADING
+LEAVE
+LEFT
+LEVEL
+LIKE
+LOCAL
+LOCALTIME
+LOCALTIMESTAMP
+LOCATOR
+LOOP
+LOWER
+MAP
+MATCH
+MAX
+MEMBER
+MERGE
+METHOD
+MIN
+MINUTE
+MODIFIES
+MODULE
+MONTH
+MULTISET
+NAMES
+NATIONAL
+NATURAL
+NCHAR
+NCLOB
+NEW
+NEXT
+NO
+NONE
+NOT
+NULL
+NULLIF
+NUMERIC
+OBJECT
+OCTET_LENGTH
+OF
+OLD
+ON
+ONLY
+OPEN
+OPTION
+OR
+ORDER
+ORDINALITY
+OUT
+OUTER
+OUTPUT
+OVER
+OVERLAPS
+PAD
+PARAMETER
+PARTIAL
+PARTITION
+PATH
+POSITION
+PRECISION
+PREPARE
+PRESERVE
+PRIMARY
+PRIOR
+PRIVILEGES
+PROCEDURE
+PUBLIC
+RANGE
+READ
+READS
+REAL
+RECURSIVE
+REF
+REFERENCES
+REFERENCING
+RELATIVE
+RELEASE
+REPEAT
+RESIGNAL
+RESTRICT
+RESULT
+RETURN
+RETURNS
+REVOKE
+RIGHT
+ROLE
+ROLLBACK
+ROLLUP
+ROUTINE
+ROW
+ROWS
+SAVEPOINT
+SCHEMA
+SCOPE
+SCROLL
+SEARCH
+SECOND
+SECTION
+SELECT
+SENSITIVE
+SESSION
+SESSION_USER
+SET
+SETS
+SIGNAL
+SIMILAR
+SIZE
+SMALLINT
+SOME
+SPACE
+SPECIFIC
+SPECIFICTYPE
+SQL
+SQLCODE
+SQLERROR
+SQLEXCEPTION
+SQLSTATE
+SQLWARNING
+START
+STATE
+STATIC
+SUBMULTISET
+SUBSTRING
+SUM
+SYMMETRIC
+SYSTEM
+SYSTEM_USER
+TABLE
+TABLESAMPLE
+TEMPORARY
+THEN
+TIME
+TIMESTAMP
+TIMEZONE_HOUR
+TIMEZONE_MINUTE
+TO
+TRAILING
+TRANSACTION
+TRANSLATE
+TRANSLATION
+TREAT
+TRIGGER
+TRIM
+TRUE
+UNDER
+UNDO
+UNION
+UNIQUE
+UNKNOWN
+UNNEST
+UNTIL
+UPDATE
+UPPER
+USAGE
+USER
+USING
+VALUE
+VALUES
+VARCHAR
+VARYING
+VIEW
+WHEN
+WHENEVER
+WHERE
+WHILE
+WINDOW
+WITH
+WITHIN
+WITHOUT
+WORK
+WRITE
+YEAR
+ZONE
diff --git a/plugins/org.eclipse.net4j.db/reserved_words/db2.txt b/plugins/org.eclipse.net4j.db/reserved_words/db2.txt
new file mode 100644
index 0000000..cdecd44
--- /dev/null
+++ b/plugins/org.eclipse.net4j.db/reserved_words/db2.txt
@@ -0,0 +1,376 @@
+ACTIVATE
+ADD
+AFTER
+ALIAS
+ALL
+ALLOCATE
+ALLOW
+ALTER
+AND
+ANY
+AS
+ASENSITIVE
+ASSOCIATE
+ASUTIME
+AT
+ATTRIBUTES
+AUDIT
+AUTHORIZATION
+AUX
+AUXILIARY
+BEFORE
+BEGIN
+BETWEEN
+BINARY
+BUFFERPOOL
+BY
+CACHE
+CALL
+CALLED
+CAPTURE
+CARDINALITY
+CASCADED
+CASE
+CAST
+CCSID
+CHAR
+CHARACTER
+CHECK
+CLOSE
+CLUSTER
+COLLECTION
+COLLID
+COLUMN
+COMMENT
+COMMIT
+CONCAT
+CONDITION
+CONNECT
+CONNECTION
+CONSTRAINT
+CONTAINS
+CONTINUE
+COUNT
+COUNT_BIG
+CREATE
+CROSS
+CURRENT
+CURRENT_DATE
+CURRENT_LC_CTYPE
+CURRENT_PATH
+CURRENT_SCHEMA
+CURRENT_SERVER
+CURRENT_TIME
+CURRENT_TIMESTAMP
+CURRENT_TIMEZONE
+CURRENT_USER
+CURSOR
+CYCLE
+DATA
+DATABASE
+DATAPARTITIONNAME
+DATAPARTITIONNUM
+DATE
+DAY
+DAYS
+DB2GENERAL
+DB2GENRL
+DB2SQL
+DBINFO
+DBPARTITIONNAME
+DBPARTITIONNUM
+DEALLOCATE
+DECLARE
+DEFAULT
+DEFAULTS
+DEFINITION
+DELETE
+DENSE_RANK
+DENSERANK
+DESCRIBE
+DESCRIPTOR
+DETERMINISTIC
+DIAGNOSTICS
+DISABLE
+DISALLOW
+DISCONNECT
+DISTINCT
+DO
+DOUBLE
+DROP
+DSSIZE
+DYNAMIC
+EACH
+EDITPROC
+ELSE
+ELSEIF
+ENABLE
+ENCODING
+ENCRYPTION
+END
+END-EXEC
+ENDING
+ERASE
+ESCAPE
+EVERY
+EXCEPT
+EXCEPTION
+EXCLUDING
+EXCLUSIVE
+EXECUTE
+EXISTS
+EXIT
+EXPLAIN
+EXTERNAL
+EXTRACT
+FENCED
+FETCH
+FIELDPROC
+FILE
+FINAL
+FOR
+FOREIGN
+FREE
+FROM
+FULL
+FUNCTION
+GENERAL
+GENERATED
+GET
+GLOBAL
+GO
+GOTO
+GRANT
+GRAPHIC
+GROUP
+HANDLER
+HASH
+HASHED_VALUE
+HAVING
+HINT
+HOLD
+HOUR
+HOURS
+IDENTITY
+IF
+IMMEDIATE
+IN
+INCLUDING
+INCLUSIVE
+INCREMENT
+INDEX
+INDICATOR
+INHERIT
+INNER
+INOUT
+INSENSITIVE
+INSERT
+INTEGRITY
+INTERSECT
+INTO
+IS
+ISOBID
+ISOLATION
+ITERATE
+JAR
+JAVA
+JOIN
+KEY
+LABEL
+LANGUAGE
+LATERAL
+LC_CTYPE
+LEAVE
+LEFT
+LIKE
+LINKTYPE
+LOCAL
+LOCALDATE
+LOCALE
+LOCALTIME
+LOCALTIMESTAMP
+LOCATOR
+LOCATORS
+LOCK
+LOCKMAX
+LOCKSIZE
+LONG
+LOOP
+MAINTAINED
+MATERIALIZED
+MAXVALUE
+MICROSECOND
+MICROSECONDS
+MINUTE
+MINUTES
+MINVALUE
+MODE
+MODIFIES
+MONTH
+MONTHS
+NEW
+NEW_TABLE
+NEXTVAL
+NO
+NOCACHE
+NOCYCLE
+NODENAME
+NODENUMBER
+NOMAXVALUE
+NOMINVALUE
+NONE
+NOORDER
+NORMALIZED
+NOT
+NULL
+NULLS
+NUMPARTS
+OBID
+OF
+OLD
+OLD_TABLE
+ON
+OPEN
+OPTIMIZATION
+OPTIMIZE
+OPTION
+OR
+ORDER
+OUT
+OUTER
+OVER
+OVERRIDING
+PACKAGE
+PADDED
+PAGESIZE
+PARAMETER
+PART
+PARTITION
+PARTITIONED
+PARTITIONING
+PARTITIONS
+PASSWORD
+PATH
+PIECESIZE
+PLAN
+POSITION
+PRECISION
+PREPARE
+PREVVAL
+PRIMARY
+PRIQTY
+PRIVILEGES
+PROCEDURE
+PROGRAM
+PSID
+QUERY
+QUERYNO
+RANGE
+RANK
+READ
+READS
+RECOVERY
+REFERENCES
+REFERENCING
+REFRESH
+RELEASE
+RENAME
+REPEAT
+RESET
+RESIGNAL
+RESTART
+RESTRICT
+RESULT
+RESULT_SET_LOCATOR
+RETURN
+RETURNS
+REVOKE
+RIGHT
+ROLLBACK
+ROUTINE
+ROW
+ROW_NUMBER
+ROWNUMBER
+ROWS
+ROWSET
+RRN
+RUN
+SAVEPOINT
+SCHEMA
+SCRATCHPAD
+SCROLL
+SEARCH
+SECOND
+SECONDS
+SECQTY
+SECURITY
+SELECT
+SENSITIVE
+SEQUENCE
+SESSION
+SESSION_USER
+SET
+SIGNAL
+SIMPLE
+SOME
+SOURCE
+SPECIFIC
+SQL
+SQLID
+STACKED
+STANDARD
+START
+STARTING
+STATEMENT
+STATIC
+STAY
+STOGROUP
+STORES
+STYLE
+SUBSTRING
+SUMMARY
+SYNONYM
+SYSFUN
+SYSIBM
+SYSPROC
+SYSTEM
+SYSTEM_USER
+TABLE
+TABLESPACE
+THEN
+TIME
+TIMESTAMP
+TO
+TRANSACTION
+TRIGGER
+TRIM
+TYPE
+UNDO
+UNION
+UNIQUE
+UNTIL
+UPDATE
+USAGE
+USER
+USING
+VALIDPROC
+VALUE
+VALUES
+VARIABLE
+VARIANT
+VCAT
+VERSION
+VIEW
+VOLATILE
+VOLUMES
+WHEN
+WHENEVER
+WHERE
+WHILE
+WITH
+WITHOUT
+WLM
+WRITE
+XMLELEMENT
+YEAR
+YEARS
diff --git a/plugins/org.eclipse.net4j.db/reserved_words/oracle.txt b/plugins/org.eclipse.net4j.db/reserved_words/oracle.txt
new file mode 100644
index 0000000..00b7d48
--- /dev/null
+++ b/plugins/org.eclipse.net4j.db/reserved_words/oracle.txt
@@ -0,0 +1,109 @@
+ACCESS
+ADD
+ALL
+ALTER
+AND
+ANY
+AS
+ASC
+AUDIT
+BETWEEN
+BY
+CHAR
+CHECK
+CLUSTER
+COLUMN
+COMMENT
+COMPRESS
+CONNECT
+CREATE
+CURRENT
+DATE
+DECIMAL
+DEFAULT
+DELETE
+DESC
+DISTINCT
+DROP
+ELSE
+EXCLUSIVE
+EXISTS
+FILE
+FLOAT
+FOR
+FROM
+GRANT
+GROUP
+HAVING
+IDENTIFIED
+IMMEDIATE
+IN
+INCREMENT
+INDEX
+INITIAL
+INSERT
+INTEGER
+INTERSECT
+INTO
+IS
+LEVEL
+LIKE
+LOCK
+LONG
+MAXEXTENTS
+MINUS
+MLSLABEL
+MODE
+MODIFY
+NOAUDIT
+NOCOMPRESS
+NOT
+NOWAIT
+NULL
+NUMBER
+OF
+OFFLINE
+ON
+ONLINE
+OPTION
+OR
+ORDER
+PCTFREE
+PRIOR
+PRIVILEGES
+PUBLIC
+RAW
+RENAME
+RESOURCE
+REVOKE
+ROW
+ROWID
+ROWNUM
+ROWS
+SELECT
+SESSION
+SET
+SHARE
+SIZE
+SMALLINT
+START
+SUCCESSFUL
+SYNONYM
+SYSDATE
+TABLE
+THEN
+TO
+TRIGGER
+UID
+UNION
+UNIQUE
+UPDATE
+USER
+VALIDATE
+VALUES
+VARCHAR
+VARCHAR2
+VIEW
+WHENEVER
+WHERE
+WITH
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 47ae48c..7f446fc 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
@@ -265,7 +265,7 @@ public final class DBUtil
builder.append(", ");
}
- builder.append(fields[i]);
+ builder.append(fields[i].getName());
}
builder.append(" FROM ");
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 d203601..25ca263 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
@@ -33,4 +33,8 @@ public interface IDBAdapter
public void createTables(Iterable<? extends IDBTable> tables, Connection connection) throws DBException;
public void createTable(IDBTable table, Statement statement) throws DBException;
+
+ public String mangleTableName(String name, int attempt);
+
+ public String mangleFieldName(String name, int attempt);
}
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBSchema.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBSchema.java
index 09466b3..23203dd 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBSchema.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBSchema.java
@@ -12,6 +12,8 @@ package org.eclipse.net4j.db;
import javax.sql.DataSource;
+import java.sql.Connection;
+
/**
* @author Eike Stepper
*/
@@ -19,11 +21,13 @@ public interface IDBSchema
{
public String getName();
- public IDBTable addTable(String name);
+ public IDBTable addTable(String name) throws DBException;
public IDBTable getTable(String name);
public IDBTable[] getTables();
- public void create(IDBAdapter dbAdapter, DataSource dataSource);
+ public void create(IDBAdapter dbAdapter, DataSource dataSource) throws DBException;
+
+ public void create(IDBAdapter dbAdapter, Connection connection) 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 4f267f9..f6f51da 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
@@ -90,6 +90,16 @@ public abstract class DBAdapter implements IDBAdapter
validateTable((DBTable)table, statement);
}
+ public String mangleFieldName(String name, int attempt)
+ {
+ return name;
+ }
+
+ public String mangleTableName(String name, int attempt)
+ {
+ return name;
+ }
+
@Override
public String toString()
{
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 861c2b0..e15a4fe 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
@@ -43,12 +43,12 @@ public class DBSchema implements IDBSchema
return name;
}
- public DBTable addTable(String name)
+ public DBTable addTable(String name) throws DBException
{
assertUnlocked();
if (tables.containsKey(name))
{
- throw new IllegalStateException("DBTable exists: " + name);
+ throw new DBException("DBTable exists: " + name);
}
DBTable table = new DBTable(this, name);
@@ -76,7 +76,7 @@ public class DBSchema implements IDBSchema
return locked = true;
}
- public void create(IDBAdapter dbAdapter, DataSource dataSource)
+ public void create(IDBAdapter dbAdapter, DataSource dataSource) throws DBException
{
Connection connection = null;
@@ -95,7 +95,7 @@ public class DBSchema implements IDBSchema
}
}
- public void create(IDBAdapter dbAdapter, Connection connection)
+ public void create(IDBAdapter dbAdapter, Connection connection) throws DBException
{
dbAdapter.createTables(tables.values(), connection);
}
@@ -106,11 +106,11 @@ public class DBSchema implements IDBSchema
return name;
}
- void assertUnlocked()
+ void assertUnlocked() throws DBException
{
if (locked)
{
- throw new IllegalStateException("DBSchema locked: " + name);
+ throw new DBException("DBSchema locked: " + name);
}
}
}
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBTable.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBTable.java
index 99de963..c5887be 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBTable.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBTable.java
@@ -10,6 +10,7 @@
**************************************************************************/
package org.eclipse.net4j.internal.db;
+import org.eclipse.net4j.db.DBException;
import org.eclipse.net4j.db.DBType;
import org.eclipse.net4j.db.IDBField;
import org.eclipse.net4j.db.IDBIndex;
@@ -79,7 +80,7 @@ public class DBTable implements IDBTable
schema.assertUnlocked();
if (getField(name) != null)
{
- throw new IllegalStateException("DBField exists: " + name);
+ throw new DBException("DBField exists: " + name);
}
DBField field = new DBField(this, name, type, precision, scale, notNull, fields.size());