db-ddlutils-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject svn commit: r509917 - in /db/ddlutils/trunk/src/java/org/apache/ddlutils/platform: ModelBasedResultSetIterator.java sybase/SybaseBuilder.java sybase/SybasePlatform.java
Date Wed, 21 Feb 2007 06:41:14 GMT
Author: tomdz
Date: Tue Feb 20 22:41:14 2007
New Revision: 509917

URL: http://svn.apache.org/viewvc?view=rev&rev=509917
Log:
Fixed bugs for Sybase

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

Modified: db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/ModelBasedResultSetIterator.java
URL: http://svn.apache.org/viewvc/db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/ModelBasedResultSetIterator.java?view=diff&rev=509917&r1=509916&r2=509917
==============================================================================
--- db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/ModelBasedResultSetIterator.java
(original)
+++ db/ddlutils/trunk/src/java/org/apache/ddlutils/platform/ModelBasedResultSetIterator.java
Tue Feb 20 22:41:14 2007
@@ -127,6 +127,11 @@
 
             if ((tableOfColumn != null) && (tableOfColumn.length() > 0))
             {
+                // jConnect might return a table name enclosed in quotes
+                if (tableOfColumn.startsWith("\"") && tableOfColumn.endsWith("\"")
&& (tableOfColumn.length() > 1))
+                {
+                    tableOfColumn = tableOfColumn.substring(1, tableOfColumn.length() - 1);
+                }
                 // the JDBC driver gave us enough meta data info
                 table = model.findTable(tableOfColumn, _caseSensitive);
             }

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?view=diff&rev=509917&r1=509916&r2=509917
==============================================================================
--- 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 Tue
Feb 20 22:41:14 2007
@@ -193,7 +193,6 @@
     {
         StringBuffer result = new StringBuffer();
 
-        result.append(getQuotationOnStatement());
         result.append("SET IDENTITY_INSERT ");
         result.append(getDelimitedIdentifier(getTableName(table)));
         result.append(" ON");
@@ -211,7 +210,6 @@
     {
         StringBuffer result = new StringBuffer();
 
-        result.append(getQuotationOnStatement());
         result.append("SET IDENTITY_INSERT ");
         result.append(getDelimitedIdentifier(getTableName(table)));
         result.append(" OFF");
@@ -224,7 +222,7 @@
      * 
      * @return The quotation-on statement
      */
-    private String getQuotationOnStatement()
+    protected String getQuotationOnStatement()
     {
         if (getPlatform().isDelimitedIdentifierModeOn())
         {

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?view=diff&rev=509917&r1=509916&r2=509917
==============================================================================
--- 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 Tue
Feb 20 22:41:14 2007
@@ -147,7 +147,7 @@
 	{
         boolean useIdx = (columnName == null);
 
-        if (jdbcType == Types.LONGVARBINARY)
+        if ((jdbcType == Types.LONGVARBINARY) || (jdbcType == Types.BLOB))
 		{
 			InputStream stream = useIdx ? resultSet.getBinaryStream(columnIdx) : resultSet.getBinaryStream(columnName);
 
@@ -197,18 +197,23 @@
      */
 	protected void setStatementParameterValue(PreparedStatement statement, int sqlIndex, int
typeCode, Object value) throws SQLException
 	{
-		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);
-		}
+        if ((typeCode == Types.BLOB) || (typeCode == Types.LONGVARBINARY))
+        {
+            // jConnect doesn't like the BLOB type, but works without problems with LONGVARBINARY
+            // even when using the Blob class
+            if (value instanceof byte[])
+            {
+                byte[] data = (byte[])value;
+
+                statement.setBinaryStream(sqlIndex, new ByteArrayInputStream(data), data.length);
+            }
+            else
+            {
+                // 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
@@ -277,9 +282,17 @@
     {
         if (useIdentityOverrideFor(table))
         {
-            SybaseBuilder builder = (SybaseBuilder)getSqlBuilder();
-    
-            connection.createStatement().execute(builder.getEnableIdentityOverrideSql(table));
+            SybaseBuilder builder          = (SybaseBuilder)getSqlBuilder();
+            String        quotationOn      = builder.getQuotationOnStatement();
+            String        identityInsertOn = builder.getEnableIdentityOverrideSql(table);
+            Statement     stmt             = connection.createStatement();
+
+            if (quotationOn.length() > 0)
+            {
+                stmt.execute(quotationOn);
+            }
+            stmt.execute(identityInsertOn);
+            stmt.close();
         }
     }
 
@@ -290,9 +303,17 @@
     {
         if (useIdentityOverrideFor(table))
         {
-            SybaseBuilder builder = (SybaseBuilder)getSqlBuilder();
-    
-            connection.createStatement().execute(builder.getDisableIdentityOverrideSql(table));
+            SybaseBuilder builder           = (SybaseBuilder)getSqlBuilder();
+            String        quotationOn       = builder.getQuotationOnStatement();
+            String        identityInsertOff = builder.getDisableIdentityOverrideSql(table);
+            Statement     stmt              = connection.createStatement();
+
+            if (quotationOn.length() > 0)
+            {
+                stmt.execute(quotationOn);
+            }
+            stmt.execute(identityInsertOff);
+            stmt.close();
         }
     }
 



Mime
View raw message