You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by to...@apache.org on 2004/08/01 23:43:36 UTC
cvs commit: jakarta-commons-sandbox/sql/src/java/org/apache/commons/sql/builder MaxDbBuilder.java SqlBuilderFactory.java
tomdz 2004/08/01 14:43:36
Modified: sql/src/java/org/apache/commons/sql/builder
SqlBuilderFactory.java
Added: sql/src/java/org/apache/commons/sql/builder
MaxDbBuilder.java
Log:
Added support for MaxDB, and fixed SapDb handling
Revision Changes Path
1.9 +44 -33 jakarta-commons-sandbox/sql/src/java/org/apache/commons/sql/builder/SqlBuilderFactory.java
Index: SqlBuilderFactory.java
===================================================================
RCS file: /home/cvs/jakarta-commons-sandbox/sql/src/java/org/apache/commons/sql/builder/SqlBuilderFactory.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- SqlBuilderFactory.java 28 Feb 2004 03:35:47 -0000 1.8
+++ SqlBuilderFactory.java 1 Aug 2004 21:43:36 -0000 1.9
@@ -1,3 +1,5 @@
+package org.apache.commons.sql.builder;
+
/*
* Copyright 1999-2002,2004 The Apache Software Foundation.
*
@@ -13,16 +15,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.commons.sql.builder;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
/**
* A factory of SqlBuilder instances based on a case insensitive database name.
*
@@ -30,64 +28,77 @@
* new databases on the classpath.
*
* @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
+ * @author <a href="mailto:tomdz@apache.org">Thomas Dudziak</a>
* @version $Revision$
*/
-public class SqlBuilderFactory {
-
- /** The Log to which logging calls will be made. */
- private static final Log log = LogFactory.getLog(SqlBuilderFactory.class);
-
+public class SqlBuilderFactory
+{
private static Map databases = new HashMap();
-
- static {
+
+ static
+ {
registerDatabases();
}
/**
* Creates a new SqlBuilder for the given (case insensitive) database name
* or returns null if the database is not recognized.
+ *
+ * @param databaseName The name of the database (case is not important)
+ * @return The builder or <code>null</code> if the database is not supported
*/
- public static synchronized SqlBuilder newSqlBuilder(String databaseName)
- throws IllegalAccessException, InstantiationException {
-
- Class theClass = (Class) databases.get(databaseName.toLowerCase());
- if (theClass != null) {
- return (SqlBuilder) theClass.newInstance();
+ public static synchronized SqlBuilder newSqlBuilder(String databaseName) throws IllegalAccessException, InstantiationException
+ {
+ Class builderClass = (Class) databases.get(databaseName.toLowerCase());
+
+ if (builderClass != null)
+ {
+ return (SqlBuilder)builderClass.newInstance();
}
return null;
}
/**
- * @return a List of currently registered database types for which there is a
- * specific SqlBuilder.
+ * Returns a list of all supported databases.
+ *
+ * @return The currently registered database types
*/
- public static synchronized List getDatabaseTypes() {
+ public static synchronized List getDatabaseTypes()
+ {
// return a copy to prevent modification
List answer = new ArrayList();
- answer.addAll( databases.keySet());
+
+ answer.addAll(databases.keySet());
return answer;
}
/**
- * Register the common builders
+ * Registers a builder.
+ *
+ * @param databaseName The database name
+ * @param sqlBuilderClass The builder class
*/
- public static synchronized void registerDatabase(String databaseName, Class sqlBuilderClass) {
+ public static synchronized void registerDatabase(String databaseName, Class sqlBuilderClass)
+ {
databases.put(databaseName.toLowerCase(), sqlBuilderClass);
}
/**
- * Register the common builders
+ * Registers the predefined builders.
*/
- protected static void registerDatabases() {
- registerDatabase("axion", AxionBuilder.class);
- registerDatabase("db2", Db2Builder.class);
- registerDatabase("hsqldb", HsqlDbBuilder.class);
- registerDatabase("mckoi", MckoiSqlBuilder.class);
- registerDatabase("mssql", MSSqlBuilder.class);
- registerDatabase("mysql", MySqlBuilder.class);
- registerDatabase("oracle", OracleBuilder.class);
+ protected static void registerDatabases()
+ {
+ registerDatabase("axion", AxionBuilder.class);
+ registerDatabase("db2", Db2Builder.class);
+ registerDatabase("hsqldb", HsqlDbBuilder.class);
+ registerDatabase("maxdb", MaxDbBuilder.class);
+ registerDatabase("mckoi", MckoiSqlBuilder.class);
+ registerDatabase("mssql", MSSqlBuilder.class);
+ registerDatabase("mysql", MySqlBuilder.class);
+ registerDatabase("oracle", OracleBuilder.class);
registerDatabase("postgresql", PostgreSqlBuilder.class);
- registerDatabase("sybase", SybaseBuilder.class);
+ registerDatabase("sapdb", SapDbBuilder.class);
+ registerDatabase("sybase", SybaseBuilder.class);
}
}
1.1 jakarta-commons-sandbox/sql/src/java/org/apache/commons/sql/builder/MaxDbBuilder.java
Index: MaxDbBuilder.java
===================================================================
package org.apache.commons.sql.builder;
/*
* Copyright 1999-2002,2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* A SQL Builder for MaxDB. Is currently identical to the SapDB builder
* as there is no difference in the SQL we're using.
*
* @author <a href="mailto:tomdz@apache.org">Thomas Dudziak</a>
*/
public class MaxDbBuilder extends SapDbBuilder
{
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org