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 [2/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
Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mssql/MSSqlModelComparator.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mssql/MSSqlModelComparator.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mssql/MSSqlModelComparator.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mssql/MSSqlModelComparator.java Sun Feb 24 18:17:57 2008
@@ -38,7 +38,7 @@
 import org.apache.ddlutils.model.Index;
 import org.apache.ddlutils.model.IndexColumn;
 import org.apache.ddlutils.model.Table;
-import org.apache.ddlutils.util.StringUtils;
+import org.apache.ddlutils.util.StringUtilsExt;
 
 /**
  * A model comparator customized for Sql Server.
@@ -304,12 +304,12 @@
                 }
                 else
                 {
-                    if (sizeMatters && !StringUtils.equals(sourceColumn.getSize(), targetColumn.getSize()))
+                    if (sizeMatters && !StringUtilsExt.equals(sourceColumn.getSize(), targetColumn.getSize()))
                     {
                         hasChange = true;
                     }
                     else if (scaleMatters &&
-                             (!StringUtils.equals(sourceColumn.getSize(), targetColumn.getSize()) ||
+                             (!StringUtilsExt.equals(sourceColumn.getSize(), targetColumn.getSize()) ||
                               (sourceColumn.getScale() != targetColumn.getScale())))
                     {
                         hasChange = true;

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mssql/MSSqlModelReader.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mssql/MSSqlModelReader.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mssql/MSSqlModelReader.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mssql/MSSqlModelReader.java Sun Feb 24 18:17:57 2008
@@ -146,26 +146,26 @@
      * @param name     The pk name
      * @return <code>true</code> if there is such a pk
      */
-    private boolean existsPKWithName(DatabaseMetaDataWrapper metaData, Table table, String name)
+    private boolean existsPKWithName(DatabaseMetaDataWrapper metaData, Table table, String name) throws SQLException
     {
+        ResultSet pks = null;
+
         try
         {
-            ResultSet pks   = metaData.getPrimaryKeys(table.getName());
-            boolean   found = false;
-    
-            while (pks.next() && !found)
+            pks = metaData.getPrimaryKeys(table.getName());
+
+            while (pks.next())
             {
                 if (name.equals(pks.getString("PK_NAME")))
                 {
-                    found = true;
+                    return true;
                 }
             }
-            pks.close();
-            return found;
+            return false;
         }
-        catch (SQLException ex)
+        finally
         {
-            throw new DdlUtilsException(ex);
+            closeResultSet(pks);
         }
     }
     

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mssql/MSSqlPlatform.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mssql/MSSqlPlatform.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mssql/MSSqlPlatform.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mssql/MSSqlPlatform.java Sun Feb 24 18:17:57 2008
@@ -80,7 +80,9 @@
         // BIGINT will be mapped back to BIGINT by the model reader 
         info.addNativeTypeMapping(Types.BIGINT,        "DECIMAL(19,0)");
         info.addNativeTypeMapping(Types.BLOB,          "IMAGE",         Types.LONGVARBINARY);
+        info.addNativeTypeMapping(Types.BOOLEAN,       "BIT",           Types.BIT);
         info.addNativeTypeMapping(Types.CLOB,          "TEXT",          Types.LONGVARCHAR);
+        info.addNativeTypeMapping(Types.DATALINK,      "IMAGE",         Types.LONGVARBINARY);
         info.addNativeTypeMapping(Types.DATE,          "DATETIME",      Types.TIMESTAMP);
         info.addNativeTypeMapping(Types.DISTINCT,      "IMAGE",         Types.LONGVARBINARY);
         info.addNativeTypeMapping(Types.DOUBLE,        "FLOAT",         Types.FLOAT);
@@ -95,8 +97,6 @@
         info.addNativeTypeMapping(Types.TIME,          "DATETIME",      Types.TIMESTAMP);
         info.addNativeTypeMapping(Types.TIMESTAMP,     "DATETIME");
         info.addNativeTypeMapping(Types.TINYINT,       "SMALLINT",      Types.SMALLINT);
-        info.addNativeTypeMapping("BOOLEAN",  "BIT",   "BIT");
-        info.addNativeTypeMapping("DATALINK", "IMAGE", "LONGVARBINARY");
 
         info.setDefaultSize(Types.CHAR,       254);
         info.setDefaultSize(Types.VARCHAR,    254);

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlBuilder.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlBuilder.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlBuilder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlBuilder.java Sun Feb 24 18:17:57 2008
@@ -31,7 +31,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 MySQL.
@@ -244,6 +243,7 @@
             switch (targetColumn.getTypeCode())
             {
                 case Types.BIT:
+                case Types.BOOLEAN:
                 case Types.TINYINT:
                 case Types.SMALLINT:
                 case Types.INTEGER:
@@ -272,15 +272,7 @@
                     targetNativeType = "CHAR";
                     break;
                 default:
-                    if (Jdbc3Utils.supportsJava14JdbcTypes() &&
-                        (targetColumn.getTypeCode() == Jdbc3Utils.determineBooleanTypeCode()))
-                    {
-                        targetNativeType = "SIGNED";
-                    }
-                    else
-                    {
-                        targetNativeType = "BINARY";
-                    }
+                    targetNativeType = "BINARY";
                     break;
             }
 

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlModelComparator.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlModelComparator.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlModelComparator.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlModelComparator.java Sun Feb 24 18:17:57 2008
@@ -38,7 +38,7 @@
 import org.apache.ddlutils.model.Index;
 import org.apache.ddlutils.model.Reference;
 import org.apache.ddlutils.model.Table;
-import org.apache.ddlutils.util.StringUtils;
+import org.apache.ddlutils.util.StringUtilsExt;
 
 /**
  * A model comparator customized for MySql.
@@ -157,7 +157,7 @@
 
                     for (Iterator colNameIt = columnNames.iterator(); colNameIt.hasNext();)
                     {
-                        if (StringUtils.equals(ref.getLocalColumnName(), (String)colNameIt.next(), isCaseSensitive()))
+                        if (StringUtilsExt.equals(ref.getLocalColumnName(), (String)colNameIt.next(), isCaseSensitive()))
                         {
                             newChanges.add(new RemoveForeignKeyChange(intermediateTable.getName(), intermediateFk));
                             newChanges.add(new AddForeignKeyChange(intermediateTable.getName(), intermediateFk));

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlPlatform.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlPlatform.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlPlatform.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/mysql/MySqlPlatform.java Sun Feb 24 18:17:57 2008
@@ -76,29 +76,29 @@
         // Double quotes are only allowed for delimiting identifiers if the server SQL mode includes ANSI_QUOTES 
         info.setDelimiterToken("`");
 
-        info.addNativeTypeMapping(Types.ARRAY,         "LONGBLOB",          Types.LONGVARBINARY);
+        info.addNativeTypeMapping(Types.ARRAY,         "LONGBLOB",   Types.LONGVARBINARY);
         info.addNativeTypeMapping(Types.BIT,           "TINYINT(1)");
-        info.addNativeTypeMapping(Types.BLOB,          "LONGBLOB",          Types.LONGVARBINARY);
-        info.addNativeTypeMapping(Types.CLOB,          "LONGTEXT",          Types.LONGVARCHAR);
-        info.addNativeTypeMapping(Types.DISTINCT,      "LONGBLOB",          Types.LONGVARBINARY);
-        info.addNativeTypeMapping(Types.FLOAT,         "DOUBLE",            Types.DOUBLE);
-        info.addNativeTypeMapping(Types.JAVA_OBJECT,   "LONGBLOB",          Types.LONGVARBINARY);
+        info.addNativeTypeMapping(Types.BLOB,          "LONGBLOB",   Types.LONGVARBINARY);
+        info.addNativeTypeMapping(Types.BOOLEAN,       "TINYINT(1)", Types.BIT);
+        info.addNativeTypeMapping(Types.CLOB,          "LONGTEXT",   Types.LONGVARCHAR);
+        info.addNativeTypeMapping(Types.DATALINK,      "MEDIUMBLOB", Types.LONGVARBINARY);
+        info.addNativeTypeMapping(Types.DISTINCT,      "LONGBLOB",   Types.LONGVARBINARY);
+        info.addNativeTypeMapping(Types.FLOAT,         "DOUBLE",     Types.DOUBLE);
+        info.addNativeTypeMapping(Types.JAVA_OBJECT,   "LONGBLOB",   Types.LONGVARBINARY);
         info.addNativeTypeMapping(Types.LONGVARBINARY, "MEDIUMBLOB");
         info.addNativeTypeMapping(Types.LONGVARCHAR,   "MEDIUMTEXT");
-        info.addNativeTypeMapping(Types.NULL,          "MEDIUMBLOB",        Types.LONGVARBINARY);
-        info.addNativeTypeMapping(Types.NUMERIC,       "DECIMAL",           Types.DECIMAL);
-        info.addNativeTypeMapping(Types.OTHER,         "LONGBLOB",          Types.LONGVARBINARY);
+        info.addNativeTypeMapping(Types.NULL,          "MEDIUMBLOB", Types.LONGVARBINARY);
+        info.addNativeTypeMapping(Types.NUMERIC,       "DECIMAL",    Types.DECIMAL);
+        info.addNativeTypeMapping(Types.OTHER,         "LONGBLOB",   Types.LONGVARBINARY);
         info.addNativeTypeMapping(Types.REAL,          "FLOAT");
-        info.addNativeTypeMapping(Types.REF,           "MEDIUMBLOB",        Types.LONGVARBINARY);
-        info.addNativeTypeMapping(Types.STRUCT,        "LONGBLOB",          Types.LONGVARBINARY);
+        info.addNativeTypeMapping(Types.REF,           "MEDIUMBLOB", Types.LONGVARBINARY);
+        info.addNativeTypeMapping(Types.STRUCT,        "LONGBLOB",   Types.LONGVARBINARY);
         // Since TIMESTAMP is not a stable datatype yet, and does not support a higher precision
         // than DATETIME (year to seconds) as of MySQL 5, we map the JDBC type here to DATETIME
         // TODO: Make this configurable
         info.addNativeTypeMapping(Types.TIMESTAMP,     "DATETIME");
         // In MySql, TINYINT has only a range of -128 to 127
         info.addNativeTypeMapping(Types.TINYINT,       "SMALLINT",          Types.SMALLINT);
-        info.addNativeTypeMapping("BOOLEAN",  "TINYINT(1)", "BIT");
-        info.addNativeTypeMapping("DATALINK", "MEDIUMBLOB", "LONGVARBINARY");
 
         info.setDefaultSize(Types.CHAR,      254);
         info.setDefaultSize(Types.VARCHAR,   254);

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle10ModelReader.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle10ModelReader.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle10ModelReader.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle10ModelReader.java Sun Feb 24 18:17:57 2008
@@ -52,12 +52,14 @@
 	{
 		// Oracle 10 added the recycle bin which contains dropped database objects not yet purged
 		// Since we don't want entries from the recycle bin, we filter them out
-        PreparedStatement stmt       = null;
+	    final String query = "SELECT * FROM RECYCLEBIN WHERE OBJECT_NAME=?";
+
+	    PreparedStatement stmt       = null;
         boolean           deletedObj = false;
 
         try
         {
-        	stmt = getConnection().prepareStatement("SELECT * FROM RECYCLEBIN WHERE OBJECT_NAME=?");
+        	stmt = getConnection().prepareStatement(query);
         	stmt.setString(1, (String)values.get("TABLE_NAME"));
         	
         	ResultSet rs = stmt.executeQuery();
@@ -67,14 +69,10 @@
         		// we found the table in the recycle bin, so its a deleted one which we ignore
         		deletedObj = true;
         	}
-        	rs.close();
         }
         finally
         {
-        	if (stmt != null)
-        	{
-        		stmt.close();
-        	}
+            closeStatement(stmt);
         }
 
         return deletedObj ? null : super.readTable(metaData, values);

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle8Builder.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle8Builder.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle8Builder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle8Builder.java Sun Feb 24 18:17:57 2008
@@ -32,8 +32,7 @@
 import org.apache.ddlutils.model.Table;
 import org.apache.ddlutils.model.TypeMap;
 import org.apache.ddlutils.platform.SqlBuilder;
-import org.apache.ddlutils.util.Jdbc3Utils;
-import org.apache.ddlutils.util.StringUtils;
+import org.apache.ddlutils.util.StringUtilsExt;
 import org.apache.oro.text.regex.MalformedPatternException;
 import org.apache.oro.text.regex.Pattern;
 import org.apache.oro.text.regex.PatternCompiler;
@@ -286,10 +285,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);
         }
     	// Oracle does not accept ISO formats, so we have to convert an ISO spec if we find one
     	// But these are the only formats that we make sure work, every other format has to be database-dependent
@@ -416,7 +414,7 @@
     {
         boolean sizeChanged = TypeMap.isTextType(targetColumn.getTypeCode()) &&
                               ColumnDefinitionChange.isSizeChanged(getPlatformInfo(), sourceColumn, targetColumn) &&
-                              !StringUtils.isEmpty(targetColumn.getSize());
+                              !StringUtilsExt.isEmpty(targetColumn.getSize());
 
         if (sizeChanged)
         {

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle8ModelReader.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle8ModelReader.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle8ModelReader.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle8ModelReader.java Sun Feb 24 18:17:57 2008
@@ -251,6 +251,9 @@
         //       But once sequence/trigger support is in place, it might be possible to 'parse' the
         //       trigger body (via SELECT trigger_name, trigger_body FROM user_triggers) in order to
         //       determine whether it fits our auto-increment definition
+        final String triggerQuery  = "SELECT * FROM user_triggers WHERE trigger_name = ?";
+        final String sequenceQuery = "SELECT * FROM user_sequences WHERE sequence_name = ?";
+
         PreparedStatement prepStmt    = null;
         String            triggerName = getPlatform().getSqlBuilder().getConstraintName("trg", table, column.getName(), null);
         String            seqName     = getPlatform().getSqlBuilder().getConstraintName("seq", table, column.getName(), null);
@@ -262,7 +265,7 @@
         }
         try
         {
-            prepStmt = getConnection().prepareStatement("SELECT * FROM user_triggers WHERE trigger_name = ?");
+            prepStmt = getConnection().prepareStatement(triggerQuery);
             prepStmt.setString(1, triggerName);
 
             ResultSet resultSet = prepStmt.executeQuery();
@@ -272,9 +275,9 @@
                 return false;
             }
             // we have a trigger, so lets check the sequence
-            prepStmt.close();
+            closeStatement(prepStmt);
 
-            prepStmt = getConnection().prepareStatement("SELECT * FROM user_sequences WHERE sequence_name = ?");
+            prepStmt = getConnection().prepareStatement(sequenceQuery);
             prepStmt.setString(1, seqName);
 
             resultSet = prepStmt.executeQuery();
@@ -282,10 +285,7 @@
         }
         finally
         {
-            if (prepStmt != null)
-            {
-                prepStmt.close();
-            }
+            closeStatement(prepStmt);
         }
     }
 
@@ -301,26 +301,19 @@
         // having GENERATED='Y' in the query result, or by their index names being equal to the
         // name of the primary key of the table
 
-		StringBuffer query = new StringBuffer();
-
-		query.append("SELECT a.INDEX_NAME, a.INDEX_TYPE, a.UNIQUENESS, b.COLUMN_NAME, b.COLUMN_POSITION FROM USER_INDEXES a, USER_IND_COLUMNS b WHERE ");
-		query.append("a.TABLE_NAME=? AND a.GENERATED=? AND a.TABLE_TYPE=? AND a.TABLE_NAME=b.TABLE_NAME AND a.INDEX_NAME=b.INDEX_NAME AND ");
-        query.append("a.INDEX_NAME NOT IN (SELECT DISTINCT c.CONSTRAINT_NAME FROM USER_CONSTRAINTS c WHERE c.CONSTRAINT_TYPE=? AND c.TABLE_NAME=a.TABLE_NAME");
-		if (metaData.getSchemaPattern() != null)
-		{
-			query.append(" AND c.OWNER LIKE ?) AND a.TABLE_OWNER LIKE ?");
-		}
-        else
-        {
-            query.append(")");
-        }
+		final String query =
+		    "SELECT a.INDEX_NAME, a.INDEX_TYPE, a.UNIQUENESS, b.COLUMN_NAME, b.COLUMN_POSITION FROM USER_INDEXES a, USER_IND_COLUMNS b WHERE " +
+		    "a.TABLE_NAME=? AND a.GENERATED=? AND a.TABLE_TYPE=? AND a.TABLE_NAME=b.TABLE_NAME AND a.INDEX_NAME=b.INDEX_NAME AND " +
+		    "a.INDEX_NAME NOT IN (SELECT DISTINCT c.CONSTRAINT_NAME FROM USER_CONSTRAINTS c WHERE c.CONSTRAINT_TYPE=? AND c.TABLE_NAME=a.TABLE_NAME)";
+		final String queryWithSchema =
+		    query.substring(query.length() - 1) + " AND c.OWNER LIKE ?) AND a.TABLE_OWNER LIKE ?";
 
         Map               indices = new ListOrderedMap();
 		PreparedStatement stmt    = null;
 
         try
         {
-    		stmt = getConnection().prepareStatement(query.toString());
+    		stmt = getConnection().prepareStatement(metaData.getSchemaPattern() == null ? query : queryWithSchema);
     		stmt.setString(1, getPlatform().isDelimitedIdentifierModeOn() ? tableName : tableName.toUpperCase());
     		stmt.setString(2, "N");
     		stmt.setString(3, "TABLE");
@@ -347,10 +340,7 @@
         }
         finally
         {
-            if (stmt != null)
-            {
-                stmt.close();
-            }
+            closeStatement(stmt);
         }
 		return indices.values();
 	}

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle8Platform.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle8Platform.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle8Platform.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/oracle/Oracle8Platform.java Sun Feb 24 18:17:57 2008
@@ -77,6 +77,8 @@
         info.addNativeTypeMapping(Types.BIGINT,        "NUMBER(38)");
         info.addNativeTypeMapping(Types.BINARY,        "RAW",              Types.VARBINARY);
         info.addNativeTypeMapping(Types.BIT,           "NUMBER(1)");
+        info.addNativeTypeMapping(Types.BOOLEAN,       "NUMBER(1)",        Types.BIT);
+        info.addNativeTypeMapping(Types.DATALINK,      "BLOB",             Types.BLOB);
         info.addNativeTypeMapping(Types.DATE,          "DATE",             Types.TIMESTAMP);
         info.addNativeTypeMapping(Types.DECIMAL,       "NUMBER");
         info.addNativeTypeMapping(Types.DISTINCT,      "BLOB",             Types.BLOB);
@@ -96,9 +98,6 @@
         info.addNativeTypeMapping(Types.TINYINT,       "NUMBER(3)");
         info.addNativeTypeMapping(Types.VARBINARY,     "RAW");
         info.addNativeTypeMapping(Types.VARCHAR,       "VARCHAR2");
-
-        info.addNativeTypeMapping("BOOLEAN",  "NUMBER(1)", "BIT");
-        info.addNativeTypeMapping("DATALINK", "BLOB",      "BLOB");
 
         info.setDefaultSize(Types.CHAR,       254);
         info.setDefaultSize(Types.VARCHAR,    254);

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/postgresql/PostgreSqlPlatform.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/postgresql/PostgreSqlPlatform.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/postgresql/PostgreSqlPlatform.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/postgresql/PostgreSqlPlatform.java Sun Feb 24 18:17:57 2008
@@ -75,7 +75,9 @@
         info.addNativeTypeMapping(Types.BINARY,        "BYTEA",            Types.LONGVARBINARY);
         info.addNativeTypeMapping(Types.BIT,           "BOOLEAN");
         info.addNativeTypeMapping(Types.BLOB,          "BYTEA",            Types.LONGVARBINARY);
+        info.addNativeTypeMapping(Types.BOOLEAN,       "BOOLEAN",          Types.BIT);
         info.addNativeTypeMapping(Types.CLOB,          "TEXT",             Types.LONGVARCHAR);
+        info.addNativeTypeMapping(Types.DATALINK,      "BYTEA",            Types.LONGVARBINARY);
         info.addNativeTypeMapping(Types.DECIMAL,       "NUMERIC",          Types.NUMERIC);
         info.addNativeTypeMapping(Types.DISTINCT,      "BYTEA",            Types.LONGVARBINARY);
         info.addNativeTypeMapping(Types.DOUBLE,        "DOUBLE PRECISION");
@@ -89,8 +91,6 @@
         info.addNativeTypeMapping(Types.STRUCT,        "BYTEA",            Types.LONGVARBINARY);
         info.addNativeTypeMapping(Types.TINYINT,       "SMALLINT",         Types.SMALLINT);
         info.addNativeTypeMapping(Types.VARBINARY,     "BYTEA",            Types.LONGVARBINARY);
-        info.addNativeTypeMapping("BOOLEAN",  "BOOLEAN", "BIT");
-        info.addNativeTypeMapping("DATALINK", "BYTEA",   "LONGVARBINARY");
 
         info.setDefaultSize(Types.CHAR,    254);
         info.setDefaultSize(Types.VARCHAR, 254);

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sapdb/SapDbPlatform.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sapdb/SapDbPlatform.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sapdb/SapDbPlatform.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sapdb/SapDbPlatform.java Sun Feb 24 18:17:57 2008
@@ -38,7 +38,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 SapDB platform implementation.
@@ -70,31 +70,30 @@
         // BIGINT is also handled by the model reader
         // Unfortunately there is no way to distinguish between REAL, and FLOAT/DOUBLE when
         // reading back via JDBC, because they all have the same size of 8
-        info.addNativeTypeMapping(Types.ARRAY,         "LONG BYTE", Types.LONGVARBINARY);
+        info.addNativeTypeMapping(Types.ARRAY,         "LONG BYTE",       Types.LONGVARBINARY);
         info.addNativeTypeMapping(Types.BIGINT,        "FIXED(38,0)");
         info.addNativeTypeMapping(Types.BINARY,        "CHAR{0} BYTE");
         info.addNativeTypeMapping(Types.BIT,           "BOOLEAN");
-        info.addNativeTypeMapping(Types.BLOB,          "LONG BYTE", Types.LONGVARBINARY);
-        info.addNativeTypeMapping(Types.CLOB,          "LONG",      Types.LONGVARCHAR);
+        info.addNativeTypeMapping(Types.BLOB,          "LONG BYTE",       Types.LONGVARBINARY);
+        info.addNativeTypeMapping(Types.BOOLEAN,       "BOOLEAN",         Types.BIT);
+        info.addNativeTypeMapping(Types.CLOB,          "LONG",            Types.LONGVARCHAR);
+        info.addNativeTypeMapping(Types.DATALINK,      "LONG BYTE",       Types.LONGVARBINARY);
         info.addNativeTypeMapping(Types.DECIMAL,       "FIXED");
-        info.addNativeTypeMapping(Types.DISTINCT,      "LONG BYTE", Types.LONGVARBINARY);
-        info.addNativeTypeMapping(Types.DOUBLE,        "FLOAT(38)", Types.FLOAT);
+        info.addNativeTypeMapping(Types.DISTINCT,      "LONG BYTE",       Types.LONGVARBINARY);
+        info.addNativeTypeMapping(Types.DOUBLE,        "FLOAT(38)",       Types.FLOAT);
         info.addNativeTypeMapping(Types.FLOAT,         "FLOAT(38)");
-        info.addNativeTypeMapping(Types.JAVA_OBJECT,   "LONG BYTE", Types.LONGVARBINARY);
+        info.addNativeTypeMapping(Types.JAVA_OBJECT,   "LONG BYTE",       Types.LONGVARBINARY);
         info.addNativeTypeMapping(Types.LONGVARBINARY, "LONG BYTE");
         info.addNativeTypeMapping(Types.LONGVARCHAR,   "LONG");
-        info.addNativeTypeMapping(Types.NULL,          "LONG BYTE", Types.LONGVARBINARY);
-        info.addNativeTypeMapping(Types.NUMERIC,       "FIXED",     Types.DECIMAL);
-        info.addNativeTypeMapping(Types.OTHER,         "LONG BYTE", Types.LONGVARBINARY);
-        info.addNativeTypeMapping(Types.REAL,          "FLOAT(16)", Types.FLOAT);
-        info.addNativeTypeMapping(Types.REF,           "LONG BYTE", Types.LONGVARBINARY);
-        info.addNativeTypeMapping(Types.STRUCT,        "LONG BYTE", Types.LONGVARBINARY);
-        info.addNativeTypeMapping(Types.TINYINT,       "SMALLINT",  Types.SMALLINT);
+        info.addNativeTypeMapping(Types.NULL,          "LONG BYTE",       Types.LONGVARBINARY);
+        info.addNativeTypeMapping(Types.NUMERIC,       "FIXED",           Types.DECIMAL);
+        info.addNativeTypeMapping(Types.OTHER,         "LONG BYTE",       Types.LONGVARBINARY);
+        info.addNativeTypeMapping(Types.REAL,          "FLOAT(16)",       Types.FLOAT);
+        info.addNativeTypeMapping(Types.REF,           "LONG BYTE",       Types.LONGVARBINARY);
+        info.addNativeTypeMapping(Types.STRUCT,        "LONG BYTE",       Types.LONGVARBINARY);
+        info.addNativeTypeMapping(Types.TINYINT,       "SMALLINT",        Types.SMALLINT);
         info.addNativeTypeMapping(Types.VARBINARY,     "VARCHAR{0} BYTE");
 
-        info.addNativeTypeMapping("BOOLEAN",  "BOOLEAN",   "BIT");
-        info.addNativeTypeMapping("DATALINK", "LONG BYTE", "LONGVARBINARY");
-
         info.setDefaultSize(Types.CHAR,      254);
         info.setDefaultSize(Types.VARCHAR,   254);
         info.setDefaultSize(Types.BINARY,    254);
@@ -150,7 +149,7 @@
                     // a default value or be IDENTITY
                     return (addColumnChange.getNextColumn() == null) &&
                            (!addColumnChange.getNewColumn().isRequired() ||
-                            !StringUtils.isEmpty(addColumnChange.getNewColumn().getDefaultValue()));
+                            !StringUtilsExt.isEmpty(addColumnChange.getNewColumn().getDefaultValue()));
                 }
                 else if (change instanceof ColumnDefinitionChange)
                 {
@@ -163,7 +162,7 @@
 
                     // we can however handle the change if only the default value or the required status was changed
                     return ((curColumn.getTypeCode() == newColumn.getTypeCode()) &&
-                           (!getPlatformInfo().hasSize(curColumn.getTypeCode()) || StringUtils.equals(curColumn.getSize(), newColumn.getSize())) &&
+                           (!getPlatformInfo().hasSize(curColumn.getTypeCode()) || StringUtilsExt.equals(curColumn.getSize(), newColumn.getSize())) &&
                            (curColumn.isAutoIncrement() == newColumn.isAutoIncrement()));
                 }
                 else
@@ -252,7 +251,7 @@
         Table  changedTable  = findChangedTable(currentModel, change);
         Column changedColumn = changedTable.findColumn(change.getChangedColumn(), isDelimitedIdentifierModeOn());
 
-        if (!StringUtils.equals(changedColumn.getDefaultValue(), change.getNewColumn().getDefaultValue()))
+        if (!StringUtilsExt.equals(changedColumn.getDefaultValue(), change.getNewColumn().getDefaultValue()))
         {
             ((SapDbBuilder)getSqlBuilder()).changeColumnDefaultValue(changedTable,
                                                                   changedColumn,

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybaseBuilder.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybaseBuilder.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybaseBuilder.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybaseBuilder.java Sun Feb 24 18:17:57 2008
@@ -31,8 +31,7 @@
 import org.apache.ddlutils.model.Index;
 import org.apache.ddlutils.model.Table;
 import org.apache.ddlutils.platform.SqlBuilder;
-import org.apache.ddlutils.util.Jdbc3Utils;
-import org.apache.ddlutils.util.StringUtils;
+import org.apache.ddlutils.util.StringUtilsExt;
 
 /**
  * The SQL Builder for Sybase.
@@ -168,10 +167,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
         {
@@ -301,7 +299,7 @@
     {
         String quotationStmt = getQuotationOnStatement();
 
-        if (!StringUtils.isEmpty(quotationStmt))
+        if (!StringUtilsExt.isEmpty(quotationStmt))
         {
             print(quotationStmt);
             printEndOfStatement();

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybaseModelReader.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybaseModelReader.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybaseModelReader.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybaseModelReader.java Sun Feb 24 18:17:57 2008
@@ -23,7 +23,6 @@
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
-import java.sql.Statement;
 import java.sql.Time;
 import java.sql.Timestamp;
 import java.sql.Types;
@@ -55,7 +54,7 @@
  */
 public class SybaseModelReader extends JdbcModelReader
 {
-	/** The regular expression pattern for the ISO dates. */
+    /** The regular expression pattern for the ISO dates. */
 	private Pattern _isoDatePattern;
 	/** The regular expression pattern for the ISO times. */
 	private Pattern _isoTimePattern;
@@ -174,29 +173,29 @@
     {
         // Sybase (or jConnect) does not return the foreign key names, thus we have to
         // read the foreign keys manually from the system tables
-        StringBuffer query = new StringBuffer();
-
-        query.append("SELECT refobjs.name, localtables.id, remotetables.name, remotetables.id");
-        for (int idx = 1; idx <= 16; idx++)
-        {
-            query.append(", refs.fokey");
-            query.append(idx);
-            query.append(", refs.refkey");
-            query.append(idx);
-        }
-        query.append(" FROM sysreferences refs, sysobjects refobjs, sysobjects localtables, sysobjects remotetables");
-        query.append(" WHERE refobjs.type = 'RI' AND refs.constrid = refobjs.id AND");
-        query.append(" localtables.type = 'U' AND refs.tableid = localtables.id AND localtables.name = '");
-        query.append(tableName);
-        query.append("' AND remotetables.type = 'U' AND refs.reftabid = remotetables.id");
-
-        Statement         stmt     = getConnection().createStatement();
-        PreparedStatement prepStmt = getConnection().prepareStatement("SELECT name FROM syscolumns WHERE id = ? AND colid = ?");
-        ArrayList         result   = new ArrayList();
+        final String colQuery = 
+            "SELECT refobjs.name, localtables.id, remotetables.name, remotetables.id," +
+            "       refs.fokey1, refs.refkey1, refs.fokey2, refs.refkey2, refs.fokey3, refs.refkey3, refs.fokey4, refs.refkey4," +
+            "       refs.fokey5, refs.refkey5, refs.fokey6, refs.refkey6, refs.fokey7, refs.refkey7, refs.fokey8, refs.refkey8," +
+            "       refs.fokey9, refs.refkey9, refs.fokey10, refs.refkey10, refs.fokey11, refs.refkey11, refs.fokey12, refs.refkey12," +
+            "       refs.fokey13, refs.refkey13, refs.fokey14, refs.refkey14, refs.fokey15, refs.refkey15, refs.fokey16, refs.refkey16," +
+            " FROM sysreferences refs, sysobjects refobjs, sysobjects localtables, sysobjects remotetables" +
+            " WHERE refobjs.type = 'RI' AND refs.constrid = refobjs.id AND" +
+            "       localtables.type = 'U' AND refs.tableid = localtables.id AND localtables.name = ?" +
+            "   AND remotetables.type = 'U' AND refs.reftabid = remotetables.id";
+        final String refObjQuery = 
+            "SELECT name FROM syscolumns WHERE id = ? AND colid = ?";
+
+        PreparedStatement colStmt    = null;
+        PreparedStatement refObjStmt = null;
+        ArrayList         result     = new ArrayList();
 
         try
         {
-            ResultSet fkRs = stmt.executeQuery(query.toString());
+            colStmt    = getConnection().prepareStatement(colQuery);
+            refObjStmt = getConnection().prepareStatement(refObjQuery);
+
+            ResultSet fkRs = colStmt.executeQuery();
 
             while (fkRs.next())
             {
@@ -216,10 +215,10 @@
                         break;
                     }
 
-                    prepStmt.setInt(1, localTableId);
-                    prepStmt.setShort(2, fkColIdx);
+                    refObjStmt.setInt(1, localTableId);
+                    refObjStmt.setShort(2, fkColIdx);
 
-                    ResultSet colRs = prepStmt.executeQuery();
+                    ResultSet colRs = refObjStmt.executeQuery();
 
                     if (colRs.next())
                     {
@@ -227,10 +226,10 @@
                     }
                     colRs.close();
 
-                    prepStmt.setInt(1, remoteTableId);
-                    prepStmt.setShort(2, pkColIdx);
+                    refObjStmt.setInt(1, remoteTableId);
+                    refObjStmt.setShort(2, pkColIdx);
 
-                    colRs = prepStmt.executeQuery();
+                    colRs = refObjStmt.executeQuery();
 
                     if (colRs.next())
                     {
@@ -242,13 +241,11 @@
                 }
                 result.add(fk);
             }
-
-            fkRs.close();
         }
         finally
         {
-            stmt.close();
-            prepStmt.close();
+            closeStatement(colStmt);
+            closeStatement(refObjStmt);
         }
 
         return result;
@@ -260,27 +257,25 @@
     protected boolean isInternalPrimaryKeyIndex(DatabaseMetaDataWrapper metaData, Table table, Index index) throws SQLException
     {
         // We can simply check the sysindexes table where a specific flag is set for pk indexes
-        StringBuffer query = new StringBuffer();
+        final String query = "SELECT name = sysindexes.name FROM sysindexes, sysobjects WHERE sysobjects.name = ? " +
+        		             "AND sysindexes.name = ? AND sysobjects.id = sysindexes.id AND (sysindexes.status & 2048) > 0";
 
-        query.append("SELECT name = sysindexes.name FROM sysindexes, sysobjects WHERE sysobjects.name = '");
-        query.append(table.getName());
-        query.append("' AND sysindexes.name = '");
-        query.append(index.getName());
-        query.append("' AND sysobjects.id = sysindexes.id AND (sysindexes.status & 2048) > 0");
-        
-        Statement stmt = getConnection().createStatement();
+        PreparedStatement stmt = null;
 
         try
         {
-            ResultSet rs     = stmt.executeQuery(query.toString());
-            boolean   result = rs.next();
+            stmt = getConnection().prepareStatement(query);
+
+            stmt.setString(1, table.getName());
+            stmt.setString(2, index.getName());
+            
+            ResultSet rs = stmt.executeQuery();
 
-            rs.close();
-            return result;
+            return rs.next();
         }
         finally
         {
-            stmt.close();
+            closeStatement(stmt);
         }
     }
 }

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybasePlatform.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybasePlatform.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybasePlatform.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybasePlatform.java Sun Feb 24 18:17:57 2008
@@ -92,7 +92,9 @@
         // we're not using the native BIT type because it is rather limited (cannot be NULL, cannot be indexed)
         info.addNativeTypeMapping(Types.BIT,           "SMALLINT",         Types.SMALLINT);
         info.addNativeTypeMapping(Types.BLOB,          "IMAGE",            Types.LONGVARBINARY);
+        info.addNativeTypeMapping(Types.BOOLEAN,       "SMALLINT",         Types.SMALLINT);
         info.addNativeTypeMapping(Types.CLOB,          "TEXT",             Types.LONGVARCHAR);
+        info.addNativeTypeMapping(Types.DATALINK,      "IMAGE",            Types.LONGVARBINARY);
         info.addNativeTypeMapping(Types.DATE,          "DATETIME",         Types.TIMESTAMP);
         info.addNativeTypeMapping(Types.DISTINCT,      "IMAGE",            Types.LONGVARBINARY);
         info.addNativeTypeMapping(Types.DOUBLE,        "DOUBLE PRECISION");
@@ -108,8 +110,6 @@
         info.addNativeTypeMapping(Types.TIME,          "DATETIME",         Types.TIMESTAMP);
         info.addNativeTypeMapping(Types.TIMESTAMP,     "DATETIME",         Types.TIMESTAMP);
         info.addNativeTypeMapping(Types.TINYINT,       "SMALLINT",         Types.SMALLINT);
-        info.addNativeTypeMapping("BOOLEAN",  "SMALLINT", "SMALLINT");
-        info.addNativeTypeMapping("DATALINK", "IMAGE",    "LONGVARBINARY");
 
         info.setDefaultSize(Types.BINARY,    254);
         info.setDefaultSize(Types.VARBINARY, 254);

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DatabaseTaskBase.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DatabaseTaskBase.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DatabaseTaskBase.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/task/DatabaseTaskBase.java Sun Feb 24 18:17:57 2008
@@ -19,6 +19,8 @@
  * under the License.
  */
 
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.Properties;
@@ -353,12 +355,26 @@
             return;
         }
 
-        ClassLoader    sysClassLoader = Thread.currentThread().getContextClassLoader();
-        AntClassLoader newClassLoader = new AntClassLoader(getClass().getClassLoader(), true);
-
-        // we're changing the thread classloader so that we can access resources
-        // from the classpath used to load this task's class
-        Thread.currentThread().setContextClassLoader(newClassLoader);
+        ClassLoader sysClassLoader = (ClassLoader)AccessController.doPrivileged(new PrivilegedAction()
+        {
+            public Object run()
+            {
+                try
+                {
+                    ClassLoader    contextClassLoader = Thread.currentThread().getContextClassLoader();
+                    AntClassLoader newClassLoader     = new AntClassLoader(getClass().getClassLoader(), true);
+
+                    // we're changing the thread classloader so that we can access resources
+                    // from the classpath used to load this task's class
+                    Thread.currentThread().setContextClassLoader(newClassLoader);
+                    return contextClassLoader;
+                }
+                catch (SecurityException ex)
+                {
+                    throw new BuildException("Could not change the context clas loader", ex);
+                }
+            }
+        });
 
         try
         {

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/task/VerbosityLevel.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/task/VerbosityLevel.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/task/VerbosityLevel.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/task/VerbosityLevel.java Sun Feb 24 18:17:57 2008
@@ -64,8 +64,12 @@
     /**
      * {@inheritDoc}
      */
-    public String[] getValues() {
-        return LEVELS;
+    public String[] getValues()
+    {
+        String[] result = new String[LEVELS.length];
+
+        System.arraycopy(LEVELS, 0, result, 0, LEVELS.length);
+        return result;
     }
 
     /**

Copied: db/ddlutils/trunk/src/java/org/apache/ddlutils/util/StringUtilsExt.java (from r630531, db/ddlutils/trunk/src/java/org/apache/ddlutils/util/StringUtils.java)
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/util/StringUtilsExt.java?p2=db/ddlutils/trunk/src/java/org/apache/ddlutils/util/StringUtilsExt.java&p1=db/ddlutils/trunk/src/java/org/apache/ddlutils/util/StringUtils.java&r1=630531&r2=630717&rev=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/util/StringUtils.java (original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/util/StringUtilsExt.java Sun Feb 24 18:17:57 2008
@@ -24,7 +24,7 @@
  * 
  * @version $Revision: $
  */
-public class StringUtils extends org.apache.commons.lang.StringUtils
+public class StringUtilsExt extends org.apache.commons.lang.StringUtils
 {
     /**
      * Compares the two given strings in a case sensitive or insensitive manner

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/TestDatabaseWriterBase.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/test/org/apache/ddlutils/TestDatabaseWriterBase.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/TestDatabaseWriterBase.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/TestDatabaseWriterBase.java Sun Feb 24 18:17:57 2008
@@ -20,6 +20,7 @@
  */
 
 import java.io.FileInputStream;
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.StringReader;
 import java.sql.Connection;
@@ -101,14 +102,18 @@
 	        {
 	        	throw new RuntimeException("Please specify the properties file via the jdbc.properties.file environment variable");
 	        }
+
+	        InputStream propStream = null;
+
 	        try
 	        {
-	            InputStream propStream = getClass().getResourceAsStream(propFile);
-	
+	            propStream = TestDatabaseWriterBase.class.getResourceAsStream(propFile);
+
 	            if (propStream == null)
 	            {
 	                propStream = new FileInputStream(propFile);
 	            }
+
 	            Properties props = new Properties();
 
 	            props.load(propStream);
@@ -117,6 +122,20 @@
 	        catch (Exception ex)
 	        {
 	        	throw new RuntimeException(ex);
+	        }
+	        finally
+	        {
+	            if (propStream != null)
+	            {
+	                try
+	                {
+	                    propStream.close();
+	                }
+	                catch (IOException ex)
+	                {
+	                    getLog().error("Could not close the stream used to read the test jdbc properties", ex);
+	                }
+	            }
 	        }
     	}
     	return _testProps;

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/TestPlatformBase.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/test/org/apache/ddlutils/TestPlatformBase.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/TestPlatformBase.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/TestPlatformBase.java Sun Feb 24 18:17:57 2008
@@ -19,13 +19,11 @@
  * under the License.
  */
 
-import java.beans.IntrospectionException;
 import java.io.IOException;
 import java.io.StringWriter;
 
 import org.apache.ddlutils.model.Database;
 import org.apache.ddlutils.platform.SqlBuilder;
-import org.xml.sax.SAXException;
 
 /**
  * Base class for builder tests.
@@ -34,95 +32,6 @@
  */
 public abstract class TestPlatformBase extends TestBase
 {
-    /** The database schema for testing the column types. */
-    public static final String COLUMN_TEST_SCHEMA =
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
-        "<database name='datatypetest'>\n" +
-        "  <table name='coltype'>\n" +
-        "    <column name='COL_ARRAY'           type='ARRAY'/>\n" +
-        "    <column name='COL_BIGINT'          type='BIGINT'/>\n" +
-        "    <column name='COL_BINARY'          type='BINARY'/>\n" +
-        "    <column name='COL_BIT'             type='BIT'/>\n" +
-        "    <column name='COL_BLOB'            type='BLOB'/>\n" +
-        "    <column name='COL_BOOLEAN'         type='BOOLEAN'/>\n" +
-        "    <column name='COL_CHAR'            type='CHAR' size='15'/>\n" +
-        "    <column name='COL_CLOB'            type='CLOB'/>\n" +
-        "    <column name='COL_DATALINK'        type='DATALINK'/>\n" +
-        "    <column name='COL_DATE'            type='DATE'/>\n" +
-        "    <column name='COL_DECIMAL'         type='DECIMAL' size='15,3'/>\n" +
-        "    <column name='COL_DECIMAL_NOSCALE' type='DECIMAL' size='15'/>\n" +
-        "    <column name='COL_DISTINCT'        type='DISTINCT'/>\n" +
-        "    <column name='COL_DOUBLE'          type='DOUBLE'/>\n" +
-        "    <column name='COL_FLOAT'           type='FLOAT'/>\n" +
-        "    <column name='COL_INTEGER'         type='INTEGER'/>\n" +
-        "    <column name='COL_JAVA_OBJECT'     type='JAVA_OBJECT'/>\n" +
-        "    <column name='COL_LONGVARBINARY'   type='LONGVARBINARY'/>\n" +
-        "    <column name='COL_LONGVARCHAR'     type='LONGVARCHAR'/>\n" +
-        "    <column name='COL_NULL'            type='NULL'/>\n" +
-        "    <column name='COL_NUMERIC'         type='NUMERIC' size='15' />\n" +
-        "    <column name='COL_OTHER'           type='OTHER'/>\n" +
-        "    <column name='COL_REAL'            type='REAL'/>\n" +
-        "    <column name='COL_REF'             type='REF'/>\n" +
-        "    <column name='COL_SMALLINT'        type='SMALLINT' size='5'/>\n" +
-        "    <column name='COL_STRUCT'          type='STRUCT'/>\n" +
-        "    <column name='COL_TIME'            type='TIME'/>\n" +
-        "    <column name='COL_TIMESTAMP'       type='TIMESTAMP'/>\n" +
-        "    <column name='COL_TINYINT'         type='TINYINT'/>\n" +
-        "    <column name='COL_VARBINARY'       type='VARBINARY' size='15'/>\n" +
-        "    <column name='COL_VARCHAR'         type='VARCHAR' size='15'/>\n" +
-        "  </table>\n" +
-        "</database>";
-
-    /** The database schema for testing column constraints. */
-    public static final String COLUMN_CONSTRAINT_TEST_SCHEMA =
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
-        "<database name='columnconstraintstest'>\n" +
-        "  <table name='constraints'>\n" +
-        "    <column name='COL_PK' type='VARCHAR' size='32' primaryKey='true'/>\n" +
-        "    <column name='COL_PK_AUTO_INCR' type='INTEGER' primaryKey='true' autoIncrement='true'/>\n" +
-        "    <column name='COL_NOT_NULL' type='BINARY' size='100' required='true'/>\n" +
-        "    <column name='COL_NOT_NULL_DEFAULT' type='DOUBLE' required='true' default='-2.0'/>\n" +
-        "    <column name='COL_DEFAULT' type='CHAR' size='4' default='test'/>\n" +
-        "    <column name='COL_AUTO_INCR' type='BIGINT' autoIncrement='true'/>\n" +
-        "  </table>\n" +
-        "</database>";
-
-    /** The database schema for testing table constraints, ie. foreign keys and indices. */
-    public static final String TABLE_CONSTRAINT_TEST_SCHEMA =
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
-        "<database name='tableconstraintstest'>\n" +
-        "  <table name='table1'>\n" +
-        "    <column name='COL_PK_1' type='VARCHAR' size='32' primaryKey='true' required='true'/>\n" +
-        "    <column name='COL_PK_2' type='INTEGER' primaryKey='true'/>\n" +
-        "    <column name='COL_INDEX_1' type='BINARY' size='100' required='true'/>\n" +
-        "    <column name='COL_INDEX_2' type='DOUBLE' required='true'/>\n" +
-        "    <column name='COL_INDEX_3' type='CHAR' size='4'/>\n" +
-        "    <index name='testindex1'>\n" +
-        "      <index-column name='COL_INDEX_2'/>\n" +
-        "    </index>\n" +
-        "    <unique name='testindex2'>\n" +
-        "      <unique-column name='COL_INDEX_3'/>\n" +
-        "      <unique-column name='COL_INDEX_1'/>\n" +
-        "    </unique>\n" +
-        "  </table>\n" +
-        "  <table name='table2'>\n" +
-        "    <column name='COL_PK' type='INTEGER' primaryKey='true'/>\n" +
-        "    <column name='COL_FK_1' type='INTEGER'/>\n" +
-        "    <column name='COL_FK_2' type='VARCHAR' size='32' required='true'/>\n" +
-        "    <foreign-key foreignTable='table1'>\n" +
-        "      <reference local='COL_FK_1' foreign='COL_PK_2'/>\n" +
-        "      <reference local='COL_FK_2' foreign='COL_PK_1'/>\n" +
-        "    </foreign-key>\n" +
-        "  </table>\n" +
-        "  <table name='table3'>\n" +
-        "    <column name='COL_PK' type='VARCHAR' size='16' primaryKey='true'/>\n" +
-        "    <column name='COL_FK' type='INTEGER' required='true'/>\n" +
-        "    <foreign-key name='testfk' foreignTable='table2'>\n" +
-        "      <reference local='COL_FK' foreign='COL_PK'/>\n" +
-        "    </foreign-key>\n" +
-        "  </table>\n" +
-        "</database>";
-
     /** The tested platform. */
     private Platform _platform;
     /** The writer that the builder of the platform writes to. */
@@ -199,12 +108,12 @@
     protected abstract String getDatabaseName();
 
     /**
-     * Creates the database creation sql for the given database schema.
+     * Returns the database creation SQL for the given database schema.
      * 
      * @param schema The database schema XML
-     * @return The sql
+     * @return The SQL
      */
-    protected String createTestDatabase(String schema) throws IntrospectionException, IOException, SAXException
+    protected String getDatabaseCreationSql(String schema) throws IOException
     {
         Database testDb = parseDatabaseFromString(schema);
 
@@ -212,5 +121,140 @@
         getPlatform().setSqlCommentsOn(false);
         getPlatform().getSqlBuilder().createTables(testDb);
         return getBuilderOutput();
+    }
+
+    /**
+     * Returns the SQL to create the test database for the column tests.
+     * 
+     * @return The SQL
+     */
+    protected String getColumnTestDatabaseCreationSql() throws IOException
+    {
+        final String schema =
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
+            "<database name='datatypetest'>\n" +
+            "  <table name='coltype'>\n" +
+            "    <column name='COL_ARRAY'           type='ARRAY'/>\n" +
+            "    <column name='COL_BIGINT'          type='BIGINT'/>\n" +
+            "    <column name='COL_BINARY'          type='BINARY'/>\n" +
+            "    <column name='COL_BIT'             type='BIT'/>\n" +
+            "    <column name='COL_BLOB'            type='BLOB'/>\n" +
+            "    <column name='COL_BOOLEAN'         type='BOOLEAN'/>\n" +
+            "    <column name='COL_CHAR'            type='CHAR' size='15'/>\n" +
+            "    <column name='COL_CLOB'            type='CLOB'/>\n" +
+            "    <column name='COL_DATALINK'        type='DATALINK'/>\n" +
+            "    <column name='COL_DATE'            type='DATE'/>\n" +
+            "    <column name='COL_DECIMAL'         type='DECIMAL' size='15,3'/>\n" +
+            "    <column name='COL_DECIMAL_NOSCALE' type='DECIMAL' size='15'/>\n" +
+            "    <column name='COL_DISTINCT'        type='DISTINCT'/>\n" +
+            "    <column name='COL_DOUBLE'          type='DOUBLE'/>\n" +
+            "    <column name='COL_FLOAT'           type='FLOAT'/>\n" +
+            "    <column name='COL_INTEGER'         type='INTEGER'/>\n" +
+            "    <column name='COL_JAVA_OBJECT'     type='JAVA_OBJECT'/>\n" +
+            "    <column name='COL_LONGVARBINARY'   type='LONGVARBINARY'/>\n" +
+            "    <column name='COL_LONGVARCHAR'     type='LONGVARCHAR'/>\n" +
+            "    <column name='COL_NULL'            type='NULL'/>\n" +
+            "    <column name='COL_NUMERIC'         type='NUMERIC' size='15' />\n" +
+            "    <column name='COL_OTHER'           type='OTHER'/>\n" +
+            "    <column name='COL_REAL'            type='REAL'/>\n" +
+            "    <column name='COL_REF'             type='REF'/>\n" +
+            "    <column name='COL_SMALLINT'        type='SMALLINT' size='5'/>\n" +
+            "    <column name='COL_STRUCT'          type='STRUCT'/>\n" +
+            "    <column name='COL_TIME'            type='TIME'/>\n" +
+            "    <column name='COL_TIMESTAMP'       type='TIMESTAMP'/>\n" +
+            "    <column name='COL_TINYINT'         type='TINYINT'/>\n" +
+            "    <column name='COL_VARBINARY'       type='VARBINARY' size='15'/>\n" +
+            "    <column name='COL_VARCHAR'         type='VARCHAR' size='15'/>\n" +
+            "  </table>\n" +
+            "</database>";
+
+        return getDatabaseCreationSql(schema);
+    }
+
+    /**
+     * Returns the SQL to create the test database for the constraint tests.
+     * 
+     * @return The SQL
+     */
+    protected String getConstraintTestDatabaseCreationSql() throws IOException
+    {
+        final String schema =
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
+            "<database name='columnconstraintstest'>\n" +
+            "  <table name='constraints'>\n" +
+            "    <column name='COL_PK' type='VARCHAR' size='32' primaryKey='true'/>\n" +
+            "    <column name='COL_PK_AUTO_INCR' type='INTEGER' primaryKey='true' autoIncrement='true'/>\n" +
+            "    <column name='COL_NOT_NULL' type='BINARY' size='100' required='true'/>\n" +
+            "    <column name='COL_NOT_NULL_DEFAULT' type='DOUBLE' required='true' default='-2.0'/>\n" +
+            "    <column name='COL_DEFAULT' type='CHAR' size='4' default='test'/>\n" +
+            "    <column name='COL_AUTO_INCR' type='BIGINT' autoIncrement='true'/>\n" +
+            "  </table>\n" +
+            "</database>";
+
+        return getDatabaseCreationSql(schema);
+    }
+
+    /**
+     * Returns the SQL to create the test database for the table-level constraint tests.
+     * 
+     * @return The SQL
+     */
+    protected String getTableConstraintTestDatabaseCreationSql() throws IOException
+    {
+        final String schema =
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
+            "<database name='tableconstraintstest'>\n" +
+            "  <table name='table1'>\n" +
+            "    <column name='COL_PK_1' type='VARCHAR' size='32' primaryKey='true' required='true'/>\n" +
+            "    <column name='COL_PK_2' type='INTEGER' primaryKey='true'/>\n" +
+            "    <column name='COL_INDEX_1' type='BINARY' size='100' required='true'/>\n" +
+            "    <column name='COL_INDEX_2' type='DOUBLE' required='true'/>\n" +
+            "    <column name='COL_INDEX_3' type='CHAR' size='4'/>\n" +
+            "    <index name='testindex1'>\n" +
+            "      <index-column name='COL_INDEX_2'/>\n" +
+            "    </index>\n" +
+            "    <unique name='testindex2'>\n" +
+            "      <unique-column name='COL_INDEX_3'/>\n" +
+            "      <unique-column name='COL_INDEX_1'/>\n" +
+            "    </unique>\n" +
+            "  </table>\n" +
+            "  <table name='table2'>\n" +
+            "    <column name='COL_PK' type='INTEGER' primaryKey='true'/>\n" +
+            "    <column name='COL_FK_1' type='INTEGER'/>\n" +
+            "    <column name='COL_FK_2' type='VARCHAR' size='32' required='true'/>\n" +
+            "    <foreign-key foreignTable='table1'>\n" +
+            "      <reference local='COL_FK_1' foreign='COL_PK_2'/>\n" +
+            "      <reference local='COL_FK_2' foreign='COL_PK_1'/>\n" +
+            "    </foreign-key>\n" +
+            "  </table>\n" +
+            "  <table name='table3'>\n" +
+            "    <column name='COL_PK' type='VARCHAR' size='16' primaryKey='true'/>\n" +
+            "    <column name='COL_FK' type='INTEGER' required='true'/>\n" +
+            "    <foreign-key name='testfk' foreignTable='table2'>\n" +
+            "      <reference local='COL_FK' foreign='COL_PK'/>\n" +
+            "    </foreign-key>\n" +
+            "  </table>\n" +
+            "</database>";
+
+        return getDatabaseCreationSql(schema);
+    }
+
+    /**
+     * Returns the SQL to create the test database for testing character escaping.
+     * 
+     * @return The SQL
+     */
+    protected String getCharEscapingTestDatabaseCreationSql() throws IOException
+    {
+        final String schema =
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
+            "<database name='escapetest'>\n" +
+            "  <table name='escapedcharacters'>\n" +
+            "    <column name='COL_PK' type='INTEGER' primaryKey='true'/>\n" +
+            "    <column name='COL_TEXT' type='VARCHAR' size='128' default='&#39;'/>\n" +
+            "  </table>\n" +
+            "</database>";
+
+        return getDatabaseCreationSql(schema);
     }
 }

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/TestSummaryCreatorTask.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/test/org/apache/ddlutils/TestSummaryCreatorTask.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/TestSummaryCreatorTask.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/TestSummaryCreatorTask.java Sun Feb 24 18:17:57 2008
@@ -24,6 +24,7 @@
 import java.io.FileReader;
 import java.io.FileWriter;
 import java.io.IOException;
+import java.io.InputStream;
 import java.sql.Connection;
 import java.sql.DatabaseMetaData;
 import java.sql.SQLException;
@@ -235,9 +236,9 @@
             totalNumErrors   += numErrors;
             totalNumFailures += numFailures;
 
-            generalElement.addAttribute("tests", String.valueOf(totalNumTests));
-            generalElement.addAttribute("errors", String.valueOf(totalNumErrors));
-            generalElement.addAttribute("failures", String.valueOf(totalNumErrors));
+            generalElement.addAttribute("tests",    String.valueOf(totalNumTests));
+            generalElement.addAttribute("errors",   String.valueOf(totalNumErrors));
+            generalElement.addAttribute("failures", String.valueOf(totalNumFailures));
 
             if ((numErrors > 0) || (numFailures > 0))
             {
@@ -266,7 +267,7 @@
     }
 
     /**
-     * Reads the database properties from the used properties file.
+     * Adds the data from the test jdbc propertis file to the document.
      * 
      * @param element            The element to add the relevant database properties to
      * @param jdbcPropertiesFile The path of the properties file
@@ -278,32 +279,12 @@
             return;
         }
 
-        Properties       props    = new Properties();
+        Properties       props    = readProperties(jdbcPropertiesFile);
         Connection       conn     = null;
         DatabaseMetaData metaData = null;
 
         try
         {
-            props.load(getClass().getResourceAsStream(jdbcPropertiesFile));
-        }
-        catch (Exception ex)
-        {
-            // not on the classpath ? let's try a file
-            File baseDir  = getProject().getBaseDir();
-            File propFile = new File(baseDir, jdbcPropertiesFile);
-
-            if (propFile.exists() && propFile.isFile() && propFile.canRead())
-            {
-                props.load(new FileInputStream(propFile));
-            }
-            else
-            {
-                throw new BuildException("Cannot load database properties from file " + jdbcPropertiesFile);
-            }
-        }
-
-        try
-        {
             String     dataSourceClass = props.getProperty(TestDatabaseWriterBase.DATASOURCE_PROPERTY_PREFIX + "class", BasicDataSource.class.getName());
             DataSource dataSource      = (DataSource)Class.forName(dataSourceClass).newInstance();
     
@@ -411,7 +392,64 @@
             }
         }
     }
-    
+
+    /**
+     * Reads the database properties from the used properties file.
+     * 
+     * @param jdbcPropertiesFile The path of the properties file
+     * @return The properties
+     */
+    private Properties readProperties(String jdbcPropertiesFile)
+    {
+        Properties  props      = new Properties();
+        InputStream propStream = null;
+
+        try
+        {
+            propStream = TestSummaryCreatorTask.class.getResourceAsStream(jdbcPropertiesFile);
+            if (propStream == null)
+            {
+                // not on the classpath ? let's try a file
+                File baseDir  = getProject().getBaseDir();
+                File propFile = new File(baseDir, jdbcPropertiesFile);
+
+                if (propFile.exists() && propFile.isFile() && propFile.canRead())
+                {
+                    propStream = new FileInputStream(propFile);
+                }
+                else
+                {
+                    throw new BuildException("Cannot load test jdbc properties from file " + jdbcPropertiesFile);
+                }
+            }
+            props.load(propStream);
+        }
+        catch (BuildException ex)
+        {
+            throw ex;
+        }
+        catch (Exception ex)
+        {
+            throw new BuildException("Cannot load test jdbc properties from file " + jdbcPropertiesFile, ex);
+        }
+        finally
+        {
+            if (propStream != null)
+            {
+                try
+                {
+                    propStream.close();
+                }
+                catch (IOException ex)
+                {
+                    log("Could not close the stream used to read the test jdbc properties", Project.MSG_WARN);
+                }
+            }
+        }
+        return props;
+    }
+
+
     /**
      * {@inheritDoc}
      */

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestAxionPlatform.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestAxionPlatform.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestAxionPlatform.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestAxionPlatform.java Sun Feb 24 18:17:57 2008
@@ -29,16 +29,6 @@
  */
 public class TestAxionPlatform extends TestPlatformBase
 {
-    /** The database schema for testing escaping of character sequences. */
-    public static final String COLUMN_CHAR_SEQUENCES_TO_ESCAPE =
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
-        "<database name='escapetest'>\n" +
-        "  <table name='escapedcharacters'>\n" +
-        "    <column name='COL_PK' type='INTEGER' primaryKey='true'/>\n" +
-        "    <column name='COL_TEXT' type='VARCHAR' size='128' default='&#39;'/>\n" +
-        "  </table>\n" +
-        "</database>";
-
     /**
      * {@inheritDoc}
      */
@@ -88,7 +78,7 @@
             "    COL_VARBINARY       VARBINARY(15),\n"+
             "    COL_VARCHAR         VARCHAR(15)\n"+
             ");\n",
-            createTestDatabase(COLUMN_TEST_SCHEMA));
+            getColumnTestDatabaseCreationSql());
     }
 
     /**
@@ -108,7 +98,7 @@
             "    COL_AUTO_INCR        BIGINT GENERATED BY DEFAULT AS IDENTITY,\n"+
             "    PRIMARY KEY (COL_PK, COL_PK_AUTO_INCR)\n"+
             ");\n",
-            createTestDatabase(COLUMN_CONSTRAINT_TEST_SCHEMA));
+            getConstraintTestDatabaseCreationSql());
     }
 
     /**
@@ -148,7 +138,7 @@
             ");\n"+
             "ALTER TABLE table2 ADD CONSTRAINT table2_FK_COL_FK_1_COL_FK_2_table1 FOREIGN KEY (COL_FK_1, COL_FK_2) REFERENCES table1 (COL_PK_2, COL_PK_1);\n"+
             "ALTER TABLE table3 ADD CONSTRAINT testfk FOREIGN KEY (COL_FK) REFERENCES table2 (COL_PK);\n",
-            createTestDatabase(TABLE_CONSTRAINT_TEST_SCHEMA));
+            getTableConstraintTestDatabaseCreationSql());
     }
 
     /**
@@ -164,6 +154,6 @@
             "    COL_TEXT VARCHAR(128) DEFAULT '\'\'',\n"+
             "    PRIMARY KEY (COL_PK)\n"+
             ");\n",
-            createTestDatabase(COLUMN_CHAR_SEQUENCES_TO_ESCAPE));
+            getCharEscapingTestDatabaseCreationSql());
     }
 }

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestCloudscapePlatform.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestCloudscapePlatform.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestCloudscapePlatform.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestCloudscapePlatform.java Sun Feb 24 18:17:57 2008
@@ -29,16 +29,6 @@
  */
 public class TestCloudscapePlatform extends TestPlatformBase
 {
-    /** The database schema for testing escaping of character sequences. */
-    public static final String COLUMN_CHAR_SEQUENCES_TO_ESCAPE =
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
-        "<database name='escapetest'>\n" +
-        "  <table name='escapedcharacters'>\n" +
-        "    <column name='COL_PK' type='INTEGER' primaryKey='true'/>\n" +
-        "    <column name='COL_TEXT' type='VARCHAR' size='128' default='&#39;'/>\n" +
-        "  </table>\n" +
-        "</database>";
-
     /**
      * {@inheritDoc}
      */
@@ -88,7 +78,7 @@
             "    \"COL_VARBINARY\"       VARCHAR(15) FOR BIT DATA,\n"+
             "    \"COL_VARCHAR\"         VARCHAR(15)\n"+
             ");\n",
-            createTestDatabase(COLUMN_TEST_SCHEMA));
+            getColumnTestDatabaseCreationSql());
     }
 
     /**
@@ -108,7 +98,7 @@
             "    \"COL_AUTO_INCR\"        BIGINT GENERATED ALWAYS AS IDENTITY,\n"+
             "    PRIMARY KEY (\"COL_PK\", \"COL_PK_AUTO_INCR\")\n"+
             ");\n",
-            createTestDatabase(COLUMN_CONSTRAINT_TEST_SCHEMA));
+            getConstraintTestDatabaseCreationSql());
     }
 
     /**
@@ -148,7 +138,7 @@
             ");\n"+
             "ALTER TABLE \"table2\" ADD CONSTRAINT \"table2_FK_COL_FK_1_COL_FK_2_table1\" FOREIGN KEY (\"COL_FK_1\", \"COL_FK_2\") REFERENCES \"table1\" (\"COL_PK_2\", \"COL_PK_1\");\n"+
             "ALTER TABLE \"table3\" ADD CONSTRAINT \"testfk\" FOREIGN KEY (\"COL_FK\") REFERENCES \"table2\" (\"COL_PK\");\n",
-            createTestDatabase(TABLE_CONSTRAINT_TEST_SCHEMA));
+            getTableConstraintTestDatabaseCreationSql());
     }
 
     /**
@@ -164,6 +154,6 @@
             "    \"COL_TEXT\" VARCHAR(128) DEFAULT '\'\'',\n"+
             "    PRIMARY KEY (\"COL_PK\")\n"+
             ");\n",
-            createTestDatabase(COLUMN_CHAR_SEQUENCES_TO_ESCAPE));
+            getCharEscapingTestDatabaseCreationSql());
     }
 }

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestDB2Platform.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestDB2Platform.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestDB2Platform.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestDB2Platform.java Sun Feb 24 18:17:57 2008
@@ -29,16 +29,6 @@
  */
 public class TestDB2Platform extends TestPlatformBase
 {
-    /** The database schema for testing escaping of character sequences. */
-    public static final String COLUMN_CHAR_SEQUENCES_TO_ESCAPE =
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
-        "<database name='escapetest'>\n" +
-        "  <table name='escapedcharacters'>\n" +
-        "    <column name='COL_PK' type='INTEGER' primaryKey='true'/>\n" +
-        "    <column name='COL_TEXT' type='VARCHAR' size='128' default='&#39;'/>\n" +
-        "  </table>\n" +
-        "</database>";
-
     /**
      * {@inheritDoc}
      */
@@ -88,7 +78,7 @@
             "    \"COL_VARBINARY\"     VARCHAR(15) FOR BIT DATA,\n"+
             "    \"COL_VARCHAR\"       VARCHAR(15)\n"+
             ");\n",
-            createTestDatabase(COLUMN_TEST_SCHEMA));
+            getColumnTestDatabaseCreationSql());
     }
 
 
@@ -109,7 +99,7 @@
             "    \"COL_AUTO_INCR\"     BIGINT GENERATED BY DEFAULT AS IDENTITY,\n"+
             "    PRIMARY KEY (\"COL_PK\", \"COL_PK_AUTO_INCR\")\n"+
             ");\n",
-            createTestDatabase(COLUMN_CONSTRAINT_TEST_SCHEMA));
+            getConstraintTestDatabaseCreationSql());
     }
 
 
@@ -150,7 +140,7 @@
             ");\n"+
             "ALTER TABLE \"table2\" ADD CONSTRAINT \"table2_FK_2_table1\" FOREIGN KEY (\"COL_FK_1\", \"COL_FK_2\") REFERENCES \"table1\" (\"COL_PK_2\", \"COL_PK_1\");\n"+
             "ALTER TABLE \"table3\" ADD CONSTRAINT \"testfk\" FOREIGN KEY (\"COL_FK\") REFERENCES \"table2\" (\"COL_PK\");\n",
-            createTestDatabase(TABLE_CONSTRAINT_TEST_SCHEMA));
+            getTableConstraintTestDatabaseCreationSql());
     }
 
     /**
@@ -166,6 +156,6 @@
             "    \"COL_TEXT\" VARCHAR(128) DEFAULT '\'\'',\n"+
             "    PRIMARY KEY (\"COL_PK\")\n"+
             ");\n",
-            createTestDatabase(COLUMN_CHAR_SEQUENCES_TO_ESCAPE));
+            getCharEscapingTestDatabaseCreationSql());
     }
 }

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestDerbyPlatform.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestDerbyPlatform.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestDerbyPlatform.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestDerbyPlatform.java Sun Feb 24 18:17:57 2008
@@ -29,16 +29,6 @@
  */
 public class TestDerbyPlatform extends TestPlatformBase
 {
-    /** The database schema for testing escaping of character sequences. */
-    public static final String COLUMN_CHAR_SEQUENCES_TO_ESCAPE =
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
-        "<database name='escapetest'>\n" +
-        "  <table name='escapedcharacters'>\n" +
-        "    <column name='COL_PK' type='INTEGER' primaryKey='true'/>\n" +
-        "    <column name='COL_TEXT' type='VARCHAR' size='128' default='&#39;'/>\n" +
-        "  </table>\n" +
-        "</database>";
-
     /**
      * {@inheritDoc}
      */
@@ -88,7 +78,7 @@
             "    \"COL_VARBINARY\"       VARCHAR(15) FOR BIT DATA,\n"+
             "    \"COL_VARCHAR\"         VARCHAR(15)\n"+
             ");\n",
-            createTestDatabase(COLUMN_TEST_SCHEMA));
+            getColumnTestDatabaseCreationSql());
     }
 
     /**
@@ -108,7 +98,7 @@
             "    \"COL_AUTO_INCR\"        BIGINT GENERATED BY DEFAULT AS IDENTITY,\n"+
             "    PRIMARY KEY (\"COL_PK\", \"COL_PK_AUTO_INCR\")\n"+
             ");\n",
-            createTestDatabase(COLUMN_CONSTRAINT_TEST_SCHEMA));
+            getConstraintTestDatabaseCreationSql());
     }
 
     /**
@@ -148,7 +138,7 @@
             ");\n"+
             "ALTER TABLE \"table2\" ADD CONSTRAINT \"table2_FK_COL_FK_1_COL_FK_2_table1\" FOREIGN KEY (\"COL_FK_1\", \"COL_FK_2\") REFERENCES \"table1\" (\"COL_PK_2\", \"COL_PK_1\");\n"+
             "ALTER TABLE \"table3\" ADD CONSTRAINT \"testfk\" FOREIGN KEY (\"COL_FK\") REFERENCES \"table2\" (\"COL_PK\");\n",
-            createTestDatabase(TABLE_CONSTRAINT_TEST_SCHEMA));
+            getTableConstraintTestDatabaseCreationSql());
     }
 
     /**
@@ -164,6 +154,6 @@
             "    \"COL_TEXT\" VARCHAR(128) DEFAULT '\'\'',\n"+
             "    PRIMARY KEY (\"COL_PK\")\n"+
             ");\n",
-            createTestDatabase(COLUMN_CHAR_SEQUENCES_TO_ESCAPE));
+            getCharEscapingTestDatabaseCreationSql());
     }
 }

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestFirebirdPlatform.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestFirebirdPlatform.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestFirebirdPlatform.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestFirebirdPlatform.java Sun Feb 24 18:17:57 2008
@@ -29,16 +29,6 @@
  */
 public class TestFirebirdPlatform extends TestPlatformBase
 {
-    /** The database schema for testing escaping of character sequences. */
-    public static final String COLUMN_CHAR_SEQUENCES_TO_ESCAPE =
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
-        "<database name='escapetest'>\n" +
-        "  <table name='escapedcharacters'>\n" +
-        "    <column name='COL_PK' type='INTEGER' primaryKey='true'/>\n" +
-        "    <column name='COL_TEXT' type='VARCHAR' size='128' default='&#39;'/>\n" +
-        "  </table>\n" +
-        "</database>";
-
     /**
      * {@inheritDoc}
      */
@@ -88,7 +78,7 @@
             "    \"COL_VARBINARY\"       BLOB(15),\n"+
             "    \"COL_VARCHAR\"         VARCHAR(15)\n"+
             ");\n",
-            createTestDatabase(COLUMN_TEST_SCHEMA));
+            getColumnTestDatabaseCreationSql());
     }
 
     /**
@@ -120,7 +110,7 @@
             "CREATE TRIGGER \"trg_constraints_COL_AUTO_INCR\" FOR \"constraints\"\n"+
             "ACTIVE BEFORE INSERT POSITION 0 AS\n"+
             "BEGIN IF (NEW.\"COL_AUTO_INCR\" IS NULL) THEN NEW.\"COL_AUTO_INCR\" = GEN_ID(\"gen_constraints_COL_AUTO_INCR\", 1); END;\n",
-            createTestDatabase(COLUMN_CONSTRAINT_TEST_SCHEMA));
+            getConstraintTestDatabaseCreationSql());
     }
 
     /**
@@ -160,7 +150,7 @@
             ");\n"+
             "ALTER TABLE \"table2\" ADD CONSTRAINT \"table2_FK_COL_F_COL_FK_2_table1\" FOREIGN KEY (\"COL_FK_1\", \"COL_FK_2\") REFERENCES \"table1\" (\"COL_PK_2\", \"COL_PK_1\");\n"+
             "ALTER TABLE \"table3\" ADD CONSTRAINT \"testfk\" FOREIGN KEY (\"COL_FK\") REFERENCES \"table2\" (\"COL_PK\");\n",
-            createTestDatabase(TABLE_CONSTRAINT_TEST_SCHEMA));
+            getTableConstraintTestDatabaseCreationSql());
     }
 
     /**
@@ -176,6 +166,6 @@
             "    \"COL_TEXT\" VARCHAR(128) DEFAULT '\'\'',\n"+
             "    PRIMARY KEY (\"COL_PK\")\n"+
             ");\n",
-            createTestDatabase(COLUMN_CHAR_SEQUENCES_TO_ESCAPE));
+            getCharEscapingTestDatabaseCreationSql());
     }
 }

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestHsqlDbPlatform.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestHsqlDbPlatform.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestHsqlDbPlatform.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestHsqlDbPlatform.java Sun Feb 24 18:17:57 2008
@@ -29,28 +29,6 @@
  */
 public class TestHsqlDbPlatform extends TestPlatformBase
 {
-    /** The database schema for testing column constraints. This is an version adapted for HsqlDb. */
-    public static final String COLUMN_CONSTRAINT_TEST_SCHEMA =
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
-        "<database name='columnconstraintstest'>\n" +
-        "  <table name='constraints'>\n" +
-        "    <column name='COL_PK' type='VARCHAR' size='32' primaryKey='true'/>\n" +
-        "    <column name='COL_PK_AUTO_INCR' type='INTEGER' primaryKey='true' autoIncrement='true'/>\n" +
-        "    <column name='COL_NOT_NULL' type='BINARY' size='100' required='true'/>\n" +
-        "    <column name='COL_NOT_NULL_DEFAULT' type='DOUBLE' required='true' default='-2.0'/>\n" +
-        "    <column name='COL_DEFAULT' type='CHAR' size='4' default='test'/>\n" +
-        "  </table>\n" +
-        "</database>";
-    /** The database schema for testing escaping of character sequences. */
-    public static final String COLUMN_CHAR_SEQUENCES_TO_ESCAPE =
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
-        "<database name='escapetest'>\n" +
-        "  <table name='escapedcharacters'>\n" +
-        "    <column name='COL_PK' type='INTEGER' primaryKey='true'/>\n" +
-        "    <column name='COL_TEXT' type='VARCHAR' size='128' default='&#39;'/>\n" +
-        "  </table>\n" +
-        "</database>";
-
     /**
      * {@inheritDoc}
      */
@@ -100,7 +78,7 @@
             "    \"COL_VARBINARY\"       VARBINARY(15),\n"+
             "    \"COL_VARCHAR\"         VARCHAR(15)\n"+
             ");\n",
-            createTestDatabase(COLUMN_TEST_SCHEMA));
+            getColumnTestDatabaseCreationSql());
     }
 
     /**
@@ -108,18 +86,31 @@
      */
     public void testColumnConstraints() throws Exception
     {
+        // adapted version for HsqlDb of the schema used for getColumnTestDatabaseCreationSql
+        final String schema =
+            "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
+            "<database name='columnconstraintstest'>\n" +
+            "  <table name='constraints'>\n" +
+            "    <column name='COL_PK' type='VARCHAR' size='32' primaryKey='true'/>\n" +
+            "    <column name='COL_PK_AUTO_INCR' type='INTEGER' primaryKey='true' autoIncrement='true'/>\n" +
+            "    <column name='COL_NOT_NULL' type='BINARY' size='100' required='true'/>\n" +
+            "    <column name='COL_NOT_NULL_DEFAULT' type='DOUBLE' required='true' default='-2.0'/>\n" +
+            "    <column name='COL_DEFAULT' type='CHAR' size='4' default='test'/>\n" +
+            "  </table>\n" +
+            "</database>";
+
         assertEqualsIgnoringWhitespaces(
             "DROP TABLE \"constraints\" IF EXISTS;\n" +
             "CREATE TABLE \"constraints\"\n"+
             "(\n"+
             "    \"COL_PK\"               VARCHAR(32),\n"+
-            "    \"COL_PK_AUTO_INCR\"     INTEGER IDENTITY,\n"+
+            "    \"COL_PK_AUTO_INCR\"     INTEGER GENERATED BY DEFAULT AS IDENTITY(START WITH 1),\n"+
             "    \"COL_NOT_NULL\"         BINARY(100) NOT NULL,\n"+
             "    \"COL_NOT_NULL_DEFAULT\" DOUBLE DEFAULT -2.0 NOT NULL,\n"+
             "    \"COL_DEFAULT\"          CHAR(4) DEFAULT 'test',\n"+
             "    PRIMARY KEY (\"COL_PK\", \"COL_PK_AUTO_INCR\")\n"+
             ");\n",
-            createTestDatabase(COLUMN_CONSTRAINT_TEST_SCHEMA));
+            getDatabaseCreationSql(schema));
     }
 
     /**
@@ -159,7 +150,7 @@
             ");\n"+
             "ALTER TABLE \"table2\" ADD CONSTRAINT \"table2_FK_COL_FK_1_COL_FK_2_table1\" FOREIGN KEY (\"COL_FK_1\", \"COL_FK_2\") REFERENCES \"table1\" (\"COL_PK_2\", \"COL_PK_1\");\n"+
             "ALTER TABLE \"table3\" ADD CONSTRAINT \"testfk\" FOREIGN KEY (\"COL_FK\") REFERENCES \"table2\" (\"COL_PK\");\n",
-            createTestDatabase(TABLE_CONSTRAINT_TEST_SCHEMA));
+            getTableConstraintTestDatabaseCreationSql());
     }
 
     /**
@@ -175,6 +166,6 @@
             "    \"COL_TEXT\" VARCHAR(128) DEFAULT '\'\'',\n"+
             "    PRIMARY KEY (\"COL_PK\")\n"+
             ");\n",
-            createTestDatabase(COLUMN_CHAR_SEQUENCES_TO_ESCAPE));
+            getCharEscapingTestDatabaseCreationSql());
     }
 }

Modified: db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestInterbasePlatform.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestInterbasePlatform.java?rev=630717&r1=630716&r2=630717&view=diff
==============================================================================
--- db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestInterbasePlatform.java (original)
+++ db/ddlutils/trunk/src/test/org/apache/ddlutils/platform/TestInterbasePlatform.java Sun Feb 24 18:17:57 2008
@@ -29,16 +29,6 @@
  */
 public class TestInterbasePlatform extends TestPlatformBase
 {
-    /** The database schema for testing escaping of character sequences. */
-    public static final String COLUMN_CHAR_SEQUENCES_TO_ESCAPE =
-        "<?xml version='1.0' encoding='ISO-8859-1'?>\n" +
-        "<database name='escapetest'>\n" +
-        "  <table name='escapedcharacters'>\n" +
-        "    <column name='COL_PK' type='INTEGER' primaryKey='true'/>\n" +
-        "    <column name='COL_TEXT' type='VARCHAR' size='128' default='&#39;'/>\n" +
-        "  </table>\n" +
-        "</database>";
-
     /**
      * {@inheritDoc}
      */
@@ -88,7 +78,7 @@
             "    \"COL_VARBINARY\"       BLOB,\n"+
             "    \"COL_VARCHAR\"         VARCHAR(15)\n"+
             ");\n",
-            createTestDatabase(COLUMN_TEST_SCHEMA));
+            getColumnTestDatabaseCreationSql());
     }
 
     /**
@@ -120,7 +110,7 @@
             "CREATE TRIGGER \"trg_constraints_COL_AUTO_INCR\" FOR \"constraints\"\n"+
             "ACTIVE BEFORE INSERT POSITION 0 AS\n"+
             "BEGIN IF (NEW.\"COL_AUTO_INCR\" IS NULL) THEN NEW.\"COL_AUTO_INCR\" = GEN_ID(\"gen_constraints_COL_AUTO_INCR\", 1); END;\n",
-            createTestDatabase(COLUMN_CONSTRAINT_TEST_SCHEMA));
+            getConstraintTestDatabaseCreationSql());
     }
 
     /**
@@ -160,7 +150,7 @@
             ");\n"+
             "ALTER TABLE \"table2\" ADD CONSTRAINT \"table2_FK_COL_F_COL_FK_2_table1\" FOREIGN KEY (\"COL_FK_1\", \"COL_FK_2\") REFERENCES \"table1\" (\"COL_PK_2\", \"COL_PK_1\");\n"+
             "ALTER TABLE \"table3\" ADD CONSTRAINT \"testfk\" FOREIGN KEY (\"COL_FK\") REFERENCES \"table2\" (\"COL_PK\");\n",
-            createTestDatabase(TABLE_CONSTRAINT_TEST_SCHEMA));
+            getTableConstraintTestDatabaseCreationSql());
     }
 
     /**
@@ -176,6 +166,6 @@
             "    \"COL_TEXT\" VARCHAR(128) DEFAULT '\'\'',\n"+
             "    PRIMARY KEY (\"COL_PK\")\n"+
             ");\n",
-            createTestDatabase(COLUMN_CHAR_SEQUENCES_TO_ESCAPE));
+            getCharEscapingTestDatabaseCreationSql());
     }
 }



Mime
View raw message