summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2006-07-11 06:17:22 (EDT)
committerEike Stepper2006-07-11 06:17:22 (EDT)
commitda567c2866d238a66127d33f231e910c11afccd5 (patch)
treea3558b0ed897abbd960d9befd5516a0ebbc6b627
parent037697eb76d0239c676b2298faac0e519a31e647 (diff)
downloadcdo-da567c2866d238a66127d33f231e910c11afccd5.zip
cdo-da567c2866d238a66127d33f231e910c11afccd5.tar.gz
cdo-da567c2866d238a66127d33f231e910c11afccd5.tar.bz2
[150231] Add Derby support and make it the default database
-rw-r--r--plugins/org.eclipse.emf.cdo.examples.server/META-INF/server.properties20
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/Mapper.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/impl/MapperImpl.java43
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/CommitTransactionIndication.java18
4 files changed, 52 insertions, 31 deletions
diff --git a/plugins/org.eclipse.emf.cdo.examples.server/META-INF/server.properties b/plugins/org.eclipse.emf.cdo.examples.server/META-INF/server.properties
index ae20211..5ba75a6 100644
--- a/plugins/org.eclipse.emf.cdo.examples.server/META-INF/server.properties
+++ b/plugins/org.eclipse.emf.cdo.examples.server/META-INF/server.properties
@@ -7,11 +7,11 @@
# DERBY #
#########
-#jdbc.dialect=DERBY
-#jdbc.driver=org.apache.derby.jdbc.EmbeddedDriver
-#jdbc.url=jdbc:derby:cdoTest;create=true
-#jdbc.username=test
-#jdbc.password=test
+jdbc.dialect=DERBY
+jdbc.driver=org.apache.derby.jdbc.EmbeddedDriver
+jdbc.url=jdbc:derby:cdoTest;create=true
+jdbc.username=test
+jdbc.password=test
##########
# HSQLDB #
@@ -27,11 +27,11 @@
# MYSQL #
#########
-jdbc.dialect=MYSQL
-jdbc.driver=org.gjt.mm.mysql.Driver
-jdbc.url=jdbc:mysql://localhost/cdoTest
-jdbc.username=test
-jdbc.password=test
+#jdbc.dialect=MYSQL
+#jdbc.driver=org.gjt.mm.mysql.Driver
+#jdbc.url=jdbc:mysql://localhost/cdoTest
+#jdbc.username=test
+#jdbc.password=test
##########
# ORACLE #
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/Mapper.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/Mapper.java
index 68cee68..ab84e83 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/Mapper.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/Mapper.java
@@ -31,6 +31,8 @@ public interface Mapper extends Service
public void sql(String sql, Object[] args);
+ public void sql(String sql, Object[] args, int[] types);
+
public int getCollectionCount(long oid, int feature);
public boolean lock(long oid, int oca);
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/impl/MapperImpl.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/impl/MapperImpl.java
index 2dac4c1..c325bd1 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/impl/MapperImpl.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/impl/MapperImpl.java
@@ -391,22 +391,21 @@ public class MapperImpl extends ServiceImpl implements Mapper, SQLConstants
public void insertPackage(final PackageInfo packageInfo)
{
- sql(INSERT_PACKAGE, new Object[] { new Integer(packageInfo.getPid()), packageInfo.getName()});
+ sql(INSERT_PACKAGE, new Object[] { packageInfo.getPid(), packageInfo.getName()});
}
public void insertClass(final ClassInfo classInfo)
{
String parentName = classInfo.getParentName() == null ? "" : classInfo.getParentName();
- sql(INSERT_CLASS, new Object[] { new Integer(classInfo.getCID()), classInfo.getName(),
- parentName, classInfo.getTableName(), new Integer(classInfo.getPackageInfo().getPid())});
+ sql(INSERT_CLASS, new Object[] { classInfo.getCID(), classInfo.getName(), parentName,
+ classInfo.getTableName(), classInfo.getPackageInfo().getPid()});
}
public void insertAttribute(final AttributeInfo attributeInfo, final int cid)
{
- sql(INSERT_ATTRIBUTE,
- new Object[] { attributeInfo.getName(), new Integer(attributeInfo.getFeatureID()),
- new Integer(attributeInfo.getDataType()), attributeInfo.getColumnName(),
- new Integer(attributeInfo.getColumnType()), new Integer(cid)});
+ sql(INSERT_ATTRIBUTE, new Object[] { attributeInfo.getName(), attributeInfo.getFeatureID(),
+ attributeInfo.getDataType(), attributeInfo.getColumnName(), attributeInfo.getColumnType(),
+ cid});
}
public ResourceInfo selectResourceInfo(String path)
@@ -505,7 +504,7 @@ public class MapperImpl extends ServiceImpl implements Mapper, SQLConstants
public ResourceInfo createResource(String resourcePath)
{
int rid = getNextRID();
- sql(INSERT_RESOURCE, new Object[] { new Integer(rid), resourcePath});
+ sql(INSERT_RESOURCE, new Object[] { rid, resourcePath});
return resourceManager.registerResourceInfo(resourcePath, rid, 1);
}
@@ -528,24 +527,22 @@ public class MapperImpl extends ServiceImpl implements Mapper, SQLConstants
public void insertResource(int rid, String path)
{
- sql(INSERT_RESOURCE, new Object[] { new Integer(rid), path});
+ sql(INSERT_RESOURCE, new Object[] { rid, path});
}
public void insertReference(long oid, int feature, int ordinal, long target, boolean content)
{
- sql(INSERT_REFERENCE, new Object[] { new Long(oid), new Integer(feature), new Integer(ordinal),
- new Long(target), new Boolean(content)});
+ sql(INSERT_REFERENCE, new Object[] { oid, feature, ordinal, target, content});
}
public void removeReference(long oid, int feature, int ordinal)
{
- sql(REMOVE_REFERENCE, new Object[] { new Long(oid), new Integer(feature), new Integer(ordinal)});
+ sql(REMOVE_REFERENCE, new Object[] { oid, feature, ordinal});
}
public void moveReferenceAbsolute(long oid, int feature, int toIndex, int fromIndex)
{
- sql(MOVE_REFERENCE_ABSOLUTE, new Object[] { new Integer(toIndex), new Long(oid),
- new Integer(feature), new Integer(fromIndex)});
+ sql(MOVE_REFERENCE_ABSOLUTE, new Object[] { toIndex, oid, feature, fromIndex});
}
public void moveReferencesRelative(long oid, int feature, int startIndex, int endIndex, int offset)
@@ -566,7 +563,7 @@ public class MapperImpl extends ServiceImpl implements Mapper, SQLConstants
protected void removeReferences(long oid)
{
- Object[] args = { new Long(oid)};
+ Object[] args = { oid};
if (isDebugEnabled()) debug(StringHelper.replaceWildcards(REMOVE_REFERENCES, "?", args));
jdbcTemplate.update(REMOVE_REFERENCES, args);
@@ -629,12 +626,12 @@ public class MapperImpl extends ServiceImpl implements Mapper, SQLConstants
public void insertContent(long oid)
{
- sql(INSERT_CONTENT, new Object[] { new Long(oid)});
+ sql(INSERT_CONTENT, new Object[] { oid});
}
public void removeContent(long oid)
{
- sql(REMOVE_CONTENT, new Object[] { new Long(oid)});
+ sql(REMOVE_CONTENT, new Object[] { oid});
}
public void sql(String sql)
@@ -661,6 +658,18 @@ public class MapperImpl extends ServiceImpl implements Mapper, SQLConstants
}
}
+ public void sql(String sql, Object[] args, int[] types)
+ {
+ if (isDebugEnabled()) debug(StringHelper.replaceWildcards(sql, "?", args));
+
+ int rows = jdbcTemplate.update(sql, args, types);
+
+ if (rows != 1)
+ {
+ throw new DatabaseInconsistencyException(sql);
+ }
+ }
+
public void transmitContent(final Channel channel, ResourceInfo resourceInfo)
{
if (resourceInfo != null)
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/CommitTransactionIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/CommitTransactionIndication.java
index da53b28..d53ddb5 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/CommitTransactionIndication.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/protocol/CommitTransactionIndication.java
@@ -39,6 +39,8 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.sql.Types;
+
public class CommitTransactionIndication extends AbstractIndicationWithResponse
{
@@ -519,7 +521,9 @@ public class CommitTransactionIndication extends AbstractIndicationWithResponse
{
int count = receiveInt();
Object[] args = new Object[count + 1]; // last element is the oid
- args[count] = new Long(oid);
+ args[count] = oid;
+ int[] types = new int[count + 1];
+ types[count] = Types.BIGINT;
StringBuffer sql = new StringBuffer("UPDATE ");
sql.append(classInfo.getTableName());
@@ -530,7 +534,9 @@ public class CommitTransactionIndication extends AbstractIndicationWithResponse
int feature = receiveInt();
AttributeInfo attributeInfo = classInfo.getAttributeInfo(feature);
ColumnConverter converter = getMapper().getColumnConverter();
+
args[i] = converter.fromChannel(getChannel(), attributeInfo.getDataType());
+ types[i] = attributeInfo.getColumnType();
if (i > 0) sql.append(", ");
sql.append(attributeInfo.getColumnName());
@@ -541,7 +547,7 @@ public class CommitTransactionIndication extends AbstractIndicationWithResponse
sql.append(SQLConstants.USER_OID_COLUMN);
sql.append("=?");
- getMapper().sql(sql.toString(), args);
+ getMapper().sql(sql.toString(), args, types);
}
@@ -554,7 +560,10 @@ public class CommitTransactionIndication extends AbstractIndicationWithResponse
AttributeInfo[] attributeInfos = classInfo.getAttributeInfos();
Object[] args = new Object[attributeInfos.length + 1]; // the first element is the oid
- args[0] = new Long(oid);
+ args[0] = oid;
+
+ int[] types = new int[attributeInfos.length + 1];
+ types[0] = Types.BIGINT;
StringBuffer sql = new StringBuffer("INSERT INTO ");
sql.append(classInfo.getTableName());
@@ -567,12 +576,13 @@ public class CommitTransactionIndication extends AbstractIndicationWithResponse
ColumnConverter converter = getMapper().getColumnConverter();
args[i + 1] = converter.fromChannel(getChannel(), attributeInfo.getDataType());
+ types[i + 1] = attributeInfo.getColumnType();
sql.append(", ?");
}
sql.append(")");
- getMapper().sql(sql.toString(), args);
+ getMapper().sql(sql.toString(), args, types);
classInfo = classInfo.getParent();
}