diff options
Diffstat (limited to 'org.eclipse.osee.framework.db.connection/src/org/eclipse/osee/framework/db/connection/core/query/Query.java')
-rw-r--r-- | org.eclipse.osee.framework.db.connection/src/org/eclipse/osee/framework/db/connection/core/query/Query.java | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/org.eclipse.osee.framework.db.connection/src/org/eclipse/osee/framework/db/connection/core/query/Query.java b/org.eclipse.osee.framework.db.connection/src/org/eclipse/osee/framework/db/connection/core/query/Query.java new file mode 100644 index 00000000000..d27c59e1d79 --- /dev/null +++ b/org.eclipse.osee.framework.db.connection/src/org/eclipse/osee/framework/db/connection/core/query/Query.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * Copyright (c) 2004, 2007 Boeing. + * 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: + * Boeing - initial API and implementation + *******************************************************************************/ +package org.eclipse.osee.framework.db.connection.core.query; + +import java.util.Collection; +import java.util.logging.Level; +import org.eclipse.osee.framework.db.connection.ConnectionHandlerStatement; +import org.eclipse.osee.framework.db.connection.core.RsetProcessor; +import org.eclipse.osee.framework.db.connection.exception.OseeCoreException; +import org.eclipse.osee.framework.db.connection.internal.InternalActivator; +import org.eclipse.osee.framework.logging.OseeLog; + +/** + * @author Robert A. Fisher + */ +public class Query { + + /** + * Builds a collection of items from an SQL statement from the basic DBConnection. + * + * @param collection The collection to add the objects to. + * @param sql The SQL statement to use to acquire a ResultSet. + * @param processor The RsetProcessor used for providing and validating items. + * @param <A> The type of object being placed into the collection. + * @throws OseeCoreException + */ + @Deprecated + // all code that uses this is also Deprecated + public static <A extends Object> void acquireCollection(Collection<A> collection, RsetProcessor<A> processor, String sql, Object... data) throws OseeCoreException { + A item; + ConnectionHandlerStatement chStmt = new ConnectionHandlerStatement(); + try { + chStmt.runPreparedQuery(sql, data); + while (chStmt.next()) { + try { + item = processor.process(chStmt); + if (processor.validate(item)) collection.add(item); + } catch (IllegalStateException ex) { + OseeLog.log(InternalActivator.class, Level.SEVERE, + "Encountered Exception when trying to acquire a collection.", ex); + } + } + } finally { + chStmt.close(); + } + } +}
\ No newline at end of file |