db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r232530 [1/4] - in /db/ddlutils/trunk/src: java/org/apache/ddlutils/ java/org/apache/ddlutils/builder/ java/org/apache/ddlutils/dynabean/ java/org/apache/ddlutils/io/ java/org/apache/ddlutils/model/ java/org/apache/ddlutils/platform/ java/o...
Date Sat, 13 Aug 2005 21:39:40 GMT
Author: tomdz
Date: Sat Aug 13 14:36:44 2005
New Revision: 232530

URL: http://svn.apache.org/viewcvs?rev=232530&view=rev
Log:
Large scale restructuring:

* new interface Platform and its implementation subsumes and replaces the DynaSql and DDLExecutor classes
  it provides the single interface to peforming operations on a database
* properties of a specific database platform is contained in a PlatformInfo object (formerly in SqlBuilder)
* SqlBuilder now only creates the textual sql, no more db access

Also the old Ant tasks have been removed
Update of the documentation follows

Added:
    db/ddlutils/trunk/src/java/org/apache/ddlutils/DynaSqlException.java
      - copied, changed from r226549, db/ddlutils/trunk/src/java/org/apache/ddlutils/dynabean/DynaSqlException.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/Platform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/PlatformFactory.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/PlatformInfo.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/PlatformUtils.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/MckoiBuilder.java
      - copied, changed from r231306, db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/MckoiSqlBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/dynabean/DynaClassCache.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/AxionPlatform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/CloudscapePlatform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/Db2Platform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/DerbyPlatform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/FirebirdPlatform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/HsqlDbPlatform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/InterbasePlatform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/MSSqlPlatform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/MaxDbPlatform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/MckoiPlatform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/MySqlPlatform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/Oracle8Platform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/Oracle9Platform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PlatformImplBase.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PostgreSqlPlatform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/SapDbPlatform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/SybasePlatform.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/TestPlatformBase.java
      - copied, changed from r226549, db/ddlutils/trunk/src/test/org/apache/ddlutils/TestBuilderBase.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/builder/TestAxionPlatform.java
      - copied, changed from r226549, db/ddlutils/trunk/src/test/org/apache/ddlutils/builder/TestAxionBuilder.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/builder/TestCloudscapePlatform.java
      - copied, changed from r226549, db/ddlutils/trunk/src/test/org/apache/ddlutils/builder/TestCloudscapeBuilder.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/builder/TestDB2Platform.java
      - copied, changed from r226549, db/ddlutils/trunk/src/test/org/apache/ddlutils/builder/TestDB2Builder.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/builder/TestDerbyPlatform.java
      - copied, changed from r226549, db/ddlutils/trunk/src/test/org/apache/ddlutils/builder/TestDerbyBuilder.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/builder/TestFirebirdPlatform.java
      - copied, changed from r226549, db/ddlutils/trunk/src/test/org/apache/ddlutils/builder/TestFirebirdBuilder.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/builder/TestHsqlDbPlatform.java
      - copied, changed from r226549, db/ddlutils/trunk/src/test/org/apache/ddlutils/builder/TestHsqlDbBuilder.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/builder/TestInterbasePlatform.java
      - copied, changed from r226549, db/ddlutils/trunk/src/test/org/apache/ddlutils/builder/TestInterbaseBuilder.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/builder/TestMSSqlPlatform.java
      - copied, changed from r226549, db/ddlutils/trunk/src/test/org/apache/ddlutils/builder/TestMSSqlServerBuilder.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/builder/TestMaxDbPlatform.java
      - copied, changed from r226549, db/ddlutils/trunk/src/test/org/apache/ddlutils/builder/TestMaxDbBuilder.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/builder/TestMcKoiPlatform.java
      - copied, changed from r226549, db/ddlutils/trunk/src/test/org/apache/ddlutils/builder/TestMcKoiBuilder.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/builder/TestMySqlPlatform.java
      - copied, changed from r226549, db/ddlutils/trunk/src/test/org/apache/ddlutils/builder/TestMySqlBuilder.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/builder/TestOracle8Platform.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/builder/TestOracle9Platform.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/builder/TestPostgresqlPlatform.java
      - copied, changed from r226549, db/ddlutils/trunk/src/test/org/apache/ddlutils/builder/TestPostgresqlBuilder.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/builder/TestSapDbPlatform.java
      - copied, changed from r226549, db/ddlutils/trunk/src/test/org/apache/ddlutils/builder/TestSapDbBuilder.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/builder/TestSybasePlatform.java
      - copied, changed from r226549, db/ddlutils/trunk/src/test/org/apache/ddlutils/builder/TestSybaseBuilder.java
Removed:
    db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/BuilderUtils.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/DerbyBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/FirebirdBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/MaxDbBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/MckoiSqlBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/SqlBuilderFactory.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/dynabean/DynaSql.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/dynabean/DynaSqlException.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DDLTask.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DatabaseTask.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/task/JdbcToSchemaTask.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/util/DDLExecutor.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/TestBuilderBase.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/builder/TestAxionBuilder.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/builder/TestCloudscapeBuilder.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/builder/TestDB2Builder.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/builder/TestDerbyBuilder.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/builder/TestFirebirdBuilder.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/builder/TestHsqlDbBuilder.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/builder/TestInterbaseBuilder.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/builder/TestMSSqlServerBuilder.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/builder/TestMaxDbBuilder.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/builder/TestMcKoiBuilder.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/builder/TestMySqlBuilder.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/builder/TestOracleBuilder.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/builder/TestPostgresqlBuilder.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/builder/TestSapDbBuilder.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/builder/TestSybaseBuilder.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/dynabean/AbstractTestDynaSql.java
Modified:
    db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/AxionBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/CloudscapeBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/Db2Builder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/HsqlDbBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/InterbaseBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/MSSqlBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/MySqlBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/OracleBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/PostgreSqlBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/SapDbBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/SqlBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/SybaseBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/dynabean/DynaSqlIterator.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/io/DataReader.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/io/DataToDatabaseSink.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/io/DynaSqlCreateRule.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/model/Database.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DatabaseCommand.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/task/WriteDataToDatabaseCommand.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/task/WriteDataToFileCommand.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/task/WriteDataToSpecifiedDatabaseCommand.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/task/WriteSchemaSqlToFileCommand.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/task/WriteSchemaToDatabaseCommand.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/util/JdbcSupport.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/TestDatabaseWriterBase.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/dynabean/TestDynaSqlQueries.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/io/TestAgainstAxionDb.java

Copied: db/ddlutils/trunk/src/java/org/apache/ddlutils/DynaSqlException.java (from r226549, db/ddlutils/trunk/src/java/org/apache/ddlutils/dynabean/DynaSqlException.java)
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/DynaSqlException.java?p2=db/ddlutils/trunk/src/java/org/apache/ddlutils/DynaSqlException.java&p1=db/ddlutils/trunk/src/java/org/apache/ddlutils/dynabean/DynaSqlException.java&r1=226549&r2=232530&rev=232530&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/dynabean/DynaSqlException.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/DynaSqlException.java Sat Aug 13 14:36:44 2005
@@ -1,4 +1,4 @@
-package org.apache.ddlutils.dynabean;
+package org.apache.ddlutils;
 
 import org.apache.commons.lang.exception.NestableRuntimeException;
 

Added: db/ddlutils/trunk/src/java/org/apache/ddlutils/Platform.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/Platform.java?rev=232530&view=auto
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/Platform.java (added)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/Platform.java Sat Aug 13 14:36:44 2005
@@ -0,0 +1,351 @@
+package org.apache.ddlutils;
+
+/*
+ * Copyright 1999-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.
+ */
+
+import java.sql.Connection;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.sql.DataSource;
+
+import org.apache.commons.beanutils.DynaBean;
+import org.apache.ddlutils.builder.SqlBuilder;
+import org.apache.ddlutils.model.Database;
+
+/**
+ * A platform encapsulates the database-related functionality such as performing queries
+ * and manipulations. It also contains an sql builder that is specific to this platform.
+ * 
+ * @author <a href="mailto:tomdz@apache.org">Thomas Dudziak</a>
+ * @version $Revision: 231110 $
+ */
+public interface Platform
+{
+    /**
+     * Returns the name of the database that this platform is for.
+     * 
+     * @return The database name
+     */
+    public String getDatabaseName();
+
+    /**
+     * Returns the info object for this platform.
+     * 
+     * @return The info object
+     */
+    public PlatformInfo getPlatformInfo();
+    
+    /**
+     * Returns the sql builder for the this database.
+     * 
+     * @return The sql builder
+     */
+    public SqlBuilder getSqlBuilder();
+
+    /**
+     * Returns the data source that this platform uses to access the database.
+     * 
+     * @return The data source
+     */
+    public DataSource getDataSource();
+    
+    /**
+     * Sets the data source that this platform shall use to access the database.
+     * 
+     * @param dataSource The data source
+     */
+    public void setDataSource(DataSource dataSource);
+
+    /**
+     * Returns a (new) JDBC connection from the data source.
+     * 
+     * @return The connection
+     */
+    public Connection borrowConnection() throws DynaSqlException;
+
+    /**
+     * Closes the given JDBC connection (returns it back to the pool if the datasource is poolable).
+     * 
+     * @param connection The connection
+     */
+    public void returnConnection(Connection connection);
+
+    /**
+     * Executes a series of sql statements which must be seperated by the delimiter
+     * configured as {@link PlatformInfo#getSqlCommandDelimiter()} of the info object
+     * of this platform.
+     * 
+     * @param connection      The connection to the database
+     * @param sql             The sql statements to execute
+     * @param continueOnError Whether to continue executing the sql commands when an error occurred
+     * @return The number of errors
+     */
+    public int evaluateBatch(String sql, boolean continueOnError) throws DynaSqlException;
+
+    /**
+     * Executes a series of sql statements which must be seperated by the delimiter
+     * configured as {@link PlatformInfo#getSqlCommandDelimiter()} of the info object
+     * of this platform.
+     *
+     * TODO: consider outputting a collection of String or some kind of statement
+     * object from the SqlBuilder instead of having to parse strings here
+     *
+     * @param connection      The connection to the database
+     * @param sql             The sql statements to execute
+     * @param continueOnError Whether to continue executing the sql commands when an error occurred
+     * @return The number of errors
+     */
+    public int evaluateBatch(Connection connection, String sql, boolean continueOnError) throws DynaSqlException;
+
+    /**
+     * Creates the tables defined in the database model.
+     * 
+     * @param model           The database model
+     * @param dropTablesFirst Whether to drop the tables prior to creating them (anew)
+     * @param continueOnError Whether to continue executing the sql commands when an error occurred
+     */
+    public void createTables(Database model, boolean dropTablesFirst, boolean continueOnError) throws DynaSqlException;
+
+    /**
+     * Creates the tables defined in the database model.
+     * 
+     * @param connection      The connection to the database
+     * @param model           The database model
+     * @param dropTablesFirst Whether to drop the tables prior to creating them (anew)
+     * @param continueOnError Whether to continue executing the sql commands when an error occurred
+     */
+    public void createTables(Connection connection, Database model, boolean dropTablesFirst, boolean continueOnError) throws DynaSqlException;
+
+    /**
+     * Alters the database schema so that it match the given model. Drops and table modifications will
+     * not be made.
+     *
+     * @param desiredDb The desired database schema
+     */
+    public void alterTables(Database desiredDb, boolean continueOnError) throws DynaSqlException;
+
+    /**
+     * Alters the database schema so that it match the given model.
+     *
+     * @param desiredDb     The desired database schema
+     * @param doDrops       Whether columns, tables and indexes should be dropped if not in the
+     *                      new schema
+     * @param modifyColumns Whether columns should be altered for datatype, size as required
+     */
+    public void alterTables(Database desiredDb, boolean doDrops, boolean modifyColumns, boolean continueOnError) throws DynaSqlException;
+
+    /**
+     * Alters the database schema so that it match the given model. Drops and table modifications will
+     * not be made.
+     *
+     * @param connection A connection to the existing database that shall be modified
+     * @param desiredDb  The desired database schema
+     */
+    public void alterTables(Connection connection, Database desiredDb, boolean continueOnError) throws DynaSqlException;
+
+    /**
+     * Alters the database schema so that it match the given model.
+     *
+     * @param connection    A connection to the existing database that shall be modified
+     * @param desiredDb     The desired database schema
+     * @param doDrops       Whether columns, tables and indexes should be dropped if not in the
+     *                      new schema
+     * @param modifyColumns Whether columns should be altered for datatype, size as required
+     */
+    public void alterTables(Connection connection, Database desiredDb, boolean doDrops, boolean modifyColumns, boolean continueOnError) throws DynaSqlException;
+
+    /**
+     * Drops the tables defined in the given database.
+     * 
+     * @param connection      The connection to the database
+     * @param model           The database model
+     * @param continueOnError Whether to continue executing the sql commands when an error occurred
+     */
+    public void dropTables(Database model, boolean continueOnError) throws DynaSqlException;
+
+    /**
+     * Drops the tables defined in the given database.
+     * 
+     * @param connection      The connection to the database
+     * @param model           The database model
+     * @param continueOnError Whether to continue executing the sql commands when an error occurred
+     */
+    public void dropTables(Connection connection, Database model, boolean continueOnError) throws DynaSqlException; 
+
+    /**
+     * Performs the given parameterized SQL query returning an iterator over the results.
+     *
+     * @param model      The database model to use
+     * @param sql        The sql query to perform
+     * @param parameters The query parameter values
+     * @return An iterator for the dyna beans resulting from the query
+     */
+    public Iterator query(Database model, String sql, Collection parameters) throws DynaSqlException;
+
+    /**
+     * Performs the given SQL query returning an iterator over the results.
+     *
+     * @param model The database model to use
+     * @param sql   The sql query to perform
+     * @return An iterator for the dyna beans resulting from the query
+     */
+    public Iterator query(Database model, String sql) throws DynaSqlException;
+
+    /**
+     * Queries for a list of dyna beans representing rows of the given query.
+     * In contrast to the {@link #query(String)} method all beans will be
+     * materialized and the connection will be closed before returning the beans. 
+     * 
+     * @param model The database model to use
+     * @param sql   The sql query
+     * @return The dyna beans resulting from the query
+     */
+    public List fetch(Database model, String sql) throws DynaSqlException;
+
+    /**
+     * Queries for a list of dyna beans representing rows of the given query.
+     * In contrast to the {@link #query(String, Collection)} method all beans will be
+     * materialized and the connection will be closed before returning the beans. 
+     * 
+     * @param sql        The parameterized query
+     * @param parameters The parameter values
+     * @return The dyna beans resulting from the query
+     */
+    public List fetch(Database model, String sql, Collection parameters) throws DynaSqlException;
+
+    /**
+     * Queries for a list of dyna beans representing rows of the given query.
+     * In contrast to the {@link #query(String)} method all beans will be
+     * materialized and the connection will be closed before returning the beans.
+     * Also, the two int parameters specify which rows of the result set to use.
+     * If there are more rows than desired, they will be ignored (and not read
+     * from the database).
+     * 
+     * @param model The database model to use
+     * @param sql   The sql query
+     * @param start Row number to start from (0 for first row)
+     * @param end   Row number to stop at (inclusively; -1 for last row)
+     * @return The dyna beans resulting from the query
+     */
+    public List fetch(Database model, String sql, int start, int end) throws DynaSqlException;
+
+    /**
+     * Queries for a list of dyna beans representing rows of the given query.
+     * In contrast to the {@link #query(String, Collection)} method all beans will be
+     * materialized and the connection will be closed before returning the beans.
+     * Also, the two int parameters specify which rows of the result set to use.
+     * If there are more rows than desired, they will be ignored (and not read
+     * from the database).
+     * 
+     * @param model      The database model to use
+     * @param sql        The parameterized sql query
+     * @param parameters The parameter values
+     * @param start      Row number to start from (0 for first row)
+     * @param end        Row number to stop at (inclusively; -1 for last row)
+     * @return The dyna beans resulting from the query
+     */
+    public List fetch(Database model, String sql, Collection parameters, int start, int end) throws DynaSqlException;
+
+    /**
+     * Stores the given bean in the database, inserting it if there is no primary key
+     * otherwise the bean is updated in the database.
+     * 
+     * @param model    The database model to use
+     * @param dynaBean The bean to store
+     */
+    public void store(Database model, DynaBean dynaBean) throws DynaSqlException;
+
+    /**
+     * Returns the sql for inserting the given bean.
+     * 
+     * @param dynaBean The bean
+     * @return The insert sql
+     */
+    public String getInsertSql(Database model, DynaBean dynaBean);
+
+    /**
+     * Inserts the given DynaBean in the database, assuming the primary key values are specified.
+     * 
+     * @param model    The database model to use
+     * @param dynaBean The bean to insert
+     */
+    public void insert(Database model, DynaBean dynaBean) throws DynaSqlException;
+
+    /**
+     * Inserts the bean. If one of the columns is an auto-incremented column, then the
+     * bean will also be updated with the column value generated by the database.
+     * Note that the connection will not be closed by this method.
+     * 
+     * @param model      The database model to use
+     * @param dynaBean   The bean
+     * @param connection The database connection
+     */
+    public void insert(Database model, DynaBean dynaBean, Connection connection) throws DynaSqlException;
+
+    /**
+     * Returns the sql for updating the given bean in the database.
+     * 
+     * @param model    The database model to use
+     * @param dynaBean The bean
+     * @return The update sql
+     */
+    public String getUpdateSql(Database model, DynaBean dynaBean);
+
+    /**
+     * Updates the given bean in the database, assuming the primary key values are specified.
+     * 
+     * @param model    The database model to use
+     * @param dynaBean The bean
+     */
+    public void update(Database model, DynaBean dynaBean) throws DynaSqlException;
+
+    /**
+     * Updates the row which maps to the given bean.
+     * 
+     * @param model      The database model to use
+     * @param dynaBean   The bean
+     * @param connection The database connection
+     */
+    public void update(Database model, DynaBean dynaBean, Connection connection) throws DynaSqlException;
+
+    /**
+     * Returns the sql for deleting the given bean from the database.
+     * 
+     * @param model    The database model to use
+     * @param dynaBean The bean
+     * @return The sql
+     */
+    public String getDeleteSql(Database model, DynaBean dynaBean);
+
+    /**
+     * Deletes the given bean from the database, assuming the primary key values are specified.
+     * 
+     * @param model    The database model to use
+     * @param dynaBean The bean to delete
+     */
+    public void delete(Database model, DynaBean dynaBean) throws DynaSqlException;
+
+    /**
+     * Deletes the row which maps to the given bean from the database.
+     * 
+     * @param model      The database model to use
+     * @param dynaBean   The bean
+     * @param connection The database connection
+     */
+    public void delete(Database model, DynaBean dynaBean, Connection connection) throws DynaSqlException;
+}

Added: db/ddlutils/trunk/src/java/org/apache/ddlutils/PlatformFactory.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/PlatformFactory.java?rev=232530&view=auto
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/PlatformFactory.java (added)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/PlatformFactory.java Sat Aug 13 14:36:44 2005
@@ -0,0 +1,126 @@
+package org.apache.ddlutils;
+
+/*
+ * 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.
+ */
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.ddlutils.platform.AxionPlatform;
+import org.apache.ddlutils.platform.CloudscapePlatform;
+import org.apache.ddlutils.platform.Db2Platform;
+import org.apache.ddlutils.platform.DerbyPlatform;
+import org.apache.ddlutils.platform.FirebirdPlatform;
+import org.apache.ddlutils.platform.HsqlDbPlatform;
+import org.apache.ddlutils.platform.InterbasePlatform;
+import org.apache.ddlutils.platform.MSSqlPlatform;
+import org.apache.ddlutils.platform.MaxDbPlatform;
+import org.apache.ddlutils.platform.MckoiPlatform;
+import org.apache.ddlutils.platform.MySqlPlatform;
+import org.apache.ddlutils.platform.Oracle8Platform;
+import org.apache.ddlutils.platform.Oracle9Platform;
+import org.apache.ddlutils.platform.PostgreSqlPlatform;
+import org.apache.ddlutils.platform.SapDbPlatform;
+import org.apache.ddlutils.platform.SybasePlatform;
+
+/**
+ * A factory of {@link org.apache.ddlutils.Platform} instances based on a case
+ * insensitive database name. Note that this is a convenience class as the platforms
+ * can also simply be created via their constructors.
+ * 
+ * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
+ * @author <a href="mailto:tomdz@apache.org">Thomas Dudziak</a>
+ * @version $Revision: 209952 $
+ */
+public class PlatformFactory
+{
+    /** The database name -> platform map */
+    private static Map _platforms = new HashMap();
+
+    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 Platform createNewPlatformInstance(String databaseName) throws IllegalAccessException, InstantiationException
+    {
+        Class platformClass = (Class)_platforms.get(databaseName.toLowerCase());
+
+        return platformClass != null ? (Platform)platformClass.newInstance() : null;
+    }
+
+    /**
+     * Returns a list of all supported databases.
+     * 
+     * @return The currently registered database types
+     */
+    public static synchronized List getDatabaseTypes()
+    {
+        // return a copy to prevent modification
+        List answer = new ArrayList();
+
+        answer.addAll(_platforms.keySet());
+        return answer;
+    }
+
+
+    /**
+     * Registers a new platform.
+     * 
+     * @param databaseName  The database name
+     * @param platformClass The platform class which must implement the {@link Platform} interface
+     */
+    public static synchronized void registerDatabase(String databaseName, Class platformClass)
+    {
+        if (!Platform.class.isAssignableFrom(platformClass))
+        {
+            throw new IllegalArgumentException("Cannot register class "+platformClass.getName()+" because it does not implement the "+Platform.class.getName()+" interface");
+        }
+        _platforms.put(databaseName.toLowerCase(), platformClass);        
+    }
+
+    /**
+     * Registers the predefined builders.
+     */
+    protected static void registerDatabases()
+    {
+        registerDatabase(AxionPlatform.DATABASENAME,      AxionPlatform.class);
+        registerDatabase(CloudscapePlatform.DATABASENAME, CloudscapePlatform.class);
+        registerDatabase(Db2Platform.DATABASENAME,        Db2Platform.class);
+        registerDatabase(DerbyPlatform.DATABASENAME,      DerbyPlatform.class);
+        registerDatabase(FirebirdPlatform.DATABASENAME,   FirebirdPlatform.class);
+        registerDatabase(HsqlDbPlatform.DATABASENAME,     HsqlDbPlatform.class);
+        registerDatabase(InterbasePlatform.DATABASENAME,  InterbasePlatform.class);
+        registerDatabase(MaxDbPlatform.DATABASENAME,      MaxDbPlatform.class);
+        registerDatabase(MckoiPlatform.DATABASENAME,      MckoiPlatform.class);
+        registerDatabase(MSSqlPlatform.DATABASENAME,      MSSqlPlatform.class);
+        registerDatabase(MySqlPlatform.DATABASENAME,      MySqlPlatform.class);
+        registerDatabase(Oracle8Platform.DATABASENAME,    Oracle8Platform.class);
+        registerDatabase(Oracle9Platform.DATABASENAME,    Oracle9Platform.class);
+        registerDatabase(PostgreSqlPlatform.DATABASENAME, PostgreSqlPlatform.class);
+        registerDatabase(SapDbPlatform.DATABASENAME,      SapDbPlatform.class);
+        registerDatabase(SybasePlatform.DATABASENAME,     SybasePlatform.class);
+    }
+}

Added: db/ddlutils/trunk/src/java/org/apache/ddlutils/PlatformInfo.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/PlatformInfo.java?rev=232530&view=auto
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/PlatformInfo.java (added)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/PlatformInfo.java Sat Aug 13 14:36:44 2005
@@ -0,0 +1,386 @@
+package org.apache.ddlutils;
+
+import java.lang.reflect.Field;
+import java.sql.Types;
+import java.util.HashMap;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Conatains information about the database platform such as supported features and native type mappings.
+ */
+public class PlatformInfo
+{
+    /** The Log to which logging calls will be made. */
+    private final Log _log = LogFactory.getLog(PlatformInfo.class);
+
+    /** Whether the database requires the explicit stating of NULL as the default value */
+    private boolean _requiringNullAsDefaultValue = false;
+
+    /** Whether primary key constraints are embedded inside the create table statement */
+    private boolean _primaryKeyEmbedded = true;
+    
+    /** Whether foreign key constraints are embedded inside the create table statement */
+    private boolean _foreignKeysEmbedded = false;
+
+    /** Whether indices are embedded inside the create table statement */
+    private boolean _indicesEmbedded = false;
+
+    /** Whether embedded foreign key constraints are explicitly named */
+    private boolean _embeddedForeignKeysNamed = false;
+
+    /** Is an ALTER TABLE needed to drop indexes? */
+    private boolean _useAlterTableForDrop = false;
+
+    /** Specifies the maximum length that an identifier (name of a table, column, constraint etc.)
+     *  can have for this database; use -1 if there is no limit */
+    private int _maxIdentifierLength = -1;
+
+    /** Whether identifiers are case sensitive or not */
+    private boolean _caseSensitive = false;
+
+    /** The string used for escaping values when generating textual SQL statements */
+    private String _valueQuoteChar = "'";
+
+    /** Whether comments are supported */
+    private boolean _commentsSupported = true;
+
+    /** The string that starts a comment */
+    private String _commentPrefix = "--";
+
+    /** The string that ends a comment */
+    private String _commentSuffix = "";
+
+    /** The text separating individual sql commands */
+    private String _sqlCommandDelimiter = ";";
+
+    /** Contains non-default mappings from jdbc to native types */
+    private HashMap _nativeTypes = new HashMap();
+
+    /**
+     * Determines whether a NULL needs to be explicitly stated when the column
+     * has no specified default value. Default is false.
+     * 
+     * @return <code>true</code> if NULL must be written for empty default values
+     */
+    public boolean isRequiringNullAsDefaultValue()
+    {
+        return _requiringNullAsDefaultValue;
+    }
+    /**
+     * Specifies whether a NULL needs to be explicitly stated when the column
+     * has no specified default value. Default is false.
+     *
+     * @param requiresNullAsDefaultValue Whether NULL must be written for empty
+     *                                   default values
+     */
+    public void setRequiringNullAsDefaultValue(boolean requiresNullAsDefaultValue)
+    {
+        _requiringNullAsDefaultValue = requiresNullAsDefaultValue;
+    }
+
+    /**
+     * Determines whether primary key constraints are embedded in the create 
+     * table clause or as seperate alter table statements. The default is
+     * embedded pks.
+     * 
+     * @return <code>true</code> if pk constraints are embedded
+     */
+    public boolean isPrimaryKeyEmbedded()
+    {
+        return _primaryKeyEmbedded;
+    }
+
+    /**
+     * Specifies whether the primary key constraints are embedded in the create 
+     * table clause or as seperate alter table statements.
+     * 
+     * @param primaryKeyEmbedded Whether pk constraints are embedded
+     */
+    public void setPrimaryKeyEmbedded(boolean primaryKeyEmbedded)
+    {
+        _primaryKeyEmbedded = primaryKeyEmbedded;
+    }
+
+    /**
+     * Determines whether foreign key constraints are embedded in the create 
+     * table clause or as seperate alter table statements. Per default,
+     * foreign keys are external.
+     * 
+     * @return <code>true</code> if fk constraints are embedded
+     */
+    public boolean isForeignKeysEmbedded()
+    {
+        return _foreignKeysEmbedded;
+    }
+
+    /**
+     * Specifies whether foreign key constraints are embedded in the create 
+     * table clause or as seperate alter table statements.
+     * 
+     * @param foreignKeysEmbedded Whether fk constraints are embedded
+     */
+    public void setForeignKeysEmbedded(boolean foreignKeysEmbedded)
+    {
+        _foreignKeysEmbedded = foreignKeysEmbedded;
+    }
+
+    /**
+     * Determines whether the indices are embedded in the create table clause
+     * or as seperate statements. Per default, indices are external.
+     * 
+     * @return <code>true</code> if indices are embedded
+     */
+    public boolean isIndicesEmbedded()
+    {
+        return _indicesEmbedded;
+    }
+
+    /**
+     * Specifies whether indices are embedded in the create table clause or
+     * as seperate alter table statements.
+     * 
+     * @param indicesEmbedded Whether indices are embedded
+     */
+    public void setIndicesEmbedded(boolean indicesEmbedded)
+    {
+        _indicesEmbedded = indicesEmbedded;
+    }
+
+    /**
+     * Returns whether embedded foreign key constraints should have a name.
+     * 
+     * @return <code>true</code> if embedded fks have name
+     */
+    public boolean isEmbeddedForeignKeysNamed()
+    {
+        return _embeddedForeignKeysNamed;
+    }
+
+    /**
+     * Specifies whether embedded foreign key constraints should be named.
+     * 
+     * @param embeddedForeignKeysNamed Whether embedded fks shall have a name
+     */
+    public void setEmbeddedForeignKeysNamed(boolean embeddedForeignKeysNamed)
+    {
+        _embeddedForeignKeysNamed = embeddedForeignKeysNamed;
+    }
+
+    /**
+     * Determines whether an ALTER TABLE statement shall be used for dropping indices
+     * or constraints.  The default is false.
+     * 
+     * @return <code>true</code> if ALTER TABLE is required
+     */
+    public boolean isUseAlterTableForDrop()
+    {
+        return _useAlterTableForDrop;
+    }
+
+    /**
+     * Specifies whether an ALTER TABLE statement shall be used for dropping indices
+     * or constraints.
+     * 
+     * @param useAlterTableForDrop Whether ALTER TABLE will be used
+     */
+    public void setUseAlterTableForDrop(boolean useAlterTableForDrop)
+    {
+        _useAlterTableForDrop = useAlterTableForDrop;
+    }
+
+    /**
+     * Returns the maximum length of identifiers that this database allows.
+     * 
+     * @return The maximum identifier length, -1 if unlimited
+     */
+    public int getMaxIdentifierLength()
+    {
+        return _maxIdentifierLength;
+    }
+
+    /**
+     * Sets the maximum length of identifiers that this database allows.
+     * 
+     * @param maxIdentifierLength The maximum identifier length, -1 if unlimited
+     */
+    public void setMaxIdentifierLength(int maxIdentifierLength)
+    {
+        _maxIdentifierLength = maxIdentifierLength;
+    }
+
+    /**
+     * Determines whether the database has case sensitive identifiers.
+     *
+     * @return <code>true</code> if case of the the identifiers is important
+     */
+    public boolean isCaseSensitive()
+    {
+        return _caseSensitive;
+    }
+
+    /**
+     * Specifies whether the database has case sensitive identifiers.
+     *
+     * @param caseSensitive <code>true</code> if case of the the identifiers is important
+     */
+    public void setCaseSensitive(boolean caseSensitive)
+    {
+        _caseSensitive = caseSensitive;
+    }
+
+    /**
+     * Returns the text that is used for for quoting values (e.g. text) when
+     * printing default values and in generates insert/update/delete statements.
+     * 
+     * @return The quote text
+     */
+    public String getValueQuoteChar()
+    {
+        return _valueQuoteChar;
+    }
+
+    /**
+     * Sets the text that is used for for quoting values (e.g. text) when
+     * printing default values and in generates insert/update/delete statements.
+     *
+     * @param valueQuoteChar The new quote text
+     */
+    public void setValueQuoteChar(String valueQuoteChar)
+    {
+        _valueQuoteChar = valueQuoteChar;
+    }
+
+    /**
+     * Determines whether the database supports comments.
+     *
+     * @return <code>true</code> if comments are supported
+     */
+    public boolean isCommentsSupported()
+    {
+        return _commentsSupported;
+    }
+
+    /**
+     * Specifies whether comments are supported by the database.
+     * 
+     * @param commentsSupported <code>true</code> if comments are supported
+     */
+    public void setCommentsSupported(boolean commentsSupported)
+    {
+        _commentsSupported = commentsSupported;
+    }
+
+    /**
+     * Returns the string that denotes the beginning of a comment.
+     *
+     * @return The comment prefix
+     */
+    public String getCommentPrefix()
+    {
+        return _commentPrefix;
+    }
+
+    /**
+     * Sets the text that starts a comment.
+     * 
+     * @param commentPrefix The new comment prefix
+     */
+    public void setCommentPrefix(String commentPrefix)
+    {
+        _commentPrefix = (commentPrefix == null ? "" : commentPrefix);
+    }
+
+    /**
+     * Returns the string that denotes the end of a comment. Note that comments will
+     * be always on their own line.
+     *
+     * @return The comment suffix
+     */
+    public String getCommentSuffix()
+    {
+        return _commentSuffix;
+    }
+
+    /**
+     * Sets the text that ends a comment.
+     * 
+     * @param commentSuffix The new comment suffix
+     */
+    public void setCommentSuffix(String commentSuffix)
+    {
+        _commentSuffix = (commentSuffix == null ? "" : commentSuffix);
+    }
+
+    /**
+     * Returns the text separating individual sql commands.
+     *
+     * @return The delimiter text
+     */
+    public String getSqlCommandDelimiter()
+    {
+        return _sqlCommandDelimiter;
+    }
+
+    /**
+     * Sets the text separating individual sql commands.
+     *
+     * @param sqlCommandDelimiter The delimiter text
+     */
+    public void setSqlCommandDelimiter(String sqlCommandDelimiter)
+    {
+        _sqlCommandDelimiter = sqlCommandDelimiter;
+    }
+
+    /**
+     * Adds a mapping from jdbc type to database-native type.
+     * 
+     * @param jdbcTypeCode The jdbc type code as defined by {@link java.sql.Types}
+     * @param nativeType   The native type
+     */
+    public void addNativeTypeMapping(int jdbcTypeCode, String nativeType)
+    {
+        _nativeTypes.put(new Integer(jdbcTypeCode), nativeType);
+    }
+
+    /**
+     * Adds a mapping from jdbc type to database-native type. Note that this
+     * method accesses the named constant in {@link java.sql.Types} via reflection
+     * and is thus safe to use under JDK 1.2/1.3 even with constants defined
+     * only in later Java versions - for these, the method simply will not add
+     * a mapping.
+     * 
+     * @param jdbcTypeName The jdbc type name, one of the constants defined in
+     *                     {@link java.sql.Types}
+     * @param nativeType   The native type
+     */
+    public void addNativeTypeMapping(String jdbcTypeName, String nativeType)
+    {
+        try
+        {
+            Field constant = Types.class.getField(jdbcTypeName);
+
+            if (constant != null)
+            {
+                addNativeTypeMapping(constant.getInt(null), nativeType);
+            }
+        }
+        catch (Exception ex)
+        {
+            // ignore -> won't be defined
+            _log.warn("Cannot add native type mapping for undefined jdbc type "+jdbcTypeName, ex);
+        }
+    }
+
+    /**
+     * Returns the database-native type for the given type code.
+     * 
+     * @param typeCode The {@link java.sql.Types} type code
+     * @return The native type or <code>null</code> if there isn't one defined
+     */
+    public String getNativeType(int typeCode)
+    {
+        return (String)_nativeTypes.get(new Integer(typeCode));
+    }
+}

Added: db/ddlutils/trunk/src/java/org/apache/ddlutils/PlatformUtils.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/PlatformUtils.java?rev=232530&view=auto
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/PlatformUtils.java (added)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/PlatformUtils.java Sat Aug 13 14:36:44 2005
@@ -0,0 +1,250 @@
+package org.apache.ddlutils;
+
+/*
+ * Copyright 1999-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.
+ */
+
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.SQLException;
+import java.util.HashMap;
+
+import javax.sql.DataSource;
+
+import org.apache.ddlutils.platform.AxionPlatform;
+import org.apache.ddlutils.platform.Db2Platform;
+import org.apache.ddlutils.platform.DerbyPlatform;
+import org.apache.ddlutils.platform.FirebirdPlatform;
+import org.apache.ddlutils.platform.HsqlDbPlatform;
+import org.apache.ddlutils.platform.InterbasePlatform;
+import org.apache.ddlutils.platform.MSSqlPlatform;
+import org.apache.ddlutils.platform.MaxDbPlatform;
+import org.apache.ddlutils.platform.MckoiPlatform;
+import org.apache.ddlutils.platform.MySqlPlatform;
+import org.apache.ddlutils.platform.Oracle8Platform;
+import org.apache.ddlutils.platform.PostgreSqlPlatform;
+import org.apache.ddlutils.platform.SapDbPlatform;
+import org.apache.ddlutils.platform.SybasePlatform;
+
+/**
+ * Utility functions for dealing with the database platforms.
+ */
+public class PlatformUtils
+{
+    // Extended drivers that support more than one database
+
+    /** The i-net DB2 jdbc driver */
+    public static final String JDBC_DRIVER_INET_DB2              = "com.inet.drda.DRDADriver";
+    /** The i-net Oracle jdbc driver */
+    public static final String JDBC_DRIVER_INET_ORACLE           = "com.inet.ora.OraDriver";
+    /** The i-net SQLServer jdbc driver */
+    public static final String JDBC_DRIVER_INET_SQLSERVER        = "com.inet.tds.TdsDriver";
+    /** The i-net Sybase jdbc driver */
+    public static final String JDBC_DRIVER_INET_SYBASE           = "com.inet.syb.SybDriver";
+    /** The i-net pooled jdbc driver for SQLServer and Sybase */
+    public static final String JDBC_DRIVER_INET_POOLED           = "com.inet.pool.PoolDriver";
+    /** The JNetDirect SQLServer jdbc driver */
+    public static final String JDBC_DRIVER_JSQLCONNECT_SQLSERVER = "com.jnetdirect.jsql.JSQLDriver";
+    /** The jTDS jdbc driver for SQLServer and Sybase */
+    public static final String JDBC_DRIVER_JTDS                  = "net.sourceforge.jtds.jdbc.Driver";
+
+    /** The subprotocol used by the i-net DB2 driver */
+    public static final String JDBC_SUBPROTOCOL_INET_DB2                = "inetdb2";
+    /** The subprotocol used by the i-net Oracle driver */
+    public static final String JDBC_SUBPROTOCOL_INET_ORACLE             = "inetora";
+    /** A subprotocol used by the i-net SQLServer driver */
+    public static final String JDBC_SUBPROTOCOL_INET_SQLSERVER          = "inetdae";
+    /** A subprotocol used by the i-net SQLServer driver */
+    public static final String JDBC_SUBPROTOCOL_INET_SQLSERVER6         = "inetdae6";
+    /** A subprotocol used by the i-net SQLServer driver */
+    public static final String JDBC_SUBPROTOCOL_INET_SQLSERVER7         = "inetdae7";
+    /** A subprotocol used by the i-net SQLServer driver */
+    public static final String JDBC_SUBPROTOCOL_INET_SQLSERVER7A        = "inetdae7a";
+    /** A subprotocol used by the pooled i-net SQLServer driver */
+    public static final String JDBC_SUBPROTOCOL_INET_SQLSERVER_POOLED   = "inetpool:inetdae";
+    /** A subprotocol used by the pooled i-net SQLServer driver */
+    public static final String JDBC_SUBPROTOCOL_INET_SQLSERVER6_POOLED  = "inetpool:inetdae6";
+    /** A subprotocol used by the pooled i-net SQLServer driver */
+    public static final String JDBC_SUBPROTOCOL_INET_SQLSERVER7_POOLED  = "inetpool:inetdae7";
+    /** A subprotocol used by the pooled i-net SQLServer driver */
+    public static final String JDBC_SUBPROTOCOL_INET_SQLSERVER7A_POOLED = "inetpool:inetdae7a";
+    /** The subprotocol used by the i-net Sybase driver */
+    public static final String JDBC_SUBPROTOCOL_INET_SYBASE             = "inetsyb";
+    /** The subprotocol used by the pooled i-net Sybase driver */
+    public static final String JDBC_SUBPROTOCOL_INET_SYBASE_POOLED      = "inetpool:inetsyb";
+    /** The subprotocol used by the JNetDirect SQLServer driver */
+    public static final String JDBC_SUBPROTOCOL_JSQLCONNECT_SQLSERVER   = "JSQLConnect";
+    /** The subprotocol used by the jTDS SQLServer driver */
+    public static final String JDBC_SUBPROTOCOL_JTDS_SQLSERVER          = "jtds:sqlserver";
+    /** The subprotocol used by the jTDS Sybase driver */
+    public static final String JDBC_SUBPROTOCOL_JTDS_SYBASE             = "jtds:sybase";
+
+    /** Maps the sub-protocl part of a jdbc connection url to a OJB platform name */
+    private HashMap jdbcSubProtocolToPlatform = new HashMap();
+    /** Maps the jdbc driver name to a OJB platform name */
+    private HashMap jdbcDriverToPlatform      = new HashMap();
+
+    /**
+     * Creates a new instance.
+     */
+    public PlatformUtils()
+    {
+        // Note that currently Sapdb and MaxDB have equal subprotocols and
+        // drivers so we have no means to distinguish them
+        jdbcSubProtocolToPlatform.put(AxionPlatform.JDBC_SUBPROTOCOL,                         AxionPlatform.DATABASENAME);
+        jdbcSubProtocolToPlatform.put(Db2Platform.JDBC_SUBPROTOCOL,                           Db2Platform.DATABASENAME);
+        jdbcSubProtocolToPlatform.put(PlatformUtils.JDBC_SUBPROTOCOL_INET_DB2,                Db2Platform.DATABASENAME);
+        jdbcSubProtocolToPlatform.put(DerbyPlatform.JDBC_SUBPROTOCOL,                         DerbyPlatform.DATABASENAME);
+        jdbcSubProtocolToPlatform.put(FirebirdPlatform.JDBC_SUBPROTOCOL,                      FirebirdPlatform.DATABASENAME);
+        jdbcSubProtocolToPlatform.put(HsqlDbPlatform.JDBC_SUBPROTOCOL,                        HsqlDbPlatform.DATABASENAME);
+        jdbcSubProtocolToPlatform.put(InterbasePlatform.JDBC_SUBPROTOCOL,                     InterbasePlatform.DATABASENAME);
+        jdbcSubProtocolToPlatform.put(SapDbPlatform.JDBC_SUBPROTOCOL,                         MaxDbPlatform.DATABASENAME);
+        jdbcSubProtocolToPlatform.put(MckoiPlatform.JDBC_SUBPROTOCOL,                         MckoiPlatform.DATABASENAME);
+        jdbcSubProtocolToPlatform.put(MSSqlPlatform.JDBC_SUBPROTOCOL,                         MSSqlPlatform.DATABASENAME);
+        jdbcSubProtocolToPlatform.put(PlatformUtils.JDBC_SUBPROTOCOL_INET_SQLSERVER,          MSSqlPlatform.DATABASENAME);
+        jdbcSubProtocolToPlatform.put(PlatformUtils.JDBC_SUBPROTOCOL_INET_SQLSERVER6,         MSSqlPlatform.DATABASENAME);
+        jdbcSubProtocolToPlatform.put(PlatformUtils.JDBC_SUBPROTOCOL_INET_SQLSERVER7,         MSSqlPlatform.DATABASENAME);
+        jdbcSubProtocolToPlatform.put(PlatformUtils.JDBC_SUBPROTOCOL_INET_SQLSERVER7A,        MSSqlPlatform.DATABASENAME);
+        jdbcSubProtocolToPlatform.put(PlatformUtils.JDBC_SUBPROTOCOL_INET_SQLSERVER_POOLED,   MSSqlPlatform.DATABASENAME);
+        jdbcSubProtocolToPlatform.put(PlatformUtils.JDBC_SUBPROTOCOL_INET_SQLSERVER6_POOLED,  MSSqlPlatform.DATABASENAME);
+        jdbcSubProtocolToPlatform.put(PlatformUtils.JDBC_SUBPROTOCOL_INET_SQLSERVER7_POOLED,  MSSqlPlatform.DATABASENAME);
+        jdbcSubProtocolToPlatform.put(PlatformUtils.JDBC_SUBPROTOCOL_INET_SQLSERVER7A_POOLED, MSSqlPlatform.DATABASENAME);
+        jdbcSubProtocolToPlatform.put(PlatformUtils.JDBC_SUBPROTOCOL_JTDS_SQLSERVER,          MSSqlPlatform.DATABASENAME);
+        jdbcSubProtocolToPlatform.put(MySqlPlatform.JDBC_SUBPROTOCOL,                         MySqlPlatform.DATABASENAME);
+        jdbcSubProtocolToPlatform.put(Oracle8Platform.JDBC_SUBPROTOCOL,                       Oracle8Platform.DATABASENAME);
+        jdbcSubProtocolToPlatform.put(PlatformUtils.JDBC_SUBPROTOCOL_INET_ORACLE,             Oracle8Platform.DATABASENAME);
+        jdbcSubProtocolToPlatform.put(PostgreSqlPlatform.JDBC_SUBPROTOCOL,                    PostgreSqlPlatform.DATABASENAME);
+        jdbcSubProtocolToPlatform.put(SybasePlatform.JDBC_SUBPROTOCOL,                        SybasePlatform.DATABASENAME);
+        jdbcSubProtocolToPlatform.put(PlatformUtils.JDBC_SUBPROTOCOL_INET_SYBASE,             SybasePlatform.DATABASENAME);
+        jdbcSubProtocolToPlatform.put(PlatformUtils.JDBC_SUBPROTOCOL_INET_SYBASE_POOLED,      SybasePlatform.DATABASENAME);
+        jdbcSubProtocolToPlatform.put(PlatformUtils.JDBC_SUBPROTOCOL_JTDS_SYBASE,             SybasePlatform.DATABASENAME);
+
+        jdbcDriverToPlatform.put(AxionPlatform.JDBC_DRIVER,                       AxionPlatform.DATABASENAME);
+        jdbcDriverToPlatform.put(Db2Platform.JDBC_DRIVER,                         Db2Platform.DATABASENAME);
+        jdbcDriverToPlatform.put(PlatformUtils.JDBC_DRIVER_INET_DB2,              Db2Platform.DATABASENAME);
+        jdbcDriverToPlatform.put(DerbyPlatform.JDBC_DRIVER_EMBEDDED,              DerbyPlatform.DATABASENAME);
+        jdbcDriverToPlatform.put(DerbyPlatform.JDBC_DRIVER,                       DerbyPlatform.DATABASENAME);
+        jdbcDriverToPlatform.put(FirebirdPlatform.JDBC_DRIVER,                    FirebirdPlatform.DATABASENAME);
+        jdbcDriverToPlatform.put(HsqlDbPlatform.JDBC_DRIVER,                      HsqlDbPlatform.DATABASENAME);
+        jdbcDriverToPlatform.put(InterbasePlatform.JDBC_DRIVER,                   InterbasePlatform.DATABASENAME);
+        jdbcDriverToPlatform.put(SapDbPlatform.JDBC_DRIVER,                       MaxDbPlatform.DATABASENAME);
+        jdbcDriverToPlatform.put(MckoiPlatform.JDBC_DRIVER,                       MckoiPlatform.DATABASENAME);
+        jdbcDriverToPlatform.put(MSSqlPlatform.JDBC_DRIVER,                       MSSqlPlatform.DATABASENAME);
+        jdbcDriverToPlatform.put(PlatformUtils.JDBC_DRIVER_INET_SQLSERVER,        MSSqlPlatform.DATABASENAME);
+        jdbcDriverToPlatform.put(PlatformUtils.JDBC_DRIVER_JSQLCONNECT_SQLSERVER, MSSqlPlatform.DATABASENAME);
+        jdbcDriverToPlatform.put(MySqlPlatform.JDBC_DRIVER,                       MySqlPlatform.DATABASENAME);
+        jdbcDriverToPlatform.put(MySqlPlatform.JDBC_DRIVER_OLD,                   MySqlPlatform.DATABASENAME);
+        jdbcDriverToPlatform.put(Oracle8Platform.JDBC_DRIVER,                     Oracle8Platform.DATABASENAME);
+        jdbcDriverToPlatform.put(PlatformUtils.JDBC_DRIVER_INET_ORACLE,           Oracle8Platform.DATABASENAME);
+        jdbcDriverToPlatform.put(PostgreSqlPlatform.JDBC_DRIVER,                  PostgreSqlPlatform.DATABASENAME);
+        jdbcDriverToPlatform.put(SybasePlatform.JDBC_DRIVER,                      SybasePlatform.DATABASENAME);
+        jdbcDriverToPlatform.put(SybasePlatform.JDBC_DRIVER_OLD,                  SybasePlatform.DATABASENAME);
+        jdbcDriverToPlatform.put(PlatformUtils.JDBC_DRIVER_INET_SYBASE,           SybasePlatform.DATABASENAME);
+    }
+
+    /**
+     * Tries to determine the database type for the given data source. Note that this will establish
+     * a connection to the database.
+     * 
+     * @param dataSource The data source
+     * @return The database type or <code>null</code> if the database type couldn't be determined
+     */
+    public String determineDatabaseType(DataSource dataSource) throws DynaSqlException
+    {
+        Connection connection = null;
+
+        try
+        {
+            connection = dataSource.getConnection();
+            
+            DatabaseMetaData metaData = connection.getMetaData();
+
+            return determineDatabaseType(metaData.getDriverName(), metaData.getURL());
+        }
+        catch (SQLException ex)
+        {
+            throw new DynaSqlException("Error while reading the database metadata", ex);
+        }
+        finally
+        {
+            if (connection != null)
+            {
+                try
+                {
+                    connection.close();
+                }
+                catch (SQLException ex)
+                {
+                    // we ignore this one
+                }
+            }
+        }
+    }
+
+    /**
+     * Tries to determine the database type for the given jdbc driver and connection url.
+     * 
+     * @param driverClassName   The fully qualified name of the JDBC driver 
+     * @param jdbcConnectionUrl The connection url
+     * @return The database type or <code>null</code> if the database type couldn't be determined
+     */
+    public String determineDatabaseType(String driverName, String jdbcConnectionUrl)
+    {
+        if (jdbcDriverToPlatform.containsKey(driverName))
+        {
+            return (String)jdbcDriverToPlatform.get(driverName);
+        }
+        if (jdbcConnectionUrl == null)
+        {
+            return null;
+        }
+
+        int pos     = jdbcConnectionUrl.indexOf(':');
+        int lastPos = pos;
+
+        // we're skipping over the 'jdbc'
+        lastPos = pos;
+        pos     = jdbcConnectionUrl.indexOf(':', lastPos + 1);
+
+        String subProtocol = jdbcConnectionUrl.substring(lastPos + 1, pos);
+
+        // there are a few jdbc drivers that have a subprotocol containing one or more ':'
+        if ("inetpool".equals(subProtocol))
+        {
+            // Possible forms are:
+            //   inetpool:<subprotocol>
+            //   inetpool:jdbc:<subprotocol>   (where we'll remove the 'jdbc' part)
+            
+            int tmpPos = jdbcConnectionUrl.indexOf(':', pos + 1);
+
+            if ("inetpool:jdbc".equals(jdbcConnectionUrl.substring(lastPos + 1, tmpPos)))
+            {
+                pos    = tmpPos;
+                tmpPos = jdbcConnectionUrl.indexOf(':', pos + 1);
+            }
+            subProtocol += ":" + jdbcConnectionUrl.substring(pos + 1, tmpPos);
+        }
+        else if ("jtds".equals(subProtocol) ||
+                 "microsoft".equals(subProtocol) ||
+                 "sybase".equals(subProtocol))
+        {
+            pos         = jdbcConnectionUrl.indexOf(':', pos + 1);
+            subProtocol = ":" + jdbcConnectionUrl.substring(lastPos + 1, pos);
+        }
+
+        return (String)jdbcSubProtocolToPlatform.get(subProtocol);
+    }
+
+}

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/AxionBuilder.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/AxionBuilder.java?rev=232530&r1=232529&r2=232530&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/AxionBuilder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/AxionBuilder.java Sat Aug 13 14:36:44 2005
@@ -17,58 +17,28 @@
  */
 
 import java.io.IOException;
-import java.sql.Types;
 
+import org.apache.ddlutils.PlatformInfo;
 import org.apache.ddlutils.model.Column;
 import org.apache.ddlutils.model.Table;
 
 /**
- * An SQL Builder for the <a href="http://axion.tigris.org/">Axion</a> JDBC database.
+ * The SQL Builder for the Axion database.
  * 
  * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
+ * @author <a href="mailto:tomdz@apache.org">Thomas Dudziak</a>
  * @version $Revision$
  */
 public class AxionBuilder extends SqlBuilder
 {
-    /** Database name of this builder */
-    public static final String DATABASENAME     = "Axion";
-    /** The axion jdbc driver */
-    public static final String JDBC_DRIVER      = "org.axiondb.jdbc.AxionDriver";
-    /** The subprotocol used by the axion driver */
-    public static final String JDBC_SUBPROTOCOL = "axiondb";
-
-    public AxionBuilder()
-    {
-        setRequiringNullAsDefaultValue(false);
-        setPrimaryKeyEmbedded(true);
-        setForeignKeysEmbedded(false);
-        setIndicesEmbedded(true);
-        addNativeTypeMapping(Types.ARRAY,         "BLOB");
-        addNativeTypeMapping(Types.BINARY,        "VARBINARY");
-        addNativeTypeMapping(Types.BIT,           "BOOLEAN");
-        addNativeTypeMapping(Types.DECIMAL,       "NUMBER");
-        addNativeTypeMapping(Types.DISTINCT,      "VARBINARY");
-        addNativeTypeMapping(Types.DOUBLE,        "FLOAT");
-        addNativeTypeMapping(Types.LONGVARBINARY, "VARBINARY");
-        addNativeTypeMapping(Types.LONGVARCHAR,   "VARCHAR");
-        addNativeTypeMapping(Types.NULL,          "VARBINARY");
-        addNativeTypeMapping(Types.NUMERIC,       "NUMBER");
-        addNativeTypeMapping(Types.OTHER,         "BLOB");
-        addNativeTypeMapping(Types.REAL,          "FLOAT");
-        addNativeTypeMapping(Types.REF,           "VARBINARY");
-        addNativeTypeMapping(Types.SMALLINT,      "SHORT");
-        addNativeTypeMapping(Types.STRUCT,        "VARBINARY");
-        addNativeTypeMapping(Types.TINYINT,       "SHORT");
-
-        addNativeTypeMapping("DATALINK", "VARBINARY");
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.ddlutils.builder.SqlBuilder#getDatabaseName()
+    /**
+     * Creates a new axion sql builder.
+     * 
+     * @param info The plaftform information
      */
-    public String getDatabaseName()
+    public AxionBuilder(PlatformInfo info)
     {
-        return DATABASENAME;
+        super(info);
     }
 
     /* (non-Javadoc)

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/CloudscapeBuilder.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/CloudscapeBuilder.java?rev=232530&r1=232529&r2=232530&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/CloudscapeBuilder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/CloudscapeBuilder.java Sat Aug 13 14:36:44 2005
@@ -19,53 +19,26 @@
 import java.io.IOException;
 import java.sql.Types;
 
+import org.apache.ddlutils.PlatformInfo;
 import org.apache.ddlutils.model.Column;
 import org.apache.ddlutils.model.Table;
 
 /**
- * An SQL Builder for Cloudscape.
+ * The SQL Builder for Cloudscape.
  * 
  * @author <a href="mailto:tomdz@apache.org">Thomas Dudziak</a>
+ * @version $Revision$
  */
 public class CloudscapeBuilder extends SqlBuilder
 {
-    /** Database name of this builder */
-    public static final String DATABASENAME = "Cloudscape";
-
-    public CloudscapeBuilder()
-    {
-        setRequiringNullAsDefaultValue(false);
-        setPrimaryKeyEmbedded(true);
-        setForeignKeysEmbedded(false);
-        setIndicesEmbedded(false);
-        setMaxIdentifierLength(128);
-        // binary and varbinary are also handled by getSqlType
-        addNativeTypeMapping(Types.ARRAY,         "BLOB");
-        addNativeTypeMapping(Types.BINARY,        "CHAR");
-        addNativeTypeMapping(Types.BIT,           "CHAR FOR BIT DATA");
-        addNativeTypeMapping(Types.DISTINCT,      "BLOB");
-        addNativeTypeMapping(Types.DOUBLE,        "DOUBLE PRECISION");
-        addNativeTypeMapping(Types.FLOAT,         "DOUBLE PRECISION");
-        addNativeTypeMapping(Types.JAVA_OBJECT,   "BLOB");
-        addNativeTypeMapping(Types.LONGVARBINARY, "LONG VARCHAR FOR BIT DATA");
-        addNativeTypeMapping(Types.LONGVARCHAR,   "LONG VARCHAR");
-        addNativeTypeMapping(Types.OTHER,         "BLOB");
-        addNativeTypeMapping(Types.NULL,          "LONG VARCHAR FOR BIT DATA");
-        addNativeTypeMapping(Types.REF,           "LONG VARCHAR FOR BIT DATA");
-        addNativeTypeMapping(Types.STRUCT,        "BLOB");
-        addNativeTypeMapping(Types.TINYINT,       "SMALLINT");
-        addNativeTypeMapping(Types.VARBINARY,     "VARCHAR");
-
-        addNativeTypeMapping("BOOLEAN",  "CHAR FOR BIT DATA");
-        addNativeTypeMapping("DATALINK", "LONG VARCHAR FOR BIT DATA");
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.ddlutils.builder.SqlBuilder#getDatabaseName()
+    /**
+     * Creates a new builder instance.
+     * 
+     * @param info The platform info
      */
-    public String getDatabaseName()
+    public CloudscapeBuilder(PlatformInfo info)
     {
-        return DATABASENAME;
+        super(info);
     }
 
     /* (non-Javadoc)

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/Db2Builder.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/Db2Builder.java?rev=232530&r1=232529&r2=232530&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/Db2Builder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/Db2Builder.java Sat Aug 13 14:36:44 2005
@@ -19,11 +19,12 @@
 import java.io.IOException;
 import java.sql.Types;
 
+import org.apache.ddlutils.PlatformInfo;
 import org.apache.ddlutils.model.Column;
 import org.apache.ddlutils.model.Table;
 
 /**
- * An SQL Builder for DB2.
+ * The SQL Builder for DB2.
  * 
  * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  * @author <a href="mailto:tomdz@apache.org">Thomas Dudziak</a>
@@ -31,43 +32,14 @@
  */
 public class Db2Builder extends SqlBuilder
 {
-    /** Database name of this builder */
-    public static final String DATABASENAME     = "DB2";
-    /** The standard DB2 jdbc driver */
-    public static final String JDBC_DRIVER      = "COM.ibm.db2.jdbc.app.DB2Driver";
-    /** The subprotocol used by the standard DB2 driver */
-    public static final String JDBC_SUBPROTOCOL = "db2";
-
-    public Db2Builder()
-    {
-        setMaxIdentifierLength(18);
-        setRequiringNullAsDefaultValue(false);
-        setPrimaryKeyEmbedded(true);
-        setForeignKeysEmbedded(false);
-        setIndicesEmbedded(false);
-        // the BINARY types are also handled by getSqlType(Column)
-        addNativeTypeMapping(Types.ARRAY,         "BLOB");
-        addNativeTypeMapping(Types.BINARY,        "CHAR");
-        addNativeTypeMapping(Types.BIT,           "CHAR FOR BIT DATA");
-        addNativeTypeMapping(Types.JAVA_OBJECT,   "BLOB");
-        addNativeTypeMapping(Types.LONGVARBINARY, "LONG VARCHAR FOR BIT DATA");
-        addNativeTypeMapping(Types.LONGVARCHAR,   "LONG VARCHAR");
-        addNativeTypeMapping(Types.NULL,          "LONG VARCHAR FOR BIT DATA");
-        addNativeTypeMapping(Types.OTHER,         "BLOB");
-        addNativeTypeMapping(Types.STRUCT,        "BLOB");
-        addNativeTypeMapping(Types.TINYINT,       "SMALLINT");
-        addNativeTypeMapping(Types.VARBINARY,     "VARCHAR");
-
-        // Types.BOOLEAN is only available since 1.4 so we're using the safe mapping method
-        addNativeTypeMapping("BOOLEAN", "CHAR FOR BIT DATA");
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.ddlutils.builder.SqlBuilder#getDatabaseName()
+    /**
+     * Creates a new builder instance.
+     * 
+     * @param info The platform info
      */
-    public String getDatabaseName()
+    public Db2Builder(PlatformInfo info)
     {
-        return DATABASENAME;
+        super(info);
     }
 
     /* (non-Javadoc)

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/HsqlDbBuilder.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/HsqlDbBuilder.java?rev=232530&r1=232529&r2=232530&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/HsqlDbBuilder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/HsqlDbBuilder.java Sat Aug 13 14:36:44 2005
@@ -17,13 +17,12 @@
  */
 
 import java.io.IOException;
-import java.sql.Types;
 
+import org.apache.ddlutils.PlatformInfo;
 import org.apache.ddlutils.model.Table;
 
-
 /**
- * An SQL Builder for the <a href="http://hsqldb.sourceforge.net/">HsqlDb</a> JDBC database.
+ * The SQL Builder for the HsqlDb database.
  * 
  * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  * @author <a href="mailto:tomdz@apache.org">Thomas Dudziak</a>
@@ -31,44 +30,14 @@
  */
 public class HsqlDbBuilder extends SqlBuilder
 {
-    /** Database name of this builder */
-    public static final String DATABASENAME     = "HsqlDb";
-    /** The standard Hsqldb jdbc driver */
-    public static final String JDBC_DRIVER      = "org.hsqldb.jdbcDriver";
-    /** The subprotocol used by the standard Hsqldb driver */
-    public static final String JDBC_SUBPROTOCOL = "hsqldb";
-
     /**
-     * Creates a new instance of the Hsqldb builer.
-     */
-    public HsqlDbBuilder()
-    {
-        super();
-        setRequiringNullAsDefaultValue(false);
-        setPrimaryKeyEmbedded(true);
-        setForeignKeysEmbedded(false);
-        setIndicesEmbedded(false);
-        addNativeTypeMapping(Types.ARRAY,       "LONGVARBINARY");
-        addNativeTypeMapping(Types.BLOB,        "LONGVARBINARY");
-        addNativeTypeMapping(Types.CLOB,        "LONGVARCHAR");
-        addNativeTypeMapping(Types.DISTINCT,    "LONGVARBINARY");
-        addNativeTypeMapping(Types.FLOAT,       "DOUBLE");
-        addNativeTypeMapping(Types.JAVA_OBJECT, "OBJECT");
-        addNativeTypeMapping(Types.NULL,        "LONGVARBINARY");
-        addNativeTypeMapping(Types.OTHER,       "OTHER");
-        addNativeTypeMapping(Types.REF,         "LONGVARBINARY");
-        addNativeTypeMapping(Types.STRUCT,      "LONGVARBINARY");
-
-        addNativeTypeMapping("BOOLEAN",  "BIT");
-        addNativeTypeMapping("DATALINK", "LONGVARBINARY");
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.ddlutils.builder.SqlBuilder#getDatabaseName()
+     * Creates a new builder instance.
+     * 
+     * @param info The platform info
      */
-    public String getDatabaseName()
+    public HsqlDbBuilder(PlatformInfo info)
     {
-        return DATABASENAME;
+        super(info);
     }
 
     /* (non-Javadoc)

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/InterbaseBuilder.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/InterbaseBuilder.java?rev=232530&r1=232529&r2=232530&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/InterbaseBuilder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/InterbaseBuilder.java Sat Aug 13 14:36:44 2005
@@ -19,74 +19,36 @@
 import java.io.IOException;
 import java.sql.Types;
 
+import org.apache.ddlutils.PlatformInfo;
 import org.apache.ddlutils.model.Column;
 import org.apache.ddlutils.model.Database;
 import org.apache.ddlutils.model.ForeignKey;
 import org.apache.ddlutils.model.Table;
 
 /**
- * An SQL Builder for the Interbase database.
+ * The SQL Builder for the Interbase database.
  * 
  * @author <a href="mailto:tomdz@apache.org">Thomas Dudziak</a>
+ * @version $Revision: 231306 $
  */
 public class InterbaseBuilder extends SqlBuilder
 {
-    /** Database name of this builder */
-    public static final String DATABASENAME     = "Interbase";
-    /** The interbase jdbc driver */
-    public static final String JDBC_DRIVER      = "interbase.interclient.Driver";
-    /** The subprotocol used by the interbase driver */
-    public static final String JDBC_SUBPROTOCOL = "interbase";
-
-    public InterbaseBuilder()
-    {
-        setMaxIdentifierLength(31);
-        setRequiringNullAsDefaultValue(false);
-        setPrimaryKeyEmbedded(true);
-        setForeignKeysEmbedded(false);
-        setIndicesEmbedded(false);
-        setCommentPrefix("/*");
-        setCommentSuffix("*/");
-
-        // BINARY and VARBINARY are also handled by the getSqlType method
-        addNativeTypeMapping(Types.ARRAY,         "BLOB");
-        addNativeTypeMapping(Types.BIGINT,        "DECIMAL(38,0)");
-        addNativeTypeMapping(Types.BINARY,        "CHAR");
-        addNativeTypeMapping(Types.BIT,           "DECIMAL(1,0)");
-        addNativeTypeMapping(Types.CLOB,          "BLOB SUB_TYPE TEXT");
-        addNativeTypeMapping(Types.DISTINCT,      "BLOB");
-        addNativeTypeMapping(Types.DOUBLE,        "DOUBLE PRECISION");
-        addNativeTypeMapping(Types.FLOAT,         "DOUBLE PRECISION");
-        addNativeTypeMapping(Types.JAVA_OBJECT,   "BLOB");
-        addNativeTypeMapping(Types.LONGVARBINARY, "BLOB");
-        addNativeTypeMapping(Types.LONGVARCHAR,   "BLOB SUB_TYPE TEXT");
-        addNativeTypeMapping(Types.NULL,          "BLOB");
-        addNativeTypeMapping(Types.OTHER,         "BLOB");
-        addNativeTypeMapping(Types.REAL,          "FLOAT");
-        addNativeTypeMapping(Types.TINYINT,       "SMALLINT");
-        addNativeTypeMapping(Types.REF,           "BLOB");
-        addNativeTypeMapping(Types.STRUCT,        "BLOB");
-        addNativeTypeMapping(Types.VARBINARY,     "VARCHAR");
-
-        // These types are only available since 1.4 so we're using the safe mapping method
-        addNativeTypeMapping("BOOLEAN",  "DECIMAL(1,0)");
-        addNativeTypeMapping("DATALINK", "BLOB");
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.ddlutils.builder.SqlBuilder#getDatabaseName()
+    /**
+     * Creates a new builder instance.
+     * 
+     * @param info The platform info
      */
-    public String getDatabaseName()
+    public InterbaseBuilder(PlatformInfo info)
     {
-        return DATABASENAME;
+        super(info);
     }
 
     /* (non-Javadoc)
      * @see org.apache.ddlutils.builder.SqlBuilder#dropDatabase(org.apache.ddlutils.model.Database)
      */
-    public void dropDatabase(Database database) throws IOException
+    public void dropTables(Database database) throws IOException
     {
-        super.dropDatabase(database);
+        super.dropTables(database);
         print("COMMIT");
         printEndOfStatement();
     }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/MSSqlBuilder.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/MSSqlBuilder.java?rev=232530&r1=232529&r2=232530&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/MSSqlBuilder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/MSSqlBuilder.java Sat Aug 13 14:36:44 2005
@@ -17,15 +17,15 @@
  */
 
 import java.io.IOException;
-import java.sql.Types;
 
+import org.apache.ddlutils.PlatformInfo;
 import org.apache.ddlutils.model.Column;
 import org.apache.ddlutils.model.ForeignKey;
 import org.apache.ddlutils.model.Index;
 import org.apache.ddlutils.model.Table;
 
 /**
- * An SQL Builder for MS SQL
+ * The SQL Builder for the Microsoft SQL Server.
  * 
  * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  * @author <a href="mailto:tomdz@apache.org">Thomas Dudziak</a>
@@ -33,51 +33,14 @@
  */
 public class MSSqlBuilder extends SqlBuilder
 {
-    /** Database name of this builder */
-    public static final String DATABASENAME     = "MsSql";
-    /** The standard SQLServer jdbc driver */
-    public static final String JDBC_DRIVER      = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
-    /** The subprotocol used by the standard SQLServer driver */
-    public static final String JDBC_SUBPROTOCOL = "microsoft:sqlserver";
-
-    public MSSqlBuilder()
-    {
-        setMaxIdentifierLength(128);
-        setRequiringNullAsDefaultValue(false);
-        setPrimaryKeyEmbedded(true);
-        setForeignKeysEmbedded(false);
-        setIndicesEmbedded(false);
-        //setCommentPrefix("#");
-        addNativeTypeMapping(Types.ARRAY,         "IMAGE");
-        addNativeTypeMapping(Types.BIGINT,        "DECIMAL(19,0)");
-        addNativeTypeMapping(Types.BLOB,          "IMAGE");
-        addNativeTypeMapping(Types.CLOB,          "TEXT");
-        addNativeTypeMapping(Types.DATE,          "DATETIME");
-        addNativeTypeMapping(Types.DISTINCT,      "IMAGE");
-        addNativeTypeMapping(Types.DOUBLE,        "FLOAT");
-        addNativeTypeMapping(Types.INTEGER,       "INT");
-        addNativeTypeMapping(Types.JAVA_OBJECT,   "IMAGE");
-        addNativeTypeMapping(Types.LONGVARBINARY, "IMAGE");
-        addNativeTypeMapping(Types.LONGVARCHAR,   "TEXT");
-        addNativeTypeMapping(Types.NULL,          "IMAGE");
-        addNativeTypeMapping(Types.OTHER,         "IMAGE");
-        addNativeTypeMapping(Types.REF,           "IMAGE");
-        addNativeTypeMapping(Types.STRUCT,        "IMAGE");
-        addNativeTypeMapping(Types.TIME,          "DATETIME");
-        addNativeTypeMapping(Types.TIMESTAMP,     "DATETIME");
-        addNativeTypeMapping(Types.TINYINT,       "SMALLINT");
-
-        // these types are only available since 1.4 so we're using the safe mapping method
-        addNativeTypeMapping("BOOLEAN",  "BIT");
-        addNativeTypeMapping("DATALINK", "IMAGE");
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.ddlutils.builder.SqlBuilder#getDatabaseName()
+    /**
+     * Creates a new builder instance.
+     * 
+     * @param info The platform info
      */
-    public String getDatabaseName()
+    public MSSqlBuilder(PlatformInfo info)
     {
-        return DATABASENAME;
+        super(info);
     }
 
     /* (non-Javadoc)

Copied: db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/MckoiBuilder.java (from r231306, db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/MckoiSqlBuilder.java)
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/MckoiBuilder.java?p2=db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/MckoiBuilder.java&p1=db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/MckoiSqlBuilder.java&r1=231306&r2=232530&rev=232530&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/MckoiSqlBuilder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/MckoiBuilder.java Sat Aug 13 14:36:44 2005
@@ -17,53 +17,28 @@
  */
 
 import java.io.IOException;
-import java.sql.Types;
 
+import org.apache.ddlutils.PlatformInfo;
 import org.apache.ddlutils.model.Column;
 import org.apache.ddlutils.model.Table;
 
 /**
- * An SQL Builder for the Mckoi database
+ * The SQL Builder for the Mckoi database.
  * 
  * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  * @author <a href="mailto:tomdz@apache.org">Thomas Dudziak</a>
  * @version $Revision$
  */
-public class MckoiSqlBuilder extends SqlBuilder
+public class MckoiBuilder extends SqlBuilder
 {
-    /** Database name of this builder */
-    public static final String DATABASENAME     = "McKoi";
-    /** The standard McKoi jdbc driver */
-    public static final String JDBC_DRIVER      = "com.mckoi.JDBCDriver";
-    /** The subprotocol used by the standard McKoi driver */
-    public static final String JDBC_SUBPROTOCOL = "mckoi";
-
-    public MckoiSqlBuilder()
-    {
-        setRequiringNullAsDefaultValue(false);
-        setPrimaryKeyEmbedded(true);
-        setForeignKeysEmbedded(false);
-        setIndicesEmbedded(false);
-
-        addNativeTypeMapping(Types.ARRAY,    "BLOB");
-        addNativeTypeMapping(Types.BIT,      "BOOLEAN");
-        addNativeTypeMapping(Types.DISTINCT, "BLOB");
-        addNativeTypeMapping(Types.FLOAT,    "DOUBLE");
-        addNativeTypeMapping(Types.NULL,     "BLOB");
-        addNativeTypeMapping(Types.OTHER,    "BLOB");
-        addNativeTypeMapping(Types.REF,      "BLOB");
-        addNativeTypeMapping(Types.STRUCT,   "BLOB");
-
-        // Types.DATALINK is only available since 1.4 so we're using the safe mapping method
-        addNativeTypeMapping("DATALINK", "BLOB");
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.ddlutils.builder.SqlBuilder#getDatabaseName()
+    /**
+     * Creates a new builder instance.
+     * 
+     * @param info The platform info
      */
-    public String getDatabaseName()
+    public MckoiBuilder(PlatformInfo info)
     {
-        return DATABASENAME;
+        super(info);
     }
 
     public void dropTable(Table table) throws IOException

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/MySqlBuilder.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/MySqlBuilder.java?rev=232530&r1=232529&r2=232530&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/MySqlBuilder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/MySqlBuilder.java Sat Aug 13 14:36:44 2005
@@ -20,11 +20,12 @@
 import java.sql.Types;
 import java.util.List;
 
+import org.apache.ddlutils.PlatformInfo;
 import org.apache.ddlutils.model.Column;
 import org.apache.ddlutils.model.Table;
 
 /**
- * An SQL Builder for MySQL
+ * The SQL Builder for MySQL.
  * 
  * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  * @author John Marshall/Connectria
@@ -33,53 +34,14 @@
  */
 public class MySqlBuilder extends SqlBuilder
 {
-    /** Database name of this builder */
-    public static final String DATABASENAME     = "MySQL";
-    /** The standard MySQL jdbc driver */
-    public static final String JDBC_DRIVER      = "com.mysql.jdbc.Driver";
-    /** The old MySQL jdbc driver */
-    public static final String JDBC_DRIVER_OLD  = "org.gjt.mm.mysql.Driver";
-    /** The subprotocol used by the standard MySQL driver */
-    public static final String JDBC_SUBPROTOCOL = "mysql";
-
-    public MySqlBuilder()
-    {
-        setMaxIdentifierLength(64);
-        setRequiringNullAsDefaultValue(false);
-        setPrimaryKeyEmbedded(true);
-        setForeignKeysEmbedded(false);
-        setIndicesEmbedded(false);
-        setCommentPrefix("#");
-        // the BINARY types are also handled by getSqlType(Column)
-        addNativeTypeMapping(Types.ARRAY,         "LONGBLOB");
-        addNativeTypeMapping(Types.BINARY,        "CHAR");
-        addNativeTypeMapping(Types.BIT,           "TINYINT(1)");
-        addNativeTypeMapping(Types.BLOB,          "LONGBLOB");
-        addNativeTypeMapping(Types.CLOB,          "LONGTEXT");
-        addNativeTypeMapping(Types.DISTINCT,      "LONGBLOB");
-        addNativeTypeMapping(Types.FLOAT,         "DOUBLE");
-        addNativeTypeMapping(Types.JAVA_OBJECT,   "LONGBLOB");
-        addNativeTypeMapping(Types.LONGVARBINARY, "MEDIUMBLOB");
-        addNativeTypeMapping(Types.LONGVARCHAR,   "MEDIUMTEXT");
-        addNativeTypeMapping(Types.NULL,          "MEDIUMBLOB");
-        addNativeTypeMapping(Types.NUMERIC,       "DECIMAL");
-        addNativeTypeMapping(Types.OTHER,         "LONGBLOB");
-        addNativeTypeMapping(Types.REAL,          "FLOAT");
-        addNativeTypeMapping(Types.REF,           "MEDIUMBLOB");
-        addNativeTypeMapping(Types.STRUCT,        "LONGBLOB");
-        addNativeTypeMapping(Types.VARBINARY,     "VARCHAR");
-
-        // These types are only available since 1.4 so we're using the safe mapping method
-        addNativeTypeMapping("BOOLEAN",  "TINYINT(1)");
-        addNativeTypeMapping("DATALINK", "MEDIUMBLOB");
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.ddlutils.builder.SqlBuilder#getDatabaseName()
+    /**
+     * Creates a new builder instance.
+     * 
+     * @param info The platform info
      */
-    public String getDatabaseName()
+    public MySqlBuilder(PlatformInfo info)
     {
-        return DATABASENAME;
+        super(info);
     }
 
     /* (non-Javadoc)

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/OracleBuilder.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/OracleBuilder.java?rev=232530&r1=232529&r2=232530&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/OracleBuilder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/builder/OracleBuilder.java Sat Aug 13 14:36:44 2005
@@ -19,12 +19,13 @@
 import java.io.IOException;
 import java.sql.Types;
 
+import org.apache.ddlutils.PlatformInfo;
 import org.apache.ddlutils.model.Column;
 import org.apache.ddlutils.model.Database;
 import org.apache.ddlutils.model.Table;
 
 /**
- * An SQL Builder for Oracle.
+ * The SQL Builder for Oracle.
  *
  * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
  * @author <a href="mailto:tomdz@apache.org">Thomas Dudziak</a>
@@ -32,59 +33,14 @@
  */
 public class OracleBuilder extends SqlBuilder
 {
-    /** Database name of this builder */
-    public static final String DATABASENAME     = "Oracle";
-    /** The standard Oracle jdbc driver */
-    public static final String JDBC_DRIVER      = "oracle.jdbc.driver.OracleDriver";
-    /** The subprotocol used by the standard Oracle driver */
-    public static final String JDBC_SUBPROTOCOL = "oracle";
-
-    public OracleBuilder()
-    {
-        setMaxIdentifierLength(30);
-        setRequiringNullAsDefaultValue(false);
-        setPrimaryKeyEmbedded(true);
-        setForeignKeysEmbedded(false);
-        setIndicesEmbedded(false);
-
-        addNativeTypeMapping(Types.ARRAY,         "BLOB");
-        addNativeTypeMapping(Types.BIGINT,        "NUMBER(38,0)");
-        addNativeTypeMapping(Types.BINARY,        "RAW");
-        addNativeTypeMapping(Types.BIT,           "NUMBER(1,0)");
-        addNativeTypeMapping(Types.DECIMAL,       "NUMBER");
-        addNativeTypeMapping(Types.DISTINCT,      "BLOB");
-        addNativeTypeMapping(Types.DOUBLE,        "NUMBER(38)");
-        addNativeTypeMapping(Types.FLOAT,         "NUMBER(38)");
-        addNativeTypeMapping(Types.INTEGER,       "NUMBER(20,0)");
-        addNativeTypeMapping(Types.JAVA_OBJECT,   "BLOB");
-        addNativeTypeMapping(Types.LONGVARBINARY, "BLOB");
-        addNativeTypeMapping(Types.LONGVARCHAR,   "CLOB");
-        addNativeTypeMapping(Types.NULL,          "BLOB");
-        addNativeTypeMapping(Types.NUMERIC,       "NUMBER");
-        addNativeTypeMapping(Types.OTHER,         "BLOB");
-        addNativeTypeMapping(Types.REAL,          "NUMBER(18)");
-        addNativeTypeMapping(Types.REF,           "BLOB");
-        addNativeTypeMapping(Types.SMALLINT,      "NUMBER(5,0)");
-        addNativeTypeMapping(Types.STRUCT,        "BLOB");
-        addNativeTypeMapping(Types.TIME,          "DATE");
-        // TODO: This should really be controlled by an option since beginning with Oracle 9,
-        //       the special TIMESTAMP type should be used
-        addNativeTypeMapping(Types.TIMESTAMP,     "DATE");
-        addNativeTypeMapping(Types.TINYINT,       "NUMBER(3,0)");
-        addNativeTypeMapping(Types.VARBINARY,     "RAW");
-        addNativeTypeMapping(Types.VARCHAR,       "VARCHAR2");
-
-        // These types are only available since 1.4 so we're using the safe mapping method
-        addNativeTypeMapping("BOOLEAN",  "NUMBER(1,0)");
-        addNativeTypeMapping("DATALINK", "BLOB");
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.ddlutils.builder.SqlBuilder#getDatabaseName()
+    /**
+     * Creates a new builder instance.
+     * 
+     * @param info The platform info
      */
-    public String getDatabaseName()
+    public OracleBuilder(PlatformInfo info)
     {
-        return DATABASENAME;
+        super(info);
     }
 
     public void dropTable(Table table) throws IOException



Mime
View raw message