summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-10-20 11:15:21 (EDT)
committerEike Stepper2007-10-20 11:15:21 (EDT)
commite6076dcae41b4a23318f73dc37fce44ebfc3f596 (patch)
tree75aeff43e67dfde5c5f522f86e512a17c9411a9f
parentb4be229539f34f66bf12edb23dab8e6cf68e3222 (diff)
downloadcdo-e6076dcae41b4a23318f73dc37fce44ebfc3f596.zip
cdo-e6076dcae41b4a23318f73dc37fce44ebfc3f596.tar.gz
cdo-e6076dcae41b4a23318f73dc37fce44ebfc3f596.tar.bz2
[206980] Add Mysql adapter
https://bugs.eclipse.org/bugs/show_bug.cgi?id=206980
-rw-r--r--features/org.eclipse.emf.cdo.server.product-feature/rootfiles/configuration/cdo-server.xml8
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.java1
-rw-r--r--plugins/org.eclipse.net4j.db.mysql/META-INF/MANIFEST.MF14
-rw-r--r--plugins/org.eclipse.net4j.db.mysql/src/org/eclipse/net4j/db/internal/mysql/MYSQLAdapter.java36
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBField.java8
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBField.java20
6 files changed, 80 insertions, 7 deletions
diff --git a/features/org.eclipse.emf.cdo.server.product-feature/rootfiles/configuration/cdo-server.xml b/features/org.eclipse.emf.cdo.server.product-feature/rootfiles/configuration/cdo-server.xml
index 13cd084..9a30a52 100644
--- a/features/org.eclipse.emf.cdo.server.product-feature/rootfiles/configuration/cdo-server.xml
+++ b/features/org.eclipse.emf.cdo.server.product-feature/rootfiles/configuration/cdo-server.xml
@@ -32,7 +32,7 @@
</mappingStrategy>
<!-- name: <any user-contributed DBAdapter name> -->
- <dbAdapter name="hsqldb"/>
+ <dbAdapter name="mysql"/>
<!-- <dataSource
driverClass="org.apache.derby.jdbc.EmbeddedDataSource"
@@ -42,9 +42,13 @@
driverClass="org.apache.derby.jdbc.ClientDataSource"
databaseName="cdodb1"
createDatabase="create"/>-->
- <dataSource
+ <!--<dataSource
driverClass="org.eclipse.net4j.db.hsqldb.HSQLDBDataSource"
database="jdbc:hsqldb:mem:cdodb1"
+ user="sa"/>-->
+ <dataSource
+ driverClass="com.mysql.jdbc.jdbc2.optional.MysqlDataSource"
+ url="jdbc:mysql://localhost/cdodb1"
user="sa"/>
</store>
</repository>
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.java
index 128b367..7c3d479 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/ClassMapping.java
@@ -87,6 +87,7 @@ public abstract class ClassMapping implements IClassMapping
{
IDBField versionField = table.getField(CDODBSchema.ATTRIBUTES_VERSION);
IDBField pathField = attributeMapping.getField();
+ pathField.setPrecision(760);// MYSQL key limitation 767
pathField.setNotNull(true);
// Create a unique index to prevent duplicate resource paths
diff --git a/plugins/org.eclipse.net4j.db.mysql/META-INF/MANIFEST.MF b/plugins/org.eclipse.net4j.db.mysql/META-INF/MANIFEST.MF
index 366f46e..7596d79 100644
--- a/plugins/org.eclipse.net4j.db.mysql/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.net4j.db.mysql/META-INF/MANIFEST.MF
@@ -9,5 +9,15 @@ Bundle-ClassPath: .,
lib/mysql-connector-java-5.1.5-bin.jar
Fragment-Host: org.eclipse.net4j.db;bundle-version="[0.8.0,0.9.0)"
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.3.0,4.0.0)"
-Export-Package: org.eclipse.net4j.db.internal.mysql;version="0.8.0",
- org.gjt.mm.mysql;x-friends:="org.eclipse.emf.cdo.tests,org.eclipse.net4j.jms.tests,org.eclipse.net4j.tests"
+Export-Package: com.mysql.jdbc,
+ com.mysql.jdbc.exceptions,
+ com.mysql.jdbc.exceptions.jdbc4,
+ com.mysql.jdbc.integration.c3p0,
+ com.mysql.jdbc.integration.jboss,
+ com.mysql.jdbc.interceptors,
+ com.mysql.jdbc.jdbc2.optional,
+ com.mysql.jdbc.log,
+ com.mysql.jdbc.profiler,
+ com.mysql.jdbc.util,
+ org.eclipse.net4j.db.internal.mysql;version="0.8.0",
+ org.gjt.mm.mysql
diff --git a/plugins/org.eclipse.net4j.db.mysql/src/org/eclipse/net4j/db/internal/mysql/MYSQLAdapter.java b/plugins/org.eclipse.net4j.db.mysql/src/org/eclipse/net4j/db/internal/mysql/MYSQLAdapter.java
index de47175..8038655 100644
--- a/plugins/org.eclipse.net4j.db.mysql/src/org/eclipse/net4j/db/internal/mysql/MYSQLAdapter.java
+++ b/plugins/org.eclipse.net4j.db.mysql/src/org/eclipse/net4j/db/internal/mysql/MYSQLAdapter.java
@@ -11,13 +11,13 @@
package org.eclipse.net4j.db.internal.mysql;
import org.eclipse.net4j.db.DBException;
-import org.eclipse.net4j.db.DBType;
-import org.eclipse.net4j.db.IDBField;
import org.eclipse.net4j.internal.db.DBAdapter;
-import org.eclipse.net4j.internal.db.DBField;
import org.gjt.mm.mysql.Driver;
+import java.io.BufferedReader;
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
import java.sql.SQLException;
import java.util.Arrays;
@@ -26,6 +26,30 @@ import java.util.Arrays;
*/
public class MYSQLAdapter extends DBAdapter
{
+ private static final String[] RESERVED_WORDS = { "ACTION", "ADD", "ALL", "ALTER", "ANALYZE", "AND", "AS", "ASC",
+ "ASENSITIVE", "BEFORE", "BETWEEN", "BIGINT", "BINARY", "BIT", "BLOB", "BOTH", "BY", "CALL", "CASCADE", "CASE",
+ "CHANGE", "CHAR", "CHARACTER", "CHECK", "COLLATE", "COLUMN", "CONDITION", "CONSTRAINT", "CONTINUE", "CONVERT",
+ "CREATE", "CROSS", "CURRENT_DATE", "CURRENT_TIME", "CURRENT_TIMESTAMP", "CURRENT_USER", "CURSOR", "DATABASE",
+ "DATABASES", "DATE", "DAY_HOUR", "DAY_MICROSECOND", "DAY_MINUTE", "DAY_SECOND", "DEC", "DECIMAL", "DECLARE",
+ "DEFAULT", "DELAYED", "DELETE", "DESC", "DESCRIBE", "DETERMINISTIC", "DISTINCT", "DISTINCTROW", "DIV", "DOUBLE",
+ "DROP", "DUAL", "EACH", "ELSE", "ELSEIF", "ENCLOSED", "ENUM", "ESCAPED", "EXISTS", "EXIT", "EXPLAIN", "FALSE",
+ "FETCH", "FLOAT", "FLOAT4", "FLOAT8", "FOR", "FORCE", "FOREIGN", "FROM", "FULLTEXT", "GRANT", "GROUP", "HAVING",
+ "HIGH_PRIORITY", "HOUR_MICROSECOND", "HOUR_MINUTE", "HOUR_SECOND", "IF", "IGNORE", "IN", "INDEX", "INFILE",
+ "INNER", "INOUT", "INSENSITIVE", "INSERT", "INT", "INT1", "INT2", "INT3", "INT4", "INT8", "INTEGER", "INTERVAL",
+ "INTO", "IS", "ITERATE", "JOIN", "KEY", "KEYS", "KILL", "LEADING", "LEAVE", "LEFT", "LIKE", "LIMIT", "LINES",
+ "LOAD", "LOCALTIME", "LOCALTIMESTAMP", "LOCK", "LONG", "LONGBLOB", "LONGTEXT", "LOOP", "LOW_PRIORITY", "MATCH",
+ "MEDIUMBLOB", "MEDIUMINT", "MEDIUMTEXT", "MIDDLEINT", "MINUTE_MICROSECOND", "MINUTE_SECOND", "MOD", "MODIFIES",
+ "NATURAL", "NO", "NOT", "NO_WRITE_TO_BINLOG", "NULL", "NUMERIC", "ON", "OPTIMIZE", "OPTION", "OPTIONALLY", "OR",
+ "ORDER", "OUT", "OUTER", "OUTFILE", "PRECISION", "PRIMARY", "PROCEDURE", "PURGE", "RAID0", "READ", "READS",
+ "REAL", "REFERENCES", "REGEXP", "RELEASE", "RENAME", "REPEAT", "REPLACE", "REQUIRE", "RESTRICT", "RETURN",
+ "REVOKE", "RIGHT", "RLIKE", "SCHEMA", "SCHEMAS", "SECOND_MICROSECOND", "SELECT", "SENSITIVE", "SEPARATOR", "SET",
+ "SHOW", "SMALLINT", "SONAME", "SPATIAL", "SPECIFIC", "SQL", "SQLEXCEPTION", "SQLSTATE", "SQLWARNING",
+ "SQL_BIG_RESULT", "SQL_CALC_FOUND_ROWS", "SQL_SMALL_RESULT", "SSL", "STARTING", "STRAIGHT_JOIN", "TABLE",
+ "TERMINATED", "TEXT", "THEN", "TIME", "TIMESTAMP", "TINYBLOB", "TINYINT", "TINYTEXT", "TO", "TRAILING",
+ "TRIGGER", "TRUE", "UNDO", "UNION", "UNIQUE", "UNLOCK", "UNSIGNED", "UPDATE", "USAGE", "USE", "USING",
+ "UTC_DATE", "UTC_TIME", "UTC_TIMESTAMP", "VALUES", "VARBINARY", "VARCHAR", "VARCHARACTER", "VARYING", "WHEN",
+ "WHERE", "WHILE", "WITH", "WRITE", "X509", "XOR", "YEAR_MONTH", "ZEROFILL" };
+
public MYSQLAdapter()
{
super("mysql", "5.1.5");
@@ -42,4 +66,10 @@ public class MYSQLAdapter extends DBAdapter
throw new DBException(ex);
}
}
+
+ @Override
+ protected boolean isReservedWord(String word)
+ {
+ return Arrays.binarySearch(RESERVED_WORDS, word.toUpperCase()) >= 0;
+ }
}
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBField.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBField.java
index f82cd3d..7838aab 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBField.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBField.java
@@ -19,12 +19,20 @@ public interface IDBField extends IDBElement
public IDBTable getTable();
+ public void setName(String name);
+
public DBType getType();
+ public void setType(DBType type);
+
public int getPrecision();
+ public void setPrecision(int precision);
+
public int getScale();
+ public void setScale(int scale);
+
public boolean isNotNull();
public void setNotNull(boolean on);
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBField.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBField.java
index f787c30..8e36538 100644
--- a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBField.java
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBField.java
@@ -61,21 +61,41 @@ public class DBField extends DBElement implements IDBField
return name;
}
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+
public DBType getType()
{
return type;
}
+ public void setType(DBType type)
+ {
+ this.type = type;
+ }
+
public int getPrecision()
{
return precision == DEFAULT ? DEFAULT_PRECISION : precision;
}
+ public void setPrecision(int precision)
+ {
+ this.precision = precision;
+ }
+
public int getScale()
{
return scale;
}
+ public void setScale(int scale)
+ {
+ this.scale = scale;
+ }
+
public boolean isNotNull()
{
return notNull;