summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-10-20 11:35:56 (EDT)
committerEike Stepper2007-10-20 11:35:56 (EDT)
commitf799cf35042a46e37db08255f95702ab2a46edfe (patch)
tree5ab9682131bd300ef14ae67f963314d2f4d9c171
parente6076dcae41b4a23318f73dc37fce44ebfc3f596 (diff)
downloadcdo-f799cf35042a46e37db08255f95702ab2a46edfe.zip
cdo-f799cf35042a46e37db08255f95702ab2a46edfe.tar.gz
cdo-f799cf35042a46e37db08255f95702ab2a46edfe.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.xml20
-rw-r--r--plugins/org.eclipse.net4j.db.mysql/src/org/eclipse/net4j/db/internal/mysql/MYSQLAdapter.java31
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBAdapter.java7
3 files changed, 46 insertions, 12 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 9a30a52..611662f 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
@@ -31,25 +31,29 @@
<property name="mappingPrecedence" value="MODEL"/>
</mappingStrategy>
- <!-- name: <any user-contributed DBAdapter name> -->
- <dbAdapter name="mysql"/>
-
- <!-- <dataSource
+ <!--<dbAdapter name="derby"/>
+ <dataSource
driverClass="org.apache.derby.jdbc.EmbeddedDataSource"
databaseName="/temp/cdodb1"
createDatabase="create"/> -->
- <!--<dataSource
+
+ <dbAdapter name="derby"/>
+ <dataSource
driverClass="org.apache.derby.jdbc.ClientDataSource"
databaseName="cdodb1"
- createDatabase="create"/>-->
- <!--<dataSource
+ createDatabase="create"/>
+
+ <!--<dbAdapter name="hsqldb"/>
+ <dataSource
driverClass="org.eclipse.net4j.db.hsqldb.HSQLDBDataSource"
database="jdbc:hsqldb:mem:cdodb1"
user="sa"/>-->
+
+ <!--<dbAdapter name="mysql"/>
<dataSource
driverClass="com.mysql.jdbc.jdbc2.optional.MysqlDataSource"
url="jdbc:mysql://localhost/cdodb1"
- user="sa"/>
+ user="sa"/>-->
</store>
</repository>
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 8038655..376bff0 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;
@@ -68,6 +68,31 @@ public class MYSQLAdapter extends DBAdapter
}
@Override
+ protected String getTypeName(DBField field)
+ {
+ DBType type = field.getType();
+ switch (type)
+ {
+ case VARCHAR:
+ return "TEXT";
+ }
+
+ return super.getTypeName(field);
+ }
+
+ @Override
+ protected void addIndexField(StringBuilder builder, IDBField field)
+ {
+ super.addIndexField(builder, field);
+ if (field.getType() == DBType.VARCHAR)
+ {
+ builder.append("(");
+ builder.append(field.getPrecision());
+ builder.append(")");
+ }
+ }
+
+ @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/internal/db/DBAdapter.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/internal/db/DBAdapter.java
index 4b2137a..3b5516f 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
@@ -211,7 +211,7 @@ public abstract class DBAdapter implements IDBAdapter
builder.append(", ");
}
- builder.append(fields[i]);
+ addIndexField(builder, fields[i]);
}
builder.append(")");
@@ -220,6 +220,11 @@ public abstract class DBAdapter implements IDBAdapter
statement.execute(sql);
}
+ protected void addIndexField(StringBuilder builder, IDBField field)
+ {
+ builder.append(field);
+ }
+
protected String createConstraints(DBTable table)
{
return null;