db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r630717 [1/3] - in /db/ddlutils/trunk/src: java/org/apache/ddlutils/alteration/ java/org/apache/ddlutils/dynabean/ java/org/apache/ddlutils/io/ java/org/apache/ddlutils/io/converters/ java/org/apache/ddlutils/model/ java/org/apache/ddlutils...
Date Mon, 25 Feb 2008 02:18:05 GMT
Author: tomdz
Date: Sun Feb 24 18:17:57 2008
New Revision: 630717

URL: http://svn.apache.org/viewvc?rev=630717&view=rev
Log:
Fixed issues reported by FindBugs
Implementation of DDLUTILS-194: Make Java 1.4 (JDBC 3) required for DdlUtils

Added:
    db/ddlutils/trunk/src/java/org/apache/ddlutils/util/StringUtilsExt.java
      - copied, changed from r630531, db/ddlutils/trunk/src/java/org/apache/ddlutils/util/StringUtils.java
Removed:
    db/ddlutils/trunk/src/java/org/apache/ddlutils/util/Jdbc3Utils.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/util/MultiInstanceofPredicate.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/util/StringUtils.java
Modified:
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddPrimaryKeyChange.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnDefinitionChange.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ModelComparator.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/PrimaryKeyChange.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/dynabean/SqlDynaClass.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/io/ConverterConfiguration.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/io/converters/NumberConverter.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/model/Column.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/model/ForeignKey.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/model/Index.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/model/IndexImplBase.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/model/NonUniqueIndex.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/model/TypeMap.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/model/UniqueIndex.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/DatabaseMetaDataWrapper.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/DefaultValueHelper.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/JdbcModelReader.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PlatformImplBase.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/axion/AxionPlatform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/cloudscape/CloudscapePlatform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/db2/Db2Builder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/db2/Db2ModelReader.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/db2/Db2Platform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/derby/DerbyBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/firebird/FirebirdBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/firebird/FirebirdModelReader.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/firebird/FirebirdPlatform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/hsqldb/HsqlDbPlatform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/interbase/InterbaseBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/interbase/InterbaseModelReader.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/interbase/InterbasePlatform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mckoi/MckoiModelReader.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mckoi/MckoiPlatform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mssql/MSSqlBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mssql/MSSqlModelComparator.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mssql/MSSqlModelReader.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mssql/MSSqlPlatform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlModelComparator.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlPlatform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle10ModelReader.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle8Builder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle8ModelReader.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle8Platform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/postgresql/PostgreSqlPlatform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sapdb/SapDbPlatform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybaseBuilder.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybaseModelReader.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybasePlatform.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DatabaseTaskBase.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/task/VerbosityLevel.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/TestDatabaseWriterBase.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/TestPlatformBase.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/TestSummaryCreatorTask.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestAxionPlatform.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestCloudscapePlatform.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestDB2Platform.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestDerbyPlatform.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestFirebirdPlatform.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestHsqlDbPlatform.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestInterbasePlatform.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMSSqlPlatform.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMaxDbPlatform.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMcKoiPlatform.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMySql50Platform.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestMySqlPlatform.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestOracle8Platform.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestOracle9Platform.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestPlatformImplBase.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestPostgresqlPlatform.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestSapDbPlatform.java
    db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestSybasePlatform.java

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddPrimaryKeyChange.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddPrimaryKeyChange.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddPrimaryKeyChange.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/AddPrimaryKeyChange.java Sun Feb 24 18:17:57 2008
@@ -42,7 +42,16 @@
     public AddPrimaryKeyChange(String tableName, String[] primaryKeyColumns)
     {
         super(tableName);
-        _primaryKeyColumns = primaryKeyColumns;
+        if (primaryKeyColumns == null)
+        {
+            _primaryKeyColumns = new String[0];
+        }
+        else
+        {
+            _primaryKeyColumns = new String[primaryKeyColumns.length];
+
+            System.arraycopy(primaryKeyColumns, 0, _primaryKeyColumns, 0, primaryKeyColumns.length);
+        }
     }
 
     /**
@@ -52,7 +61,10 @@
      */
     public String[] getPrimaryKeyColumns()
     {
-        return _primaryKeyColumns;
+        String[] result = new String[_primaryKeyColumns.length];
+
+        System.arraycopy(_primaryKeyColumns, 0, result, 0, _primaryKeyColumns.length);
+        return result;
     }
 
     /**

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnDefinitionChange.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnDefinitionChange.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnDefinitionChange.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ColumnDefinitionChange.java Sun Feb 24 18:17:57 2008
@@ -22,7 +22,7 @@
 import org.apache.ddlutils.PlatformInfo;
 import org.apache.ddlutils.model.Column;
 import org.apache.ddlutils.model.Database;
-import org.apache.ddlutils.util.StringUtils;
+import org.apache.ddlutils.util.StringUtilsExt;
 
 /**
  * Represents the change of one or more aspects of the definition of a column, such as
@@ -108,7 +108,7 @@
         boolean sizeMatters    = platformInfo.hasSize(targetTypeCode);
         boolean scaleMatters   = platformInfo.hasPrecisionAndScale(targetTypeCode);
 
-        if (sizeMatters && !StringUtils.equals(sourceColumn.getSize(), targetColumn.getSize()))
+        if (sizeMatters && !StringUtilsExt.equals(sourceColumn.getSize(), targetColumn.getSize()))
         {
             return true;
         }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ModelComparator.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ModelComparator.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ModelComparator.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/ModelComparator.java Sun Feb 24 18:17:57 2008
@@ -32,7 +32,7 @@
 import org.apache.ddlutils.model.ForeignKey;
 import org.apache.ddlutils.model.Index;
 import org.apache.ddlutils.model.Table;
-import org.apache.ddlutils.util.StringUtils;
+import org.apache.ddlutils.util.StringUtilsExt;
 
 /**
  * Compares two database models and creates change objects that express how to
@@ -239,15 +239,13 @@
         {
             Table targetTable       = targetModel.getTable(tableIdx);
             Table intermediateTable = intermediateModel.findTable(targetTable.getName(), _caseSensitive);
-            Table sourceTable       = sourceModel.findTable(targetTable.getName(), _caseSensitive);
 
             for (int fkIdx = 0; fkIdx < targetTable.getForeignKeyCount(); fkIdx++)
             {
                 ForeignKey targetFk       = targetTable.getForeignKey(fkIdx);
                 ForeignKey intermediateFk = findCorrespondingForeignKey(intermediateTable, targetFk);
-                ForeignKey sourceFk       = sourceTable == null ? null : findCorrespondingForeignKey(sourceTable, targetFk);
 
-                if ((sourceFk == null) && (intermediateFk == null))
+                if (intermediateFk == null)
                 {
                     if (_log.isInfoEnabled())
                     {
@@ -791,7 +789,7 @@
             {
                 for (int pkColumnIdx = 0; (pkColumnIdx < curPK.length) && !changePK; pkColumnIdx++)
                 {
-                    if (!StringUtils.equals(curPK[pkColumnIdx].getName(), targetPK[pkColumnIdx].getName(), _caseSensitive))
+                    if (!StringUtilsExt.equals(curPK[pkColumnIdx].getName(), targetPK[pkColumnIdx].getName(), _caseSensitive))
                     {
                         changePK = true;
                     }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/PrimaryKeyChange.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/PrimaryKeyChange.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/PrimaryKeyChange.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/alteration/PrimaryKeyChange.java Sun Feb 24 18:17:57 2008
@@ -42,7 +42,16 @@
     public PrimaryKeyChange(String tableName, String[] newPrimaryKeyColumns)
     {
         super(tableName);
-        _newPrimaryKeyColumns = newPrimaryKeyColumns;
+        if (newPrimaryKeyColumns == null)
+        {
+            _newPrimaryKeyColumns = new String[0];
+        }
+        else
+        {
+            _newPrimaryKeyColumns = new String[newPrimaryKeyColumns.length];
+
+            System.arraycopy(newPrimaryKeyColumns, 0, _newPrimaryKeyColumns, 0, newPrimaryKeyColumns.length);
+        }
     }
 
     /**
@@ -52,7 +61,10 @@
      */
     public String[] getNewPrimaryKeyColumns()
     {
-        return _newPrimaryKeyColumns;
+        String[] result = new String[_newPrimaryKeyColumns.length];
+
+        System.arraycopy(_newPrimaryKeyColumns, 0, result, 0, _newPrimaryKeyColumns.length);
+        return result;
     }
 
     /**

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/dynabean/SqlDynaClass.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/dynabean/SqlDynaClass.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/dynabean/SqlDynaClass.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/dynabean/SqlDynaClass.java Sun Feb 24 18:17:57 2008
@@ -108,7 +108,11 @@
      */
     public SqlDynaProperty[] getSqlDynaProperties()
     {
-        return (SqlDynaProperty[])getDynaProperties();
+        DynaProperty[]    props  = getDynaProperties();
+        SqlDynaProperty[] result = new SqlDynaProperty[props.length];
+
+        System.arraycopy(props, 0, result, 0, props.length);
+        return result;
     }
     
     /**
@@ -122,7 +126,11 @@
         {
             initPrimaryKeys();
         }
-        return _primaryKeyProperties;
+
+        SqlDynaProperty[] result = new SqlDynaProperty[_primaryKeyProperties.length];
+
+        System.arraycopy(_primaryKeyProperties, 0, result, 0, _primaryKeyProperties.length);
+        return result;
     }
 
     /**
@@ -136,7 +144,11 @@
         {
             initPrimaryKeys();
         }
-        return _nonPrimaryKeyProperties;
+
+        SqlDynaProperty[] result = new SqlDynaProperty[_nonPrimaryKeyProperties.length];
+
+        System.arraycopy(_nonPrimaryKeyProperties, 0, result, 0, _nonPrimaryKeyProperties.length);
+        return result;
     }
     
     // Implementation methods    

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/io/ConverterConfiguration.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/io/ConverterConfiguration.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/io/ConverterConfiguration.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/io/ConverterConfiguration.java Sun Feb 24 18:17:57 2008
@@ -30,7 +30,6 @@
 import org.apache.ddlutils.io.converters.TimestampConverter;
 import org.apache.ddlutils.model.Column;
 import org.apache.ddlutils.model.Table;
-import org.apache.ddlutils.util.Jdbc3Utils;
 
 /**
  * Contains the configuration for converters, which convert between the Java data types
@@ -58,6 +57,7 @@
         registerConverter(Types.TIMESTAMP,     new TimestampConverter());
         registerConverter(Types.BIGINT,        numberConverter);
         registerConverter(Types.BIT,           numberConverter);
+        registerConverter(Types.BOOLEAN,       numberConverter);
         registerConverter(Types.DECIMAL,       numberConverter);
         registerConverter(Types.DOUBLE,        numberConverter);
         registerConverter(Types.FLOAT,         numberConverter);
@@ -70,10 +70,6 @@
         registerConverter(Types.VARBINARY,     binaryConverter);
         registerConverter(Types.LONGVARBINARY, binaryConverter);
         registerConverter(Types.BLOB,          binaryConverter);
-        if (Jdbc3Utils.supportsJava14JdbcTypes())
-        {
-            registerConverter(Jdbc3Utils.determineBooleanTypeCode(), numberConverter);
-        }
     }
 
     /**

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/io/converters/NumberConverter.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/io/converters/NumberConverter.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/io/converters/NumberConverter.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/io/converters/NumberConverter.java Sun Feb 24 18:17:57 2008
@@ -23,7 +23,6 @@
 import java.sql.Types;
 
 import org.apache.commons.beanutils.ConvertUtils;
-import org.apache.ddlutils.util.Jdbc3Utils;
 
 /**
  * Converts between the various number types (including boolean types) and {@link java.lang.String}.
@@ -43,7 +42,7 @@
         }
         else
         {
-            Class  targetClass = null;
+            Class targetClass = null;
 
             switch (sqlTypeCode)
             {
@@ -51,6 +50,7 @@
                     targetClass = Long.class;
                     break;
                 case Types.BIT:
+                case Types.BOOLEAN:
                     targetClass = Boolean.class;
                     break;
                 case Types.DECIMAL:
@@ -70,13 +70,6 @@
                 case Types.SMALLINT:
                 case Types.TINYINT:
                     targetClass = Short.class;
-                    break;
-                default:
-                    if (Jdbc3Utils.supportsJava14JdbcTypes() &&
-                        (sqlTypeCode == Jdbc3Utils.determineBooleanTypeCode()))
-                    {
-                        targetClass = Boolean.class;
-                    }
                     break;
             }
             return targetClass == null ? textRep : ConvertUtils.convert(textRep, targetClass);

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/model/Column.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/model/Column.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/model/Column.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/model/Column.java Sun Feb 24 18:17:57 2008
@@ -29,7 +29,6 @@
 import org.apache.commons.beanutils.ConvertUtils;
 import org.apache.commons.lang.builder.EqualsBuilder;
 import org.apache.commons.lang.builder.HashCodeBuilder;
-import org.apache.ddlutils.util.Jdbc3Utils;
 
 /**
  * Represents a column in the database model.
@@ -446,14 +445,8 @@
                     case Types.TIMESTAMP:
                         return Timestamp.valueOf(_defaultValue);
                     case Types.BIT:
+                    case Types.BOOLEAN:
                         return ConvertUtils.convert(_defaultValue, Boolean.class);
-                    default:
-                        if (Jdbc3Utils.supportsJava14JdbcTypes() &&
-                            (_typeCode == Jdbc3Utils.determineBooleanTypeCode()))
-                        {
-                            return ConvertUtils.convert(_defaultValue, Boolean.class);
-                        }
-                        break;
                 }
             }
             catch (NumberFormatException ex)

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/model/ForeignKey.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/model/ForeignKey.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/model/ForeignKey.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/model/ForeignKey.java Sun Feb 24 18:17:57 2008
@@ -26,7 +26,7 @@
 import org.apache.commons.collections.set.ListOrderedSet;
 import org.apache.commons.lang.builder.EqualsBuilder;
 import org.apache.commons.lang.builder.HashCodeBuilder;
-import org.apache.ddlutils.util.StringUtils;
+import org.apache.ddlutils.util.StringUtilsExt;
 
 /**
  * Represents a database foreign key.
@@ -309,7 +309,7 @@
     {
         for (int idx = 0; idx < getReferenceCount(); idx++)
         {
-            if (StringUtils.equals(columnName, getReference(idx).getLocalColumnName(), caseSensitive))
+            if (StringUtilsExt.equals(columnName, getReference(idx).getLocalColumnName(), caseSensitive))
             {
                 return true;
             }
@@ -351,7 +351,7 @@
     {
         for (int idx = 0; idx < getReferenceCount(); idx++)
         {
-            if (StringUtils.equals(columnName, getReference(idx).getForeignColumnName(), caseSensitive))
+            if (StringUtilsExt.equals(columnName, getReference(idx).getForeignColumnName(), caseSensitive))
             {
                 return true;
             }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/model/Index.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/model/Index.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/model/Index.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/model/Index.java Sun Feb 24 18:17:57 2008
@@ -26,7 +26,7 @@
  * 
  * @version $Revision$
  */
-public interface Index extends Cloneable, Serializable
+public interface Index extends Serializable
 {
     /**
      * Determines whether this index is unique or not.
@@ -108,14 +108,6 @@
      * @param idx The position of the index column to remove
      */
     public void removeColumn(int idx);
-
-    /**
-     * Clones this index.
-     * 
-     * @return The clone
-     * @throws CloneNotSupportedException If the cloning did fail
-     */
-    public Object clone() throws CloneNotSupportedException;
 
     /**
      * Returns a clone of this index object. This is essentially the same method as

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/model/IndexImplBase.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/model/IndexImplBase.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/model/IndexImplBase.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/model/IndexImplBase.java Sun Feb 24 18:17:57 2008
@@ -21,7 +21,7 @@
 
 import java.util.ArrayList;
 
-import org.apache.ddlutils.util.StringUtils;
+import org.apache.ddlutils.util.StringUtilsExt;
 
 /**
  * Base class for indexes.
@@ -101,7 +101,7 @@
         {
             IndexColumn curColumn = getColumn(idx);
 
-            if (StringUtils.equals(columnName, curColumn.getName(), caseSensitive))
+            if (StringUtilsExt.equals(columnName, curColumn.getName(), caseSensitive))
             {
                 return true;
             }
@@ -145,9 +145,4 @@
     {
         _columns.remove(idx);
     }
-
-    /**
-     * {@inheritDoc}
-     */
-    public abstract Object clone() throws CloneNotSupportedException;
 }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/model/NonUniqueIndex.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/model/NonUniqueIndex.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/model/NonUniqueIndex.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/model/NonUniqueIndex.java Sun Feb 24 18:17:57 2008
@@ -45,14 +45,6 @@
     /**
      * {@inheritDoc}
      */
-    public Object clone() throws CloneNotSupportedException
-    {
-        return getClone();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
     public Index getClone() throws ModelException
     {
         NonUniqueIndex result = new NonUniqueIndex();

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/model/TypeMap.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/model/TypeMap.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/model/TypeMap.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/model/TypeMap.java Sun Feb 24 18:17:57 2008
@@ -20,14 +20,11 @@
  */
 
 import java.sql.Types;
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Set;
 
-import org.apache.ddlutils.util.Jdbc3Utils;
-
 /**
  * A class that maps SQL type names to their JDBC type ID found in
  * {@link java.sql.Types} and vice versa.
@@ -111,8 +108,10 @@
         registerJdbcType(Types.BINARY,        BINARY,        JdbcTypeCategoryEnum.BINARY);
         registerJdbcType(Types.BIT,           BIT,           JdbcTypeCategoryEnum.NUMERIC);
         registerJdbcType(Types.BLOB,          BLOB,          JdbcTypeCategoryEnum.BINARY);
+        registerJdbcType(Types.BOOLEAN,       BOOLEAN,       JdbcTypeCategoryEnum.NUMERIC);
         registerJdbcType(Types.CHAR,          CHAR,          JdbcTypeCategoryEnum.TEXTUAL);
         registerJdbcType(Types.CLOB,          CLOB,          JdbcTypeCategoryEnum.TEXTUAL);
+        registerJdbcType(Types.DATALINK,      DATALINK,      JdbcTypeCategoryEnum.SPECIAL);
         registerJdbcType(Types.DATE,          DATE,          JdbcTypeCategoryEnum.DATETIME);
         registerJdbcType(Types.DECIMAL,       DECIMAL,       JdbcTypeCategoryEnum.NUMERIC);
         registerJdbcType(Types.DISTINCT,      DISTINCT,      JdbcTypeCategoryEnum.SPECIAL);
@@ -134,13 +133,6 @@
         registerJdbcType(Types.TINYINT,       TINYINT,       JdbcTypeCategoryEnum.NUMERIC);
         registerJdbcType(Types.VARBINARY,     VARBINARY,     JdbcTypeCategoryEnum.BINARY);
         registerJdbcType(Types.VARCHAR,       VARCHAR,       JdbcTypeCategoryEnum.TEXTUAL);
-
-        // only available in JDK 1.4 and above:
-        if (Jdbc3Utils.supportsJava14JdbcTypes())
-        {
-            registerJdbcType(Jdbc3Utils.determineBooleanTypeCode(),  BOOLEAN,  JdbcTypeCategoryEnum.NUMERIC);
-            registerJdbcType(Jdbc3Utils.determineDatalinkTypeCode(), DATALINK, JdbcTypeCategoryEnum.SPECIAL);
-        }
 
         // Torque/Turbine extensions which we only support when reading from an XML schema
         _typeNameToTypeCode.put("BOOLEANINT",  new Integer(Types.TINYINT));

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/model/UniqueIndex.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/model/UniqueIndex.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/model/UniqueIndex.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/model/UniqueIndex.java Sun Feb 24 18:17:57 2008
@@ -46,14 +46,6 @@
     /**
      * {@inheritDoc}
      */
-    public Object clone() throws CloneNotSupportedException
-    {
-        return getClone();
-    }
-
-    /**
-     * {@inheritDoc}
-     */
     public Index getClone() throws ModelException
     {
         UniqueIndex result = new UniqueIndex();

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/DatabaseMetaDataWrapper.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/DatabaseMetaDataWrapper.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/DatabaseMetaDataWrapper.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/DatabaseMetaDataWrapper.java Sun Feb 24 18:17:57 2008
@@ -106,7 +106,17 @@
      */
     public String[] getTableTypes()
     {
-        return _tableTypes;
+        if (_tableTypes == null)
+        {
+            return null;
+        }
+        else
+        {
+            String[] result = new String[_tableTypes.length];
+
+            System.arraycopy(_tableTypes, 0, result, 0, _tableTypes.length);
+            return result;
+        }
     }
 
     /**
@@ -116,7 +126,16 @@
      */
     public void setTableTypes(String[] types)
     {
-        _tableTypes = types;
+        if (types == null)
+        {
+            _tableTypes = null;
+        }
+        else
+        {
+            _tableTypes = new String[types.length];
+
+            System.arraycopy(types, 0, _tableTypes, 0, types.length);
+        }
     }
 
     /**

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/DefaultValueHelper.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/DefaultValueHelper.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/DefaultValueHelper.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/DefaultValueHelper.java Sun Feb 24 18:17:57 2008
@@ -27,7 +27,6 @@
 import org.apache.commons.beanutils.ConversionException;
 import org.apache.commons.beanutils.ConvertUtils;
 import org.apache.ddlutils.model.TypeMap;
-import org.apache.ddlutils.util.Jdbc3Utils;
 
 /**
  * Helper class for dealing with default values, e.g. converting them to other types.
@@ -54,6 +53,7 @@
             switch (originalTypeCode)
             {
                 case Types.BIT:
+                case Types.BOOLEAN:
                     result = convertBoolean(defaultValue, targetTypeCode).toString();
                     break;
                 case Types.DATE:
@@ -82,13 +82,6 @@
                 		{}
                 	}
                     break;
-                default:
-                    if (Jdbc3Utils.supportsJava14JdbcTypes() &&
-                        (originalTypeCode == Jdbc3Utils.determineBooleanTypeCode()))
-                    {
-                        result = convertBoolean(defaultValue, targetTypeCode).toString();
-                    }
-                    break;
             }
         }
         return result;
@@ -115,8 +108,7 @@
             return defaultValue;
         }
         
-        if ((targetTypeCode == Types.BIT) ||
-            (Jdbc3Utils.supportsJava14JdbcTypes() && (targetTypeCode == Jdbc3Utils.determineBooleanTypeCode())))
+        if ((targetTypeCode == Types.BIT) || (targetTypeCode == Types.BOOLEAN))
         {
             result = value;
         }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/JdbcModelReader.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/JdbcModelReader.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/JdbcModelReader.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/JdbcModelReader.java Sun Feb 24 18:17:57 2008
@@ -61,7 +61,7 @@
 public class JdbcModelReader
 {
     /** The Log to which logging calls will be made. */
-    private final Log _log = LogFactory.getLog(JdbcModelReader.class);
+    private final Log _log = LogFactory.getLog(getClass());
 
     /** The descriptors for the relevant columns in the table meta data. */
     private final List _columnsForTable;
@@ -122,6 +122,16 @@
     }
 
     /**
+     * Returns the log used by the model reader.
+     * 
+     * @return The log
+     */
+    protected Log getLog()
+    {
+        return _log;
+    }
+    
+    /**
      * Returns the platform that this model reader belongs to.
      * 
      * @return The platform
@@ -347,7 +357,17 @@
      */
     public String[] getDefaultTableTypes()
     {
-        return _defaultTableTypes;
+        if (_defaultTableTypes == null)
+        {
+            return null;
+        }
+        else
+        {
+            String[] result = new String[_defaultTableTypes.length];
+
+            System.arraycopy(_defaultTableTypes, 0, result, 0, _defaultTableTypes.length);
+            return result;
+        }
     }
 
     /**
@@ -358,7 +378,16 @@
      */
     public void setDefaultTableTypes(String[] types)
     {
-        _defaultTableTypes = types;
+        if (types == null)
+        {
+            _defaultTableTypes = null;
+        }
+        else
+        {
+            _defaultTableTypes = new String[types.length];
+
+            System.arraycopy(types, 0, types, 0, types.length);
+        }
     }
 
     /**
@@ -536,10 +565,7 @@
         }
         finally
         {
-            if (tableData != null)
-            {
-                tableData.close();
-            }
+            closeResultSet(tableData);
         }
     }
 
@@ -761,10 +787,7 @@
         }
         finally
         {
-            if (columnData != null)
-            {
-                columnData.close();
-            }
+            closeResultSet(columnData);
         }
     }
 
@@ -812,7 +835,7 @@
 
         String description = (String)values.get("REMARKS");
 
-        if (!org.apache.ddlutils.util.StringUtils.isEmpty(description))
+        if (!org.apache.ddlutils.util.StringUtilsExt.isEmpty(description))
         {
             column.setDescription(description);
         }
@@ -843,10 +866,7 @@
         }
         finally
         {
-            if (pkData != null)
-            {
-                pkData.close();
-            }
+            closeResultSet(pkData);
         }
         return pks;
     }
@@ -888,10 +908,7 @@
         }
         finally
         {
-            if (fkData != null)
-            {
-                fkData.close();
-            }
+            closeResultSet(fkData);
         }
         return fks.values();
     }
@@ -985,10 +1002,7 @@
         }
         finally
         {
-            if (indexData != null)
-            {
-                indexData.close();
-            }
+            closeResultSet(indexData);
         }
         return indices.values();
     }
@@ -1126,10 +1140,7 @@
         }
         finally
         {
-            if (stmt != null)
-            {
-                stmt.close();
-            }
+            closeStatement(stmt);
         }
     }
 
@@ -1246,13 +1257,37 @@
         }
         finally
         {
-            if (columnData != null)
+            closeResultSet(columnData);
+            closeResultSet(tableData);
+        }
+    }
+
+    protected void closeResultSet(ResultSet resultSet)
+    {
+        if (resultSet != null)
+        {
+            try
+            {
+                resultSet.close();
+            }
+            catch (SQLException ex)
             {
-                columnData.close();
+                _log.warn("Error while closing result set", ex);
+            }
+        }
+    }
+
+    protected void closeStatement(Statement stmt)
+    {
+        if (stmt != null)
+        {
+            try
+            {
+                stmt.close();
             }
-            if (tableData != null)
+            catch (SQLException ex)
             {
-                tableData.close();
+                _log.warn("Error while closing statement", ex);
             }
         }
     }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PlatformImplBase.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PlatformImplBase.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PlatformImplBase.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/PlatformImplBase.java Sun Feb 24 18:17:57 2008
@@ -83,7 +83,6 @@
 import org.apache.ddlutils.model.ModelException;
 import org.apache.ddlutils.model.Table;
 import org.apache.ddlutils.model.TypeMap;
-import org.apache.ddlutils.util.Jdbc3Utils;
 import org.apache.ddlutils.util.JdbcSupport;
 import org.apache.ddlutils.util.SqlTokenizer;
 
@@ -461,7 +460,7 @@
      */
     public String getCreateTablesSql(Database model, boolean dropTablesFirst, boolean continueOnError)
     {
-        return getCreateTablesSql(model, dropTablesFirst, continueOnError);
+        return getCreateModelSql(model, dropTablesFirst, continueOnError);
     }
 
     /**
@@ -469,7 +468,7 @@
      */
     public String getCreateTablesSql(Database model, CreationParameters params, boolean dropTablesFirst, boolean continueOnError)
     {
-        return getCreateTablesSql(model, params, dropTablesFirst, continueOnError);
+        return getCreateModelSql(model, params, dropTablesFirst, continueOnError);
     }
 
     /**
@@ -2140,14 +2139,13 @@
                     if (results[idx] < 0)
                     {
                         hasSum = false;
-                        if (Jdbc3Utils.supportsJava14BatchResultCodes())
+                        if (results[idx] == Statement.EXECUTE_FAILED)
                         {
-                            String msg = Jdbc3Utils.getBatchResultMessage(table.getName(), idx, results[idx]);
-
-                            if (msg != null)
-                            {
-                                _log.warn(msg);
-                            }
+                            _log.warn("The batch insertion of row " + idx + " into table " + table.getName() + " failed but the driver is able to continue processing");
+                        }
+                        else if (results[idx] != Statement.SUCCESS_NO_INFO)
+                        {
+                            _log.warn("The batch insertion of row " + idx + " into table " + table.getName() + " returned an undefined status value " + results[idx]);
                         }
                     }
                     else
@@ -2936,6 +2934,7 @@
 		        value = useIdx ? resultSet.getBigDecimal(columnIdx) : resultSet.getBigDecimal(columnName);
 		        break;
 		    case Types.BIT:
+            case Types.BOOLEAN:
 		        value = new Boolean(useIdx ? resultSet.getBoolean(columnIdx) : resultSet.getBoolean(columnName));
 		        break;
 		    case Types.TINYINT:
@@ -3030,16 +3029,7 @@
 		        value = useIdx ? resultSet.getRef(columnIdx) : resultSet.getRef(columnName);
 		        break;
 		    default:
-		        // special handling for Java 1.4/JDBC 3 types
-		        if (Jdbc3Utils.supportsJava14JdbcTypes() &&
-		            (jdbcType == Jdbc3Utils.determineBooleanTypeCode()))
-		        {
-		            value = new Boolean(useIdx ? resultSet.getBoolean(columnIdx) : resultSet.getBoolean(columnName));
-		        }
-		        else
-		        {
-		            value = useIdx ? resultSet.getObject(columnIdx) : resultSet.getObject(columnName);
-		        }
+	            value = useIdx ? resultSet.getObject(columnIdx) : resultSet.getObject(columnName);
 		        break;
 		}
         return resultSet.wasNull() ? null : value;

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/axion/AxionPlatform.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/axion/AxionPlatform.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/axion/AxionPlatform.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/axion/AxionPlatform.java Sun Feb 24 18:17:57 2008
@@ -54,16 +54,16 @@
         info.setDelimitedIdentifiersSupported(false);
         info.setSqlCommentsSupported(false);
         info.setLastIdentityValueReadable(false);
-        info.addNativeTypeMapping(Types.ARRAY,         "BLOB",      Types.BLOB);
-        info.addNativeTypeMapping(Types.BIT,           "BOOLEAN");
-        info.addNativeTypeMapping(Types.DISTINCT,      "VARBINARY", Types.VARBINARY);
-        info.addNativeTypeMapping(Types.NULL,          "VARBINARY", Types.VARBINARY);
-        info.addNativeTypeMapping(Types.OTHER,         "BLOB",      Types.BLOB);
-        info.addNativeTypeMapping(Types.REAL,          "REAL",      Types.FLOAT);
-        info.addNativeTypeMapping(Types.REF,           "VARBINARY", Types.VARBINARY);
-        info.addNativeTypeMapping(Types.STRUCT,        "VARBINARY", Types.VARBINARY);
-        info.addNativeTypeMapping(Types.TINYINT,       "SMALLINT",  Types.SMALLINT);
-        info.addNativeTypeMapping("DATALINK", "VARBINARY", "VARBINARY");
+        info.addNativeTypeMapping(Types.ARRAY,    "BLOB",      Types.BLOB);
+        info.addNativeTypeMapping(Types.BIT,      "BOOLEAN");
+        info.addNativeTypeMapping(Types.DATALINK, "VARBINARY", Types.VARBINARY);
+        info.addNativeTypeMapping(Types.DISTINCT, "VARBINARY", Types.VARBINARY);
+        info.addNativeTypeMapping(Types.NULL,     "VARBINARY", Types.VARBINARY);
+        info.addNativeTypeMapping(Types.OTHER,    "BLOB",      Types.BLOB);
+        info.addNativeTypeMapping(Types.REAL,     "REAL",      Types.FLOAT);
+        info.addNativeTypeMapping(Types.REF,      "VARBINARY", Types.VARBINARY);
+        info.addNativeTypeMapping(Types.STRUCT,   "VARBINARY", Types.VARBINARY);
+        info.addNativeTypeMapping(Types.TINYINT,  "SMALLINT",  Types.SMALLINT);
 
         setSqlBuilder(new AxionBuilder(this));
         setModelReader(new AxionModelReader(this));

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/cloudscape/CloudscapePlatform.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/cloudscape/CloudscapePlatform.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/cloudscape/CloudscapePlatform.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/cloudscape/CloudscapePlatform.java Sun Feb 24 18:17:57 2008
@@ -52,13 +52,15 @@
         info.setMultipleIdentityColumnsSupported(false);
 
         // BINARY and VARBINARY will also be handled by CloudscapeBuilder.getSqlType
-        info.addNativeTypeMapping(Types.ARRAY,         "BLOB",                     Types.BLOB);
+        info.addNativeTypeMapping(Types.ARRAY,         "BLOB",                      Types.BLOB);
         info.addNativeTypeMapping(Types.BINARY,        "CHAR {0} FOR BIT DATA");
-        info.addNativeTypeMapping(Types.BIT,           "SMALLINT",                 Types.SMALLINT);
-        info.addNativeTypeMapping(Types.DISTINCT,      "BLOB",                     Types.BLOB);
+        info.addNativeTypeMapping(Types.BIT,           "SMALLINT",                  Types.SMALLINT);
+        info.addNativeTypeMapping(Types.BOOLEAN,       "SMALLINT",                  Types.SMALLINT);
+        info.addNativeTypeMapping(Types.DATALINK,      "LONG VARCHAR FOR BIT DATA", Types.LONGVARBINARY);
+        info.addNativeTypeMapping(Types.DISTINCT,      "BLOB",                      Types.BLOB);
         info.addNativeTypeMapping(Types.DOUBLE,        "DOUBLE PRECISION");
-        info.addNativeTypeMapping(Types.FLOAT,         "DOUBLE PRECISION",         Types.DOUBLE);
-        info.addNativeTypeMapping(Types.JAVA_OBJECT,   "BLOB",                     Types.BLOB);
+        info.addNativeTypeMapping(Types.FLOAT,         "DOUBLE PRECISION",          Types.DOUBLE);
+        info.addNativeTypeMapping(Types.JAVA_OBJECT,   "BLOB",                      Types.BLOB);
         info.addNativeTypeMapping(Types.LONGVARBINARY, "LONG VARCHAR FOR BIT DATA");
         info.addNativeTypeMapping(Types.LONGVARCHAR,   "LONG VARCHAR");
         info.addNativeTypeMapping(Types.NULL,          "LONG VARCHAR FOR BIT DATA", Types.LONGVARBINARY);
@@ -67,8 +69,6 @@
         info.addNativeTypeMapping(Types.STRUCT,        "BLOB",                      Types.BLOB);
         info.addNativeTypeMapping(Types.TINYINT,       "SMALLINT",                  Types.SMALLINT);
         info.addNativeTypeMapping(Types.VARBINARY,     "VARCHAR {0} FOR BIT DATA");
-        info.addNativeTypeMapping("BOOLEAN",  "SMALLINT",                  "SMALLINT");
-        info.addNativeTypeMapping("DATALINK", "LONG VARCHAR FOR BIT DATA", "LONGVARBINARY");
 
         info.setDefaultSize(Types.BINARY,    254);
         info.setDefaultSize(Types.CHAR,      254);

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/db2/Db2Builder.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/db2/Db2Builder.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/db2/Db2Builder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/db2/Db2Builder.java Sun Feb 24 18:17:57 2008
@@ -29,7 +29,6 @@
 import org.apache.ddlutils.model.Table;
 import org.apache.ddlutils.model.TypeMap;
 import org.apache.ddlutils.platform.SqlBuilder;
-import org.apache.ddlutils.util.Jdbc3Utils;
 
 /**
  * The SQL Builder for DB2.
@@ -54,10 +53,9 @@
      */
     protected String getNativeDefaultValue(Column column)
     {
-        if ((column.getTypeCode() == Types.BIT) ||
-            (Jdbc3Utils.supportsJava14JdbcTypes() && (column.getTypeCode() == Jdbc3Utils.determineBooleanTypeCode())))
+        if ((column.getTypeCode() == Types.BIT) || (column.getTypeCode() == Types.BOOLEAN))
         {
-            return getDefaultValueHelper().convert(column.getDefaultValue(), column.getTypeCode(), Types.SMALLINT).toString();
+            return getDefaultValueHelper().convert(column.getDefaultValue(), column.getTypeCode(), Types.SMALLINT);
         }
         else
         {

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/db2/Db2ModelReader.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/db2/Db2ModelReader.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/db2/Db2ModelReader.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/db2/Db2ModelReader.java Sun Feb 24 18:17:57 2008
@@ -22,7 +22,6 @@
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
-import java.sql.Statement;
 import java.sql.Types;
 import java.util.HashSet;
 import java.util.Map;
@@ -182,11 +181,13 @@
      */
     protected void determineAutoIncrementColumns(Table table) throws SQLException
     {
+        final String query = "SELECT COLNAME FROM SYSCAT.COLUMNS WHERE TABNAME = ? AND IDENTITY = 'Y' AND HIDDEN != 'S'";
+
         PreparedStatement stmt = null;
 
         try
         {
-            stmt = getConnection().prepareStatement("SELECT COLNAME FROM SYSCAT.COLUMNS WHERE TABNAME = ? AND IDENTITY = 'Y' AND HIDDEN != 'S'");
+            stmt = getConnection().prepareStatement(query);
             stmt.setString(1, table.getName());
 
             ResultSet rs = stmt.executeQuery();
@@ -201,14 +202,10 @@
                     column.setAutoIncrement(true);
                 }
             }
-            rs.close();
         }
         finally
         {
-            if (stmt != null)
-            {
-                stmt.close();
-            }
+            closeStatement(stmt);
         }
     }
 
@@ -251,10 +248,7 @@
             }
             finally
             {
-                if (pkData != null)
-                {
-                    pkData.close();
-                }
+                closeResultSet(pkData);
             }
 
             return pkNames.contains(index.getName());

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/db2/Db2Platform.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/db2/Db2Platform.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/db2/Db2Platform.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/db2/Db2Platform.java Sun Feb 24 18:17:57 2008
@@ -36,7 +36,7 @@
 import org.apache.ddlutils.platform.CreationParameters;
 import org.apache.ddlutils.platform.DefaultTableDefinitionChangesPredicate;
 import org.apache.ddlutils.platform.PlatformImplBase;
-import org.apache.ddlutils.util.StringUtils;
+import org.apache.ddlutils.util.StringUtilsExt;
 
 /**
  * The DB2 platform implementation.
@@ -79,6 +79,7 @@
         info.addNativeTypeMapping(Types.ARRAY,         "BLOB",                      Types.BLOB);
         info.addNativeTypeMapping(Types.BINARY,        "CHAR {0} FOR BIT DATA");
         info.addNativeTypeMapping(Types.BIT,           "SMALLINT",                  Types.SMALLINT);
+        info.addNativeTypeMapping(Types.BOOLEAN,       "SMALLINT",                  Types.SMALLINT);
         info.addNativeTypeMapping(Types.FLOAT,         "DOUBLE",                    Types.DOUBLE);
         info.addNativeTypeMapping(Types.JAVA_OBJECT,   "BLOB",                      Types.BLOB);
         info.addNativeTypeMapping(Types.LONGVARBINARY, "LONG VARCHAR FOR BIT DATA");
@@ -89,7 +90,6 @@
         info.addNativeTypeMapping(Types.STRUCT,        "BLOB",                      Types.BLOB);
         info.addNativeTypeMapping(Types.TINYINT,       "SMALLINT",                  Types.SMALLINT);
         info.addNativeTypeMapping(Types.VARBINARY,     "VARCHAR {0} FOR BIT DATA");
-        info.addNativeTypeMapping("BOOLEAN", "SMALLINT", "SMALLINT");
 
         info.setDefaultSize(Types.CHAR,      254);
         info.setDefaultSize(Types.VARCHAR,   254);
@@ -141,7 +141,7 @@
 
                     // DB2 cannot add IDENTITY columns, and required columns need a default value
                     return !addColumnChange.getNewColumn().isAutoIncrement() &&
-                           (!addColumnChange.getNewColumn().isRequired() || !StringUtils.isEmpty(addColumnChange.getNewColumn().getDefaultValue()));
+                           (!addColumnChange.getNewColumn().isRequired() || !StringUtilsExt.isEmpty(addColumnChange.getNewColumn().getDefaultValue()));
                 }
                 else
                 {

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/derby/DerbyBuilder.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/derby/DerbyBuilder.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/derby/DerbyBuilder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/derby/DerbyBuilder.java Sun Feb 24 18:17:57 2008
@@ -29,7 +29,6 @@
 import org.apache.ddlutils.model.Table;
 import org.apache.ddlutils.model.TypeMap;
 import org.apache.ddlutils.platform.cloudscape.CloudscapeBuilder;
-import org.apache.ddlutils.util.Jdbc3Utils;
 
 /**
  * The SQL Builder for Derby.
@@ -53,10 +52,9 @@
      */
     protected String getNativeDefaultValue(Column column)
     {
-        if ((column.getTypeCode() == Types.BIT) ||
-            (Jdbc3Utils.supportsJava14JdbcTypes() && (column.getTypeCode() == Jdbc3Utils.determineBooleanTypeCode())))
+        if ((column.getTypeCode() == Types.BIT) || (column.getTypeCode() == Types.BOOLEAN))
         {
-            return getDefaultValueHelper().convert(column.getDefaultValue(), column.getTypeCode(), Types.SMALLINT).toString();
+            return getDefaultValueHelper().convert(column.getDefaultValue(), column.getTypeCode(), Types.SMALLINT);
         }
         else
         {

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/firebird/FirebirdBuilder.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/firebird/FirebirdBuilder.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/firebird/FirebirdBuilder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/firebird/FirebirdBuilder.java Sun Feb 24 18:17:57 2008
@@ -29,7 +29,6 @@
 import org.apache.ddlutils.model.Index;
 import org.apache.ddlutils.model.Table;
 import org.apache.ddlutils.platform.SqlBuilder;
-import org.apache.ddlutils.util.Jdbc3Utils;
 
 /**
  * The SQL Builder for the FireBird database.
@@ -177,10 +176,9 @@
      */
     protected String getNativeDefaultValue(Column column)
     {
-        if ((column.getTypeCode() == Types.BIT) ||
-            (Jdbc3Utils.supportsJava14JdbcTypes() && (column.getTypeCode() == Jdbc3Utils.determineBooleanTypeCode())))
+        if ((column.getTypeCode() == Types.BIT) || (column.getTypeCode() == Types.BOOLEAN))
         {
-            return getDefaultValueHelper().convert(column.getDefaultValue(), column.getTypeCode(), Types.SMALLINT).toString();
+            return getDefaultValueHelper().convert(column.getDefaultValue(), column.getTypeCode(), Types.SMALLINT);
         }
         else
         {

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/firebird/FirebirdModelReader.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/firebird/FirebirdModelReader.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/firebird/FirebirdModelReader.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/firebird/FirebirdModelReader.java Sun Feb 24 18:17:57 2008
@@ -120,10 +120,7 @@
         }
         finally
         {
-            if (columnData != null)
-            {
-                columnData.close();
-            }
+            closeResultSet(columnData);
         }
     }
 
@@ -154,7 +151,9 @@
     {
     	// Since for long table and column names, the generator name will be shortened
     	// we have to determine for each column whether there is a generator for it
-    	FirebirdBuilder builder = (FirebirdBuilder)getPlatform().getSqlBuilder();
+        final String query = "SELECT RDB$GENERATOR_NAME FROM RDB$GENERATORS WHERE RDB$GENERATOR_NAME NOT LIKE '%$%'";
+
+        FirebirdBuilder builder = (FirebirdBuilder)getPlatform().getSqlBuilder();
     	Column[]        columns = table.getColumns();
     	HashMap         names   = new HashMap();
         String          name;
@@ -169,11 +168,13 @@
     		names.put(name, columns[idx]);
     	}
 
-    	Statement stmt = getConnection().createStatement();
+    	Statement stmt = null;
 
     	try
     	{
-            ResultSet rs = stmt.executeQuery("SELECT RDB$GENERATOR_NAME FROM RDB$GENERATORS WHERE RDB$GENERATOR_NAME NOT LIKE '%$%'");
+    	    stmt = getConnection().createStatement();
+
+    	    ResultSet rs = stmt.executeQuery(query);
 
             while (rs.next())
             {
@@ -185,11 +186,10 @@
                     column.setAutoIncrement(true);
                 }
             }
-    		rs.close();
     	}
         finally
         {
-            stmt.close();
+            closeStatement(stmt);
         }
     }
 
@@ -232,10 +232,7 @@
         }
         finally
         {
-            if (pkData != null)
-            {
-                pkData.close();
-            }
+            closeResultSet(pkData);
         }
         return pks;
     }
@@ -279,10 +276,7 @@
         }
         finally
         {
-            if (fkData != null)
-            {
-                fkData.close();
-            }
+            closeResultSet(fkData);
         }
         return fks.values();
     }
@@ -294,21 +288,21 @@
     {
         // Jaybird is not able to read indices when delimited identifiers are turned on,
         // so we gather the data manually using Firebird's system tables
-        Map          indices = new ListOrderedMap();
-        StringBuffer query   = new StringBuffer();
-        
-        query.append("SELECT a.RDB$INDEX_NAME INDEX_NAME, b.RDB$RELATION_NAME TABLE_NAME, b.RDB$UNIQUE_FLAG NON_UNIQUE,");
-        query.append(" a.RDB$FIELD_POSITION ORDINAL_POSITION, a.RDB$FIELD_NAME COLUMN_NAME, 3 INDEX_TYPE");
-        query.append(" FROM RDB$INDEX_SEGMENTS a, RDB$INDICES b WHERE a.RDB$INDEX_NAME=b.RDB$INDEX_NAME AND b.RDB$RELATION_NAME = ?");
-
-        PreparedStatement stmt      = getConnection().prepareStatement(query.toString());
-        ResultSet         indexData = null;
+        final String query =
+            "SELECT a.RDB$INDEX_NAME INDEX_NAME, b.RDB$RELATION_NAME TABLE_NAME, b.RDB$UNIQUE_FLAG NON_UNIQUE, " +
+            "a.RDB$FIELD_POSITION ORDINAL_POSITION, a.RDB$FIELD_NAME COLUMN_NAME, 3 INDEX_TYPE " +
+            "FROM RDB$INDEX_SEGMENTS a, RDB$INDICES b WHERE a.RDB$INDEX_NAME=b.RDB$INDEX_NAME AND b.RDB$RELATION_NAME = ?";
 
-        stmt.setString(1, getPlatform().isDelimitedIdentifierModeOn() ? tableName : tableName.toUpperCase());
+        Map               indices = new ListOrderedMap();
+        PreparedStatement stmt    = null;
 
-        try 
+        try
         {
-        	indexData = stmt.executeQuery();
+            stmt = getConnection().prepareStatement(query);
+
+            stmt.setString(1, getPlatform().isDelimitedIdentifierModeOn() ? tableName : tableName.toUpperCase());
+
+            ResultSet indexData = stmt.executeQuery();
 
             while (indexData.next())
             {
@@ -325,10 +319,7 @@
         }
         finally
         {
-            if (indexData != null)
-            {
-                indexData.close();
-            }
+            closeStatement(stmt);
         }
         return indices.values();
     }
@@ -338,16 +329,17 @@
      */
     protected boolean isInternalPrimaryKeyIndex(DatabaseMetaDataWrapper metaData, Table table, Index index) throws SQLException
     {
-        String       tableName = getPlatform().getSqlBuilder().getTableName(table);
-        String       indexName = getPlatform().getSqlBuilder().getIndexName(index);
-        StringBuffer query     = new StringBuffer();
-
-        query.append("SELECT RDB$CONSTRAINT_NAME FROM RDB$RELATION_CONSTRAINTS where RDB$RELATION_NAME=? AND RDB$CONSTRAINT_TYPE=? AND RDB$INDEX_NAME=?");
-
-        PreparedStatement stmt = getConnection().prepareStatement(query.toString());
+        final String query =
+            "SELECT RDB$CONSTRAINT_NAME FROM RDB$RELATION_CONSTRAINTS " +
+            "WHERE RDB$RELATION_NAME=? AND RDB$CONSTRAINT_TYPE=? AND RDB$INDEX_NAME=?";
+
+        String            tableName = getPlatform().getSqlBuilder().getTableName(table);
+        String            indexName = getPlatform().getSqlBuilder().getIndexName(index);
+        PreparedStatement stmt      = null;
 
         try 
         {
+            stmt = getConnection().prepareStatement(query);
             stmt.setString(1, getPlatform().isDelimitedIdentifierModeOn() ? tableName : tableName.toUpperCase());
             stmt.setString(2, "PRIMARY KEY");
             stmt.setString(3, indexName);
@@ -358,10 +350,7 @@
         }
         finally
         {
-            if (stmt != null)
-            {
-                stmt.close();
-            }
+            closeStatement(stmt);
         }
     }
 
@@ -370,17 +359,18 @@
      */
     protected boolean isInternalForeignKeyIndex(DatabaseMetaDataWrapper metaData, Table table, ForeignKey fk, Index index) throws SQLException
     {
-        String       tableName = getPlatform().getSqlBuilder().getTableName(table);
-        String       indexName = getPlatform().getSqlBuilder().getIndexName(index);
-        String       fkName    = getPlatform().getSqlBuilder().getForeignKeyName(table, fk);
-        StringBuffer query     = new StringBuffer();
-
-        query.append("SELECT RDB$CONSTRAINT_NAME FROM RDB$RELATION_CONSTRAINTS where RDB$RELATION_NAME=? AND RDB$CONSTRAINT_TYPE=? AND RDB$CONSTRAINT_NAME=? AND RDB$INDEX_NAME=?");
-
-        PreparedStatement stmt = getConnection().prepareStatement(query.toString());
+        final String query =
+            "SELECT RDB$CONSTRAINT_NAME FROM RDB$RELATION_CONSTRAINTS " +
+            "WHERE RDB$RELATION_NAME=? AND RDB$CONSTRAINT_TYPE=? AND RDB$CONSTRAINT_NAME=? AND RDB$INDEX_NAME=?";
+
+        String            tableName = getPlatform().getSqlBuilder().getTableName(table);
+        String            indexName = getPlatform().getSqlBuilder().getIndexName(index);
+        String            fkName    = getPlatform().getSqlBuilder().getForeignKeyName(table, fk);
+        PreparedStatement stmt      = null;
 
         try 
         {
+            stmt = getConnection().prepareStatement(query);
             stmt.setString(1, getPlatform().isDelimitedIdentifierModeOn() ? tableName : tableName.toUpperCase());
             stmt.setString(2, "FOREIGN KEY");
             stmt.setString(3, fkName);
@@ -392,10 +382,7 @@
         }
         finally
         {
-            if (stmt != null)
-            {
-                stmt.close();
-            }
+            closeStatement(stmt);
         }
     }
 
@@ -466,7 +453,7 @@
                             found = false;
                         }
                     }
-                    columnData.close();
+                    closeResultSet(columnData);
                     columnData = null;
                 }
             }
@@ -474,14 +461,8 @@
         }
         finally
         {
-            if (columnData != null)
-            {
-                columnData.close();
-            }
-            if (tableData != null)
-            {
-                tableData.close();
-            }
+            closeResultSet(columnData);
+            closeResultSet(tableData);
         }
     }
 }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/firebird/FirebirdPlatform.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/firebird/FirebirdPlatform.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/firebird/FirebirdPlatform.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/firebird/FirebirdPlatform.java Sun Feb 24 18:17:57 2008
@@ -71,9 +71,11 @@
         info.addNativeTypeMapping(Types.ARRAY,         "BLOB",               Types.LONGVARBINARY);
         info.addNativeTypeMapping(Types.BINARY,        "BLOB",               Types.LONGVARBINARY);
         info.addNativeTypeMapping(Types.BIT,           "SMALLINT",           Types.SMALLINT);
+        info.addNativeTypeMapping(Types.BLOB,          "BLOB",               Types.LONGVARBINARY);
+        info.addNativeTypeMapping(Types.BOOLEAN,       "SMALLINT",           Types.SMALLINT);
         info.addNativeTypeMapping(Types.CLOB,          "BLOB SUB_TYPE TEXT", Types.LONGVARCHAR);
+        info.addNativeTypeMapping(Types.DATALINK,      "BLOB",               Types.LONGVARBINARY);
         info.addNativeTypeMapping(Types.DISTINCT,      "BLOB",               Types.LONGVARBINARY);
-        info.addNativeTypeMapping(Types.BLOB,          "BLOB",               Types.LONGVARBINARY);
         info.addNativeTypeMapping(Types.DOUBLE,        "DOUBLE PRECISION");
         info.addNativeTypeMapping(Types.FLOAT,         "DOUBLE PRECISION",   Types.DOUBLE);
         info.addNativeTypeMapping(Types.JAVA_OBJECT,   "BLOB",               Types.LONGVARBINARY);
@@ -87,9 +89,6 @@
         info.addNativeTypeMapping(Types.STRUCT,        "BLOB",               Types.LONGVARBINARY);
         info.addNativeTypeMapping(Types.TINYINT,       "SMALLINT",           Types.SMALLINT);
         info.addNativeTypeMapping(Types.VARBINARY,     "BLOB",               Types.LONGVARBINARY);
-        
-        info.addNativeTypeMapping("BOOLEAN",  "SMALLINT", "SMALLINT");
-        info.addNativeTypeMapping("DATALINK", "BLOB",     "LONGVARBINARY");
 
         info.setDefaultSize(Types.VARCHAR, 254);
         info.setDefaultSize(Types.CHAR,    254);

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/hsqldb/HsqlDbPlatform.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/hsqldb/HsqlDbPlatform.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/hsqldb/HsqlDbPlatform.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/hsqldb/HsqlDbPlatform.java Sun Feb 24 18:17:57 2008
@@ -68,8 +68,10 @@
         info.setMixingIdentityAndNormalPrimaryKeyColumnsSupported(false);
 
         info.addNativeTypeMapping(Types.ARRAY,       "LONGVARBINARY", Types.LONGVARBINARY);
+        info.addNativeTypeMapping(Types.BIT,         "BOOLEAN",       Types.BOOLEAN);
         info.addNativeTypeMapping(Types.BLOB,        "LONGVARBINARY", Types.LONGVARBINARY);
         info.addNativeTypeMapping(Types.CLOB,        "LONGVARCHAR",   Types.LONGVARCHAR);
+        info.addNativeTypeMapping(Types.DATALINK,    "LONGVARBINARY", Types.LONGVARBINARY);
         info.addNativeTypeMapping(Types.DISTINCT,    "LONGVARBINARY", Types.LONGVARBINARY);
         info.addNativeTypeMapping(Types.FLOAT,       "DOUBLE",        Types.DOUBLE);
         info.addNativeTypeMapping(Types.JAVA_OBJECT, "OBJECT");
@@ -78,9 +80,6 @@
         info.addNativeTypeMapping(Types.STRUCT,      "LONGVARBINARY", Types.LONGVARBINARY);
         // JDBC's TINYINT requires a value range of -255 to 255, but HsqlDb's is only -128 to 127
         info.addNativeTypeMapping(Types.TINYINT,     "SMALLINT",      Types.SMALLINT);
-
-        info.addNativeTypeMapping("BIT",      "BOOLEAN",       "BOOLEAN");
-        info.addNativeTypeMapping("DATALINK", "LONGVARBINARY", "LONGVARBINARY");
 
         info.setDefaultSize(Types.CHAR,      Integer.MAX_VALUE);
         info.setDefaultSize(Types.VARCHAR,   Integer.MAX_VALUE);

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/interbase/InterbaseBuilder.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/interbase/InterbaseBuilder.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/interbase/InterbaseBuilder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/interbase/InterbaseBuilder.java Sun Feb 24 18:17:57 2008
@@ -29,7 +29,6 @@
 import org.apache.ddlutils.model.Index;
 import org.apache.ddlutils.model.Table;
 import org.apache.ddlutils.platform.SqlBuilder;
-import org.apache.ddlutils.util.Jdbc3Utils;
 
 /**
  * The SQL Builder for the Interbase database.
@@ -70,10 +69,9 @@
      */
     protected String getNativeDefaultValue(Column column)
     {
-        if ((column.getTypeCode() == Types.BIT) ||
-            (Jdbc3Utils.supportsJava14JdbcTypes() && (column.getTypeCode() == Jdbc3Utils.determineBooleanTypeCode())))
+        if ((column.getTypeCode() == Types.BIT) || (column.getTypeCode() == Types.BOOLEAN))
         {
-            return getDefaultValueHelper().convert(column.getDefaultValue(), column.getTypeCode(), Types.SMALLINT).toString();
+            return getDefaultValueHelper().convert(column.getDefaultValue(), column.getTypeCode(), Types.SMALLINT);
         }
         else
         {

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/interbase/InterbaseModelReader.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/interbase/InterbaseModelReader.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/interbase/InterbaseModelReader.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/interbase/InterbaseModelReader.java Sun Feb 24 18:17:57 2008
@@ -123,10 +123,7 @@
         }
         finally
         {
-            if (columnData != null)
-            {
-                columnData.close();
-            }
+            closeResultSet(columnData);
         }
     }
 
@@ -137,16 +134,16 @@
      */
     protected void determineExtraColumnInfo(Table table) throws SQLException
     {
-        StringBuffer query   = new StringBuffer();
-        
-        query.append("SELECT a.RDB$FIELD_NAME, a.RDB$DEFAULT_SOURCE, b.RDB$FIELD_PRECISION, b.RDB$FIELD_SCALE,");
-        query.append(" b.RDB$FIELD_TYPE, b.RDB$FIELD_SUB_TYPE FROM RDB$RELATION_FIELDS a, RDB$FIELDS b");
-        query.append(" WHERE a.RDB$RELATION_NAME=? AND a.RDB$FIELD_SOURCE=b.RDB$FIELD_NAME");
+        final String query =
+            "SELECT a.RDB$FIELD_NAME, a.RDB$DEFAULT_SOURCE, b.RDB$FIELD_PRECISION, b.RDB$FIELD_SCALE," +
+            " b.RDB$FIELD_TYPE, b.RDB$FIELD_SUB_TYPE FROM RDB$RELATION_FIELDS a, RDB$FIELDS b" +
+            " WHERE a.RDB$RELATION_NAME=? AND a.RDB$FIELD_SOURCE=b.RDB$FIELD_NAME";
 
-        PreparedStatement prepStmt = getConnection().prepareStatement(query.toString());
+        PreparedStatement prepStmt = null;
 
         try
         {
+            prepStmt = getConnection().prepareStatement(query);
             prepStmt.setString(1, getPlatform().isDelimitedIdentifierModeOn() ? table.getName() : table.getName().toUpperCase());
 
             ResultSet rs = prepStmt.executeQuery();
@@ -191,11 +188,10 @@
                     }
                 }
             }
-            rs.close();
         }
         finally
         {
-            prepStmt.close();
+            closeStatement(prepStmt);
         }
     }
 
@@ -208,6 +204,8 @@
     {
         // Since for long table and column names, the generator name will be shortened
         // we have to determine for each column whether there is a generator for it
+        final String query = "SELECT RDB$GENERATOR_NAME FROM RDB$GENERATORS";
+
         InterbaseBuilder builder = (InterbaseBuilder)getPlatform().getSqlBuilder();
         Column[]         columns = table.getColumns();
         HashMap          names   = new HashMap();
@@ -223,11 +221,13 @@
             names.put(name, columns[idx]);
         }
 
-        Statement stmt = getConnection().createStatement();
+        Statement stmt = null;
 
         try
         {
-            ResultSet rs = stmt.executeQuery("SELECT RDB$GENERATOR_NAME FROM RDB$GENERATORS");
+            stmt = getConnection().createStatement();
+
+            ResultSet rs = stmt.executeQuery(query);
 
             while (rs.next())
             {
@@ -239,11 +239,10 @@
                     column.setAutoIncrement(true);
                 }
             }
-            rs.close();
         }
         finally
         {
-            stmt.close();
+            closeStatement(stmt);
         }
     }
 
@@ -315,10 +314,7 @@
         }
         finally
         {
-            if (pkData != null)
-            {
-                pkData.close();
-            }
+            closeResultSet(pkData);
         }
         return pks;
     }
@@ -362,10 +358,7 @@
         }
         finally
         {
-            if (fkData != null)
-            {
-                fkData.close();
-            }
+            closeResultSet(fkData);
         }
         return fks.values();
     }
@@ -375,16 +368,17 @@
      */
     protected boolean isInternalPrimaryKeyIndex(DatabaseMetaDataWrapper metaData, Table table, Index index) throws SQLException
     {
-        String       tableName = getPlatform().getSqlBuilder().getTableName(table);
-        String       indexName = getPlatform().getSqlBuilder().getIndexName(index);
-        StringBuffer query     = new StringBuffer();
-
-        query.append("SELECT RDB$CONSTRAINT_NAME FROM RDB$RELATION_CONSTRAINTS where RDB$RELATION_NAME=? AND RDB$CONSTRAINT_TYPE=? AND RDB$INDEX_NAME=?");
-
-        PreparedStatement stmt = getConnection().prepareStatement(query.toString());
+        final String query =
+            "SELECT RDB$CONSTRAINT_NAME FROM RDB$RELATION_CONSTRAINTS " +
+            "WHERE RDB$RELATION_NAME=? AND RDB$CONSTRAINT_TYPE=? AND RDB$INDEX_NAME=?";
+
+        String            tableName = getPlatform().getSqlBuilder().getTableName(table);
+        String            indexName = getPlatform().getSqlBuilder().getIndexName(index);
+        PreparedStatement stmt      = null;
 
         try 
         {
+            stmt = getConnection().prepareStatement(query);
             stmt.setString(1, getPlatform().isDelimitedIdentifierModeOn() ? tableName : tableName.toUpperCase());
             stmt.setString(2, "PRIMARY KEY");
             stmt.setString(3, indexName);
@@ -395,10 +389,7 @@
         }
         finally
         {
-            if (stmt != null)
-            {
-                stmt.close();
-            }
+            closeStatement(stmt);
         }
     }
 
@@ -407,17 +398,18 @@
      */
     protected boolean isInternalForeignKeyIndex(DatabaseMetaDataWrapper metaData, Table table, ForeignKey fk, Index index) throws SQLException
     {
-        String       tableName = getPlatform().getSqlBuilder().getTableName(table);
-        String       indexName = getPlatform().getSqlBuilder().getIndexName(index);
-        String       fkName    = getPlatform().getSqlBuilder().getForeignKeyName(table, fk);
-        StringBuffer query     = new StringBuffer();
-
-        query.append("SELECT RDB$CONSTRAINT_NAME FROM RDB$RELATION_CONSTRAINTS where RDB$RELATION_NAME=? AND RDB$CONSTRAINT_TYPE=? AND RDB$CONSTRAINT_NAME=? AND RDB$INDEX_NAME=?");
-
-        PreparedStatement stmt = getConnection().prepareStatement(query.toString());
+        final String query =
+            "SELECT RDB$CONSTRAINT_NAME FROM RDB$RELATION_CONSTRAINTS " +
+            "WHERE RDB$RELATION_NAME=? AND RDB$CONSTRAINT_TYPE=? AND RDB$CONSTRAINT_NAME=? AND RDB$INDEX_NAME=?";
+
+        String            tableName = getPlatform().getSqlBuilder().getTableName(table);
+        String            indexName = getPlatform().getSqlBuilder().getIndexName(index);
+        String            fkName    = getPlatform().getSqlBuilder().getForeignKeyName(table, fk);
+        PreparedStatement stmt      = null;
 
         try 
         {
+            stmt = getConnection().prepareStatement(query);
             stmt.setString(1, getPlatform().isDelimitedIdentifierModeOn() ? tableName : tableName.toUpperCase());
             stmt.setString(2, "FOREIGN KEY");
             stmt.setString(3, fkName);
@@ -429,10 +421,7 @@
         }
         finally
         {
-            if (stmt != null)
-            {
-                stmt.close();
-            }
+            closeStatement(stmt);
         }
     }
 
@@ -511,14 +500,8 @@
         }
         finally
         {
-            if (columnData != null)
-            {
-                columnData.close();
-            }
-            if (tableData != null)
-            {
-                tableData.close();
-            }
+            closeResultSet(columnData);
+            closeResultSet(tableData);
         }
     }
 }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/interbase/InterbasePlatform.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/interbase/InterbasePlatform.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/interbase/InterbasePlatform.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/interbase/InterbasePlatform.java Sun Feb 24 18:17:57 2008
@@ -82,7 +82,9 @@
         info.addNativeTypeMapping(Types.BINARY,        "BLOB",               Types.LONGVARBINARY);
         info.addNativeTypeMapping(Types.BIT,           "SMALLINT",           Types.SMALLINT);
         info.addNativeTypeMapping(Types.BLOB,          "BLOB",               Types.LONGVARBINARY);
+        info.addNativeTypeMapping(Types.BOOLEAN,       "SMALLINT",           Types.SMALLINT);
         info.addNativeTypeMapping(Types.CLOB,          "BLOB SUB_TYPE TEXT");
+        info.addNativeTypeMapping(Types.DATALINK,      "BLOB",               Types.LONGVARBINARY);
         info.addNativeTypeMapping(Types.DISTINCT,      "BLOB",               Types.LONGVARBINARY);
         info.addNativeTypeMapping(Types.DOUBLE,        "DOUBLE PRECISION");
         info.addNativeTypeMapping(Types.FLOAT,         "DOUBLE PRECISION",   Types.DOUBLE);
@@ -96,8 +98,6 @@
         info.addNativeTypeMapping(Types.STRUCT,        "BLOB",               Types.LONGVARBINARY);
         info.addNativeTypeMapping(Types.TINYINT,       "SMALLINT",           Types.SMALLINT);
         info.addNativeTypeMapping(Types.VARBINARY,     "BLOB",               Types.LONGVARBINARY);
-        info.addNativeTypeMapping("BOOLEAN",  "SMALLINT", "SMALLINT");
-        info.addNativeTypeMapping("DATALINK", "BLOB",     "LONGVARBINARY");
 
         info.setDefaultSize(Types.CHAR,    254);
         info.setDefaultSize(Types.VARCHAR, 254);
@@ -154,10 +154,12 @@
             case Types.BINARY:
             case Types.VARBINARY:
             case Types.BLOB:
+                BufferedInputStream input = null;
+
                 try
                 {
-                    BufferedInputStream input = new BufferedInputStream(useIdx ? resultSet.getBinaryStream(columnIdx) : resultSet.getBinaryStream(columnName));
-        
+                    input = new BufferedInputStream(useIdx ? resultSet.getBinaryStream(columnIdx) : resultSet.getBinaryStream(columnName));
+
                     if (resultSet.wasNull())
                     {
                         return null;
@@ -177,6 +179,20 @@
                 catch (IOException ex)
                 {
                     throw new DdlUtilsException(ex);
+                }
+                finally
+                {
+                    if (input != null)
+                    {
+                        try
+                        {
+                            input.close();
+                        }
+                        catch (IOException ex)
+                        {
+                            getLog().error("Could not close binary stream read from result set", ex);
+                        }
+                    }
                 }
             case Types.LONGVARCHAR:
             case Types.CLOB:

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mckoi/MckoiModelReader.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mckoi/MckoiModelReader.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mckoi/MckoiModelReader.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mckoi/MckoiModelReader.java Sun Feb 24 18:17:57 2008
@@ -19,13 +19,15 @@
  * under the License.
  */
 
+import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
-import java.sql.Statement;
 import java.util.HashMap;
 import java.util.Map;
 
 import org.apache.commons.collections.map.ListOrderedMap;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 import org.apache.ddlutils.Platform;
 import org.apache.ddlutils.model.Column;
 import org.apache.ddlutils.model.Table;
@@ -40,6 +42,9 @@
  */
 public class MckoiModelReader extends JdbcModelReader
 {
+    /** The log. */
+    protected Log _log = LogFactory.getLog(MckoiModelReader.class);
+
     /**
      * Creates a new model reader for Mckoi databases.
      * 
@@ -57,40 +62,48 @@
      */
     protected Table readTable(DatabaseMetaDataWrapper metaData, Map values) throws SQLException
     {
+        // Mckoi does not currently return unique indices in the metadata so we have to query
+        // internal tables to get this info
+        final String query =
+            "SELECT uniqueColumns.column, uniqueColumns.seq_no, uniqueInfo.name" +
+            " FROM SYS_INFO.sUSRUniqueColumns uniqueColumns, SYS_INFO.sUSRUniqueInfo uniqueInfo" +
+            " WHERE uniqueColumns.un_id = uniqueInfo.id AND uniqueInfo.table = ?";
+        final String queryWithSchema =
+            query + " AND uniqueInfo.schema = ?";
+
         Table table = super.readTable(metaData, values);
 
         if (table != null)
         {
-            // Mckoi does not currently return unique indices in the metadata so we have to query
-            // internal tables to get this info
-            StringBuffer query = new StringBuffer();
-        
-            query.append("SELECT uniqueColumns.column, uniqueColumns.seq_no, uniqueInfo.name");
-            query.append(" FROM SYS_INFO.sUSRUniqueColumns uniqueColumns, SYS_INFO.sUSRUniqueInfo uniqueInfo");
-            query.append(" WHERE uniqueColumns.un_id = uniqueInfo.id AND uniqueInfo.table = '");
-            query.append(table.getName());
-            if (table.getSchema() != null)
+            Map               indices = new ListOrderedMap();
+            PreparedStatement stmt    = null;
+
+            try
             {
-                query.append("' AND uniqueInfo.schema = '");
-                query.append(table.getSchema());
+                stmt = getConnection().prepareStatement(table.getSchema() == null ? query : queryWithSchema);
+                stmt.setString(1, table.getName());
+                if (table.getSchema() != null)
+                {
+                    stmt.setString(2, table.getSchema());
+                }
+    
+                ResultSet  resultSet   = stmt.executeQuery();
+                Map        indexValues = new HashMap();
+            
+                indexValues.put("NON_UNIQUE", Boolean.FALSE);
+                while (resultSet.next())
+                {
+                    indexValues.put("COLUMN_NAME",      resultSet.getString(1));
+                    indexValues.put("ORDINAL_POSITION", new Short(resultSet.getShort(2)));
+                    indexValues.put("INDEX_NAME",       resultSet.getString(3));
+            
+                    readIndex(metaData, indexValues, indices);
+                }
             }
-            query.append("'");
-        
-            Statement stmt        = getConnection().createStatement();
-            ResultSet resultSet   = stmt.executeQuery(query.toString());
-            Map       indices     = new ListOrderedMap();
-            Map       indexValues = new HashMap();
-        
-            indexValues.put("NON_UNIQUE", Boolean.FALSE);
-            while (resultSet.next())
+            finally
             {
-                indexValues.put("COLUMN_NAME",      resultSet.getString(1));
-                indexValues.put("ORDINAL_POSITION", new Short(resultSet.getShort(2)));
-                indexValues.put("INDEX_NAME",       resultSet.getString(3));
-        
-                readIndex(metaData, indexValues, indices);
+                closeStatement(stmt);
             }
-            resultSet.close();
         
             table.addIndices(indices.values());
         }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mckoi/MckoiPlatform.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mckoi/MckoiPlatform.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mckoi/MckoiPlatform.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mckoi/MckoiPlatform.java Sun Feb 24 18:17:57 2008
@@ -69,15 +69,15 @@
         info.setDefaultValueUsedForIdentitySpec(true);
         info.setAutoCommitModeForLastIdentityValueReading(false);
 
-        info.addNativeTypeMapping(Types.ARRAY,    "BLOB",   Types.BLOB);
-        info.addNativeTypeMapping(Types.DISTINCT, "BLOB",   Types.BLOB);
-        info.addNativeTypeMapping(Types.FLOAT,    "DOUBLE", Types.DOUBLE);
-        info.addNativeTypeMapping(Types.NULL,     "BLOB",   Types.BLOB);
-        info.addNativeTypeMapping(Types.OTHER,    "BLOB",   Types.BLOB);
-        info.addNativeTypeMapping(Types.REF,      "BLOB",   Types.BLOB);
-        info.addNativeTypeMapping(Types.STRUCT,   "BLOB",   Types.BLOB);
-        info.addNativeTypeMapping("BIT",      "BOOLEAN", "BOOLEAN");
-        info.addNativeTypeMapping("DATALINK", "BLOB",    "BLOB");
+        info.addNativeTypeMapping(Types.ARRAY,    "BLOB",    Types.BLOB);
+        info.addNativeTypeMapping(Types.BIT,      "BOOLEAN", Types.BOOLEAN);
+        info.addNativeTypeMapping(Types.DATALINK, "BLOB",    Types.BLOB);
+        info.addNativeTypeMapping(Types.DISTINCT, "BLOB",    Types.BLOB);
+        info.addNativeTypeMapping(Types.FLOAT,    "DOUBLE",  Types.DOUBLE);
+        info.addNativeTypeMapping(Types.NULL,     "BLOB",    Types.BLOB);
+        info.addNativeTypeMapping(Types.OTHER,    "BLOB",    Types.BLOB);
+        info.addNativeTypeMapping(Types.REF,      "BLOB",    Types.BLOB);
+        info.addNativeTypeMapping(Types.STRUCT,   "BLOB",    Types.BLOB);
 
         info.setDefaultSize(Types.CHAR,      1024);
         info.setDefaultSize(Types.VARCHAR,   1024);

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mssql/MSSqlBuilder.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mssql/MSSqlBuilder.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mssql/MSSqlBuilder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mssql/MSSqlBuilder.java Sun Feb 24 18:17:57 2008
@@ -34,7 +34,6 @@
 import org.apache.ddlutils.model.Index;
 import org.apache.ddlutils.model.Table;
 import org.apache.ddlutils.platform.SqlBuilder;
-import org.apache.ddlutils.util.Jdbc3Utils;
 
 /**
  * The SQL Builder for the Microsoft SQL Server.
@@ -188,10 +187,9 @@
     protected String getNativeDefaultValue(Column column)
     {
     	// Sql Server wants BIT default values as 0 or 1
-        if ((column.getTypeCode() == Types.BIT) ||
-            (Jdbc3Utils.supportsJava14JdbcTypes() && (column.getTypeCode() == Jdbc3Utils.determineBooleanTypeCode())))
+        if ((column.getTypeCode() == Types.BIT) || (column.getTypeCode() == Types.BOOLEAN))
         {
-            return getDefaultValueHelper().convert(column.getDefaultValue(), column.getTypeCode(), Types.SMALLINT).toString();
+            return getDefaultValueHelper().convert(column.getDefaultValue(), column.getTypeCode(), Types.SMALLINT);
         }
         else
         {



Mime
View raw message