summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-08-16 05:00:48 (EDT)
committerEike Stepper2007-08-16 05:00:48 (EDT)
commit3e1b65f3fe98c57ca7bb5dcd2224818296c04b6b (patch)
treea19ea4c9b81906f9c393b317ce1f8ae6c7394257
parent76185a225a698cb986b0c15ce41e0c8d1f3ca20b (diff)
downloadcdo-3e1b65f3fe98c57ca7bb5dcd2224818296c04b6b.zip
cdo-3e1b65f3fe98c57ca7bb5dcd2224818296c04b6b.tar.gz
cdo-3e1b65f3fe98c57ca7bb5dcd2224818296c04b6b.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/CDODBSchema.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreReader.java139
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreWriter.java13
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/PackageManager.java15
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreReader.java28
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBSelect.java68
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBUtil.java105
-rw-r--r--plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBRowHandler.java19
9 files changed, 371 insertions, 28 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/CDODBSchema.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/CDODBSchema.java
index e8ee239..2aefd22 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/CDODBSchema.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/CDODBSchema.java
@@ -63,7 +63,7 @@ public class CDODBSchema extends DBSchema
CLASSES.addField("id", IDBField.Type.INTEGER);
public static final IDBField CLASSES_PACKAGE = //
- CLASSES.addField("package", IDBField.Type.VARCHAR, 255);
+ CLASSES.addField("package", IDBField.Type.INTEGER);
public static final IDBField CLASSES_CLASSIFIER = //
CLASSES.addField("classifier", IDBField.Type.INTEGER);
@@ -102,6 +102,12 @@ public class CDODBSchema extends DBSchema
public static final IDBField FEATURES_ID = //
FEATURES.addField("id", IDBField.Type.INTEGER);
+ public static final IDBField FEATURES_CLASS = //
+ FEATURES.addField("class", IDBField.Type.INTEGER);
+
+ public static final IDBField FEATURES_FEATURE = //
+ FEATURES.addField("feature", IDBField.Type.INTEGER);
+
public static final IDBField FEATURES_NAME = //
FEATURES.addField("name", IDBField.Type.VARCHAR, 255);
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 36f107a..d511f77 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
@@ -10,16 +10,28 @@
**************************************************************************/
package org.eclipse.emf.cdo.server.internal.db;
+import org.eclipse.emf.cdo.internal.protocol.CDOIDRangeImpl;
+import org.eclipse.emf.cdo.internal.protocol.model.CDOClassImpl;
+import org.eclipse.emf.cdo.internal.protocol.model.CDOClassProxy;
+import org.eclipse.emf.cdo.internal.protocol.model.CDOClassRefImpl;
+import org.eclipse.emf.cdo.internal.protocol.model.CDOFeatureImpl;
import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
+import org.eclipse.emf.cdo.internal.protocol.model.CDOTypeImpl;
import org.eclipse.emf.cdo.protocol.CDOID;
+import org.eclipse.emf.cdo.protocol.CDOIDRange;
import org.eclipse.emf.cdo.protocol.model.CDOClassRef;
+import org.eclipse.emf.cdo.protocol.model.CDOType;
import org.eclipse.emf.cdo.protocol.revision.CDORevision;
import org.eclipse.emf.cdo.server.IStoreReader;
import org.eclipse.net4j.db.DBException;
+import org.eclipse.net4j.db.DBUtil;
+import org.eclipse.net4j.db.IDBRowHandler;
import java.sql.Connection;
import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Collection;
/**
* @author Eike Stepper
@@ -61,16 +73,131 @@ public class DBStoreReader implements IStoreReader
return store;
}
- public CDOPackageImpl[] readPackages()
+ public Collection<PackageInfo> readPackageInfos()
{
- // TODO Implement method DBStoreReader.readPackages()
- throw new UnsupportedOperationException("Not yet implemented");
+ final Collection<PackageInfo> result = new ArrayList(0);
+ IDBRowHandler rowHandler = new IDBRowHandler()
+ {
+ public boolean handle(int row, final Object... values)
+ {
+ result.add(new PackageInfo()
+ {
+ public String getPackageURI()
+ {
+ return (String)values[0];
+ }
+
+ public boolean isDynamic()
+ {
+ return values[1] != null;
+ }
+
+ public CDOIDRange getMetaIDRange()
+ {
+ long rangeLB = (Long)values[2];
+ long rangeUB = (Long)values[3];
+ return CDOIDRangeImpl.create(rangeLB, rangeUB);
+ }
+ });
+
+ return true;
+ }
+ };
+
+ DBUtil.select(connection, rowHandler, CDODBSchema.PACKAGES_URI, CDODBSchema.PACKAGES_DYNAMIC,
+ CDODBSchema.PACKAGES_RANGE_LB, CDODBSchema.PACKAGES_RANGE_UB);
+ return result;
}
- public void readPackage(CDOPackageImpl cdoPackage)
+ public void readPackage(final CDOPackageImpl cdoPackage)
{
- // TODO Implement method DBStoreReader.readPackage()
- throw new UnsupportedOperationException("Not yet implemented");
+ Object[] values = DBUtil.select(connection, "", CDODBSchema.PACKAGES_ID, CDODBSchema.PACKAGES_NAME,
+ CDODBSchema.PACKAGES_ECORE);
+ cdoPackage.setServerInfo(values[0]);
+ cdoPackage.setName((String)values[1]);
+ cdoPackage.setEcore((String)values[2]);
+
+ IDBRowHandler rowHandler = new IDBRowHandler()
+ {
+ public boolean handle(int row, Object... values)
+ {
+ int classifierID = (Integer)values[1];
+ String name = (String)values[2];
+ boolean isAbstract = (Boolean)values[3];
+ CDOClassImpl cdoClass = new CDOClassImpl(cdoPackage, classifierID, name, isAbstract);
+ cdoClass.setServerInfo(values[0]);
+ cdoPackage.addClass(cdoClass);
+ readClass(cdoClass);
+ return true;
+ }
+ };
+
+ String where = CDODBSchema.CLASSES_PACKAGE.toString() + " = '" + cdoPackage.getPackageURI() + "'";
+ DBUtil.select(connection, rowHandler, where, CDODBSchema.CLASSES_ID, CDODBSchema.CLASSES_CLASSIFIER,
+ CDODBSchema.CLASSES_NAME, CDODBSchema.CLASSES_ABSTRACT);
+ }
+
+ public void readClass(final CDOClassImpl cdoClass)
+ {
+ int classID = (Integer)cdoClass.getServerInfo();
+ readSuperTypes(cdoClass, classID);
+ readFeatures(cdoClass, classID);
+ }
+
+ public void readSuperTypes(final CDOClassImpl cdoClass, int classID)
+ {
+ IDBRowHandler rowHandler = new IDBRowHandler()
+ {
+ public boolean handle(int row, Object... values)
+ {
+ String packageURI = (String)values[0];
+ int classifierID = (Integer)values[1];
+ cdoClass.addSuperType(new CDOClassRefImpl(packageURI, classifierID));
+ return true;
+ }
+ };
+
+ String where = CDODBSchema.SUPERTYPES_TYPE.toString() + " = " + classID;
+ DBUtil.select(connection, rowHandler, where, CDODBSchema.SUPERTYPES_SUPERTYPE_PACKAGE,
+ CDODBSchema.SUPERTYPES_SUPERTYPE_CLASSIFIER);
+ }
+
+ public void readFeatures(final CDOClassImpl cdoClass, int classID)
+ {
+ IDBRowHandler rowHandler = new IDBRowHandler()
+ {
+ public boolean handle(int row, Object... values)
+ {
+ int featureID = (Integer)values[1];
+ String name = (String)values[2];
+ CDOTypeImpl type = CDOTypeImpl.getType((Integer)values[3]);
+ boolean many = (Boolean)values[6];
+
+ CDOFeatureImpl feature;
+ if (type == CDOType.OBJECT)
+ {
+ String packageURI = (String)values[4];
+ int classifierID = (Integer)values[5];
+ boolean containment = (Boolean)values[7];
+ CDOClassRefImpl classRef = new CDOClassRefImpl(packageURI, classifierID);
+ CDOClassProxy referenceType = new CDOClassProxy(classRef, cdoClass.getPackageManager());
+ feature = new CDOFeatureImpl(cdoClass, featureID, name, referenceType, many, containment);
+ }
+ else
+ {
+ feature = new CDOFeatureImpl(cdoClass, featureID, name, type, many);
+ }
+
+ feature.setServerInfo(values[0]);
+ cdoClass.addFeature(feature);
+ return true;
+ }
+ };
+
+ String where = CDODBSchema.FEATURES_CLASS.toString() + " = " + 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);
}
public CDORevision readRevision(CDOID id, long timeStamp)
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreWriter.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreWriter.java
index c6f133c..3de3349 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreWriter.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreWriter.java
@@ -78,7 +78,7 @@ public class DBStoreWriter extends DBStoreReader implements IStoreWriter
CDOIDRange metaIDRange = cdoPackage.getMetaIDRange();
long lb = metaIDRange.getLowerBound().getValue();
long ub = metaIDRange.getUpperBound().getValue();
- DBUtil.insert(connection, CDODBSchema.PACKAGES, id, packageURI, name, ecore, dynamic, lb, ub);
+ DBUtil.insertRow(connection, CDODBSchema.PACKAGES, id, packageURI, name, ecore, dynamic, lb, ub);
for (CDOClassImpl cdoClass : cdoPackage.getClasses())
{
@@ -92,11 +92,11 @@ public class DBStoreWriter extends DBStoreReader implements IStoreWriter
cdoClass.setServerInfo(id);
CDOPackageImpl cdoPackage = cdoClass.getContainingPackage();
- String packageURI = cdoPackage.getPackageURI();
+ int packageID = (Integer)cdoPackage.getServerInfo();
int classifierID = cdoClass.getClassifierID();
String name = cdoClass.getName();
boolean isAbstract = cdoClass.isAbstract();
- DBUtil.insert(connection, CDODBSchema.CLASSES, id, packageURI, classifierID, name, isAbstract);
+ DBUtil.insertRow(connection, CDODBSchema.CLASSES, id, packageID, classifierID, name, isAbstract);
for (CDOClassProxy superType : cdoClass.getSuperTypeProxies())
{
@@ -113,7 +113,7 @@ public class DBStoreWriter extends DBStoreReader implements IStoreWriter
{
String packageURI = superType.getPackageURI();
int classifierID = superType.getClassifierID();
- DBUtil.insert(connection, CDODBSchema.SUPERTYPES, type, packageURI, classifierID);
+ DBUtil.insertRow(connection, CDODBSchema.SUPERTYPES, type, packageURI, classifierID);
}
public void writeFeature(CDOFeatureImpl feature)
@@ -121,7 +121,9 @@ public class DBStoreWriter extends DBStoreReader implements IStoreWriter
int id = store.getNextFeatureID();
feature.setServerInfo(id);
+ int classID = (Integer)feature.getContainingClass().getServerInfo();
String name = feature.getName();
+ int featureID = feature.getFeatureID();
int type = feature.getType().getTypeID();
CDOClassProxy reference = feature.getReferenceTypeProxy();
String packageURI = reference == null ? null : reference.getPackageURI();
@@ -129,7 +131,8 @@ public class DBStoreWriter extends DBStoreReader implements IStoreWriter
boolean many = feature.isMany();
boolean containment = feature.isContainment();
int idx = feature.getFeatureIndex();
- DBUtil.insert(connection, CDODBSchema.FEATURES, id, name, type, packageURI, classifierID, many, containment, idx);
+ DBUtil.insertRow(connection, CDODBSchema.FEATURES, id, classID, featureID, name, type, packageURI, classifierID,
+ many, containment, idx);
}
public void writeRevision(CDORevisionImpl revision)
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/PackageManager.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/PackageManager.java
index 7a0f86e..8aa96b2 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/PackageManager.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/PackageManager.java
@@ -15,10 +15,13 @@ import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageManagerImpl;
import org.eclipse.emf.cdo.server.IPackageManager;
import org.eclipse.emf.cdo.server.IStoreReader;
import org.eclipse.emf.cdo.server.IStoreWriter;
+import org.eclipse.emf.cdo.server.IStoreReader.PackageInfo;
import org.eclipse.net4j.util.transaction.ITransaction;
import org.eclipse.net4j.util.transaction.ITransactionalOperation;
+import java.util.Collection;
+
/**
* @author Eike Stepper
*/
@@ -62,6 +65,18 @@ public class PackageManager extends CDOPackageManagerImpl implements IPackageMan
return null;
}
+ @Override
+ protected void doActivate() throws Exception
+ {
+ super.doActivate();
+ IStoreReader storeReader = repository.getStore().getReader();
+ Collection<PackageInfo> packageInfos = storeReader.readPackageInfos();
+ for (PackageInfo info : packageInfos)
+ {
+ addPackage(new CDOPackageImpl(this, info.getPackageURI(), info.isDynamic(), info.getMetaIDRange()));
+ }
+ }
+
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java
index 54842b8..39fc7c5 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java
@@ -174,21 +174,21 @@ public class Repository extends Container implements IRepository
protected void doActivate() throws Exception
{
super.doActivate();
+ LifecycleUtil.activate(store);
packageManager.activate();
sessionManager.activate();
resourceManager.activate();
revisionManager.activate();
- LifecycleUtil.activate(store);
}
@Override
protected void doDeactivate() throws Exception
{
- LifecycleUtil.deactivate(store);
revisionManager.deactivate();
resourceManager.deactivate();
sessionManager.deactivate();
packageManager.deactivate();
+ LifecycleUtil.deactivate(store);
super.doDeactivate();
}
}
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreReader.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreReader.java
index 464f1d9..3a1b288 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreReader.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/IStoreReader.java
@@ -11,31 +11,21 @@
package org.eclipse.emf.cdo.server;
import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageImpl;
-import org.eclipse.emf.cdo.internal.protocol.model.CDOPackageManagerImpl;
import org.eclipse.emf.cdo.internal.server.StoreUtil;
import org.eclipse.emf.cdo.protocol.CDOID;
import org.eclipse.emf.cdo.protocol.CDOIDRange;
import org.eclipse.emf.cdo.protocol.model.CDOClassRef;
import org.eclipse.emf.cdo.protocol.revision.CDORevision;
+import java.util.Collection;
+
/**
* @see StoreUtil#getReader()
* @author Eike Stepper
*/
public interface IStoreReader extends IStoreAccessor
{
- /**
- * Creates and returns package instances for all packages stored in the
- * repository. This method is called on startup of a repository.
- * <p>
- * <b>Note:</b> The implementor is free to create and return package proxies
- * that are demand loaded at a later point in time.
- * <p>
- *
- * @see CDOPackageImpl#CDOPackageImpl(CDOPackageManagerImpl, String, boolean,
- * CDOIDRange)
- */
- public CDOPackageImpl[] readPackages();
+ public Collection<PackageInfo> readPackageInfos();
/**
* Demand loads a given package proxy that has been created on startup of the
@@ -53,4 +43,16 @@ public interface IStoreReader extends IStoreAccessor
public CDORevision readRevision(CDOID id, long timeStamp);
public CDOClassRef readObjectType(CDOID id);
+
+ /**
+ * @author Eike Stepper
+ */
+ public interface PackageInfo
+ {
+ public String getPackageURI();
+
+ public boolean isDynamic();
+
+ public CDOIDRange getMetaIDRange();
+ }
}
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBSelect.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBSelect.java
new file mode 100644
index 0000000..4ac4460
--- /dev/null
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/DBSelect.java
@@ -0,0 +1,68 @@
+/***************************************************************************
+ * 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.net4j.db;
+
+import org.eclipse.net4j.util.collection.Pair;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ */
+public abstract class DBSelect implements IDBRowHandler
+{
+ private List<IDBField> fields = new ArrayList(0);
+
+ private List<Pair<IDBField, Boolean>> orders = new ArrayList(0);
+
+ private String where;
+
+ public DBSelect(IDBField... fields)
+ {
+ this.fields.addAll(Arrays.asList(fields));
+ }
+
+ public DBSelect field(IDBField field)
+ {
+ fields.add(field);
+ return this;
+ }
+
+ public DBSelect order(IDBField field, boolean asc)
+ {
+ orders.add(new Pair(field, asc));
+ return this;
+ }
+
+ public DBSelect orderAsc(IDBField field)
+ {
+ return order(field, true);
+ }
+
+ public DBSelect orderDesc(IDBField field)
+ {
+ return order(field, false);
+ }
+
+ public DBSelect where()
+ {
+ where = "";
+ return this;
+ }
+
+ public DBSelect whereEq(IDBField field, boolean value)
+ {
+ this.where += where;
+ return this;
+ }
+}
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 0274b3f..47ae48c 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
@@ -169,7 +169,7 @@ public final class DBUtil
}
}
- public static void insert(Connection connection, IDBTable table, Object... args) throws DBException
+ public static void insertRow(Connection connection, IDBTable table, Object... args) throws DBException
{
IDBField[] fields = table.getFields();
if (fields.length != args.length)
@@ -243,4 +243,107 @@ public final class DBUtil
close(statement);
}
}
+
+ public static int select(Connection connection, IDBRowHandler rowHandler, String where, IDBField... fields)
+ throws DBException
+ {
+ IDBTable table = fields[0].getTable();
+ for (int i = 1; i < fields.length; i++)
+ {
+ if (fields[i].getTable() != table)
+ {
+ throw new IllegalArgumentException("Multiple tables not allowed: " + Arrays.asList(fields));
+ }
+ }
+
+ StringBuilder builder = new StringBuilder();
+ builder.append("SELECT ");
+ for (int i = 0; i < fields.length; i++)
+ {
+ if (i > 0)
+ {
+ builder.append(", ");
+ }
+
+ builder.append(fields[i]);
+ }
+
+ builder.append(" FROM ");
+ builder.append(table);
+ if (where != null)
+ {
+ builder.append(" WHERE ");
+ builder.append(where);
+ }
+
+ String sql = builder.toString();
+ if (TRACER.isEnabled())
+ {
+ TRACER.trace(sql);
+ }
+
+ Statement statement = null;
+ ResultSet resultSet = null;
+
+ try
+ {
+ statement = connection.createStatement();
+
+ try
+ {
+ int rows = 0;
+ boolean proceed = true;
+ Object[] values = new Object[fields.length];
+ resultSet = statement.executeQuery(sql);
+ while (proceed && resultSet.next())
+ {
+ for (int i = 0; i < fields.length; i++)
+ {
+ values[i] = resultSet.getObject(i + 1);
+ }
+
+ proceed = rowHandler.handle(rows++, values);
+ }
+
+ return rows;
+ }
+ catch (SQLException ex)
+ {
+ throw new DBException(ex);
+ }
+ finally
+ {
+ close(resultSet);
+ }
+ }
+ catch (SQLException ex)
+ {
+ throw new DBException(ex);
+ }
+ finally
+ {
+ close(statement);
+ }
+ }
+
+ public static int select(Connection connection, IDBRowHandler rowHandler, IDBField... fields) throws DBException
+ {
+ return select(connection, rowHandler, null, fields);
+ }
+
+ public static Object[] select(Connection connection, String where, IDBField... fields) throws DBException
+ {
+ final Object[][] result = new Object[1][];
+ IDBRowHandler rowHandler = new IDBRowHandler()
+ {
+ public boolean handle(int row, Object... values)
+ {
+ result[0] = values;
+ return false;
+ }
+ };
+
+ select(connection, rowHandler, where, fields);
+ return result[0];
+ }
}
diff --git a/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBRowHandler.java b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBRowHandler.java
new file mode 100644
index 0000000..0239e41
--- /dev/null
+++ b/plugins/org.eclipse.net4j.db/src/org/eclipse/net4j/db/IDBRowHandler.java
@@ -0,0 +1,19 @@
+/***************************************************************************
+ * 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.net4j.db;
+
+/**
+ * @author Eike Stepper
+ */
+public interface IDBRowHandler
+{
+ public boolean handle(int row, Object... values);
+}