db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r381141 - in /db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase: SybaseModelReader.java SybasePlatform.java
Date Sun, 26 Feb 2006 19:24:16 GMT
Author: tomdz
Date: Sun Feb 26 11:24:14 2006
New Revision: 381141

URL: http://svn.apache.org/viewcvs?rev=381141&view=rev
Log:
Fixes to the blob/clob handling and the determination of auto-increment fields for the Sybase
platform

Modified:
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybaseModelReader.java
    db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybasePlatform.java

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybaseModelReader.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybaseModelReader.java?rev=381141&r1=381140&r2=381141&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 26 11:24:14 2006
@@ -58,6 +58,9 @@
     public SybaseModelReader(PlatformInfo platformInfo)
     {
         super(platformInfo);
+        setDefaultCatalogPattern(null);
+        setDefaultSchemaPattern(null);
+        setDefaultTablePattern("%");
 
         PatternCompiler compiler = new Perl5Compiler();
 
@@ -71,6 +74,21 @@
         	throw new DdlUtilsException(ex);
         }
     }
+
+    /**
+     * {@inheritDoc}
+     */
+	protected Table readTable(DatabaseMetaDataWrapper metaData, Map values) throws SQLException
+	{
+        Table table = super.readTable(metaData, values);
+
+        if (table != null)
+        {
+            // Sybase does not return the auto-increment status via the database metadata
+            determineAutoIncrementFromResultSetMetaData(table, table.getColumns());
+        }
+        return table;
+	}
 
 	/**
      * {@inheritDoc}

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybasePlatform.java
URL: http://svn.apache.org/viewcvs/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/sybase/SybasePlatform.java?rev=381141&r1=381140&r2=381141&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 26 11:24:14 2006
@@ -74,26 +74,27 @@
         info.addNativeTypeMapping(Types.ARRAY,         "IMAGE");
         // 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);
+        // BIGINT is mapped back in the model reader
         info.addNativeTypeMapping(Types.BIGINT,        "DECIMAL(19,0)");
-        info.addNativeTypeMapping(Types.BLOB,          "IMAGE");
-        info.addNativeTypeMapping(Types.CLOB,          "TEXT");
+        info.addNativeTypeMapping(Types.BLOB,          "IMAGE",            Types.LONGVARBINARY);
+        info.addNativeTypeMapping(Types.CLOB,          "TEXT",             Types.LONGVARCHAR);
         info.addNativeTypeMapping(Types.DATE,          "DATETIME",         Types.TIMESTAMP);
-        info.addNativeTypeMapping(Types.DISTINCT,      "IMAGE");
+        info.addNativeTypeMapping(Types.DISTINCT,      "IMAGE",            Types.LONGVARBINARY);
         info.addNativeTypeMapping(Types.DOUBLE,        "DOUBLE PRECISION");
         info.addNativeTypeMapping(Types.FLOAT,         "DOUBLE PRECISION", Types.DOUBLE);
         info.addNativeTypeMapping(Types.INTEGER,       "INT");
-        info.addNativeTypeMapping(Types.JAVA_OBJECT,   "IMAGE");
+        info.addNativeTypeMapping(Types.JAVA_OBJECT,   "IMAGE",            Types.LONGVARBINARY);
         info.addNativeTypeMapping(Types.LONGVARBINARY, "IMAGE");
         info.addNativeTypeMapping(Types.LONGVARCHAR,   "TEXT");
-        info.addNativeTypeMapping(Types.NULL,          "IMAGE");
-        info.addNativeTypeMapping(Types.OTHER,         "IMAGE");
-        info.addNativeTypeMapping(Types.REF,           "IMAGE");
-        info.addNativeTypeMapping(Types.STRUCT,        "IMAGE");
+        info.addNativeTypeMapping(Types.NULL,          "IMAGE",            Types.LONGVARBINARY);
+        info.addNativeTypeMapping(Types.OTHER,         "IMAGE",            Types.LONGVARBINARY);
+        info.addNativeTypeMapping(Types.REF,           "IMAGE",            Types.LONGVARBINARY);
+        info.addNativeTypeMapping(Types.STRUCT,        "IMAGE",            Types.LONGVARBINARY);
         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");
+        info.addNativeTypeMapping("DATALINK", "IMAGE",    "LONGVARBINARY");
 
         info.addDefaultSize(Types.BINARY,    254);
         info.addDefaultSize(Types.VARBINARY, 254);
@@ -196,11 +197,22 @@
      */
 	protected void setStatementParameterValue(PreparedStatement statement, int sqlIndex, int
typeCode, Object value) throws SQLException
 	{
-		if ((value instanceof byte[]) && (typeCode == Types.LONGVARBINARY))
+		if ((value instanceof byte[]) && ((typeCode == Types.LONGVARBINARY) || (typeCode
== Types.BLOB)))
 		{
 			byte[] data = (byte[])value;
 
 			statement.setBinaryStream(sqlIndex, new ByteArrayInputStream(data), data.length);
+		}
+		else if (typeCode == Types.BLOB)
+		{
+			// Sybase doesn't like the BLOB type, but works without problems with LONGVARBINARY
+			// even when using the Blob class
+			super.setStatementParameterValue(statement, sqlIndex, Types.LONGVARBINARY, value);
+		}
+		else if (typeCode == Types.CLOB)
+		{
+			// Same for CLOB and LONGVARCHAR
+			super.setStatementParameterValue(statement, sqlIndex, Types.LONGVARCHAR, value);
 		}
 		else
 		{



Mime
View raw message