You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by ba...@apache.org on 2006/02/08 08:10:48 UTC

svn commit: r375877 - in /db/derby/code/trunk/java: engine/org/apache/derby/iapi/types/ testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/

Author: bandaram
Date: Tue Feb  7 23:10:47 2006
New Revision: 375877

URL: http://svn.apache.org/viewcvs?rev=375877&view=rev
Log:
DERBY-628: Allow setting a CLOB to NULL using any character types for setNull.

Submitted by Satheesh Bandaram(satheesh@sourcery.org)


Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/parameterMapping.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/prepStmtNull.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/prepStmtNull.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java?rev=375877&r1=375876&r2=375877&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/types/DataTypeDescriptor.java Tue Feb  7 23:10:47 2006
@@ -990,6 +990,10 @@
 			return false;
 		}
 		
+		// To CLOB
+		if (existingType == Types.CLOB && DataTypeDescriptor.isCharacterType(jdbcTypeId))
+			return true;
+
 		return false;
 	}
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/parameterMapping.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/parameterMapping.out?rev=375877&r1=375876&r2=375877&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/parameterMapping.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/parameterMapping.out Tue Feb  7 23:10:47 2006
@@ -3290,12 +3290,12 @@
   setNull with batching support(Types.NUMERIC) IC
   setNull(Types.BIT) IC
   setNull with batching support(Types.BIT) IC
-  setNull(CHAR) IC
-  setNull with batching support(CHAR) IC
-  setNull(VARCHAR) IC
-  setNull with batching support(VARCHAR) IC
-  setNull(LONG VARCHAR) IC
-  setNull with batching support(LONG VARCHAR) IC
+  setNull(CHAR) getClob=null was null true
+  setNull with batching support(CHAR) getClob=null was null true
+  setNull(VARCHAR) getClob=null was null true
+  setNull with batching support(VARCHAR) getClob=null was null true
+  setNull(LONG VARCHAR) getClob=null was null true
+  setNull with batching support(LONG VARCHAR) getClob=null was null true
   setNull(VARCHAR () FOR BIT DATA) IC
   setNull with batching support(VARCHAR () FOR BIT DATA) IC
   setNull(DATE) IC

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/prepStmtNull.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/prepStmtNull.out?rev=375877&r1=375876&r2=375877&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/prepStmtNull.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/prepStmtNull.out Tue Feb  7 23:10:47 2006
@@ -4,3 +4,5 @@
 Test prepStmtNull starting
 ResultSet is: blob
 ResultSet is: null
+Test3 prepStmtNull starting
+ResultSet is: null

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/prepStmtNull.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/prepStmtNull.java?rev=375877&r1=375876&r2=375877&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/prepStmtNull.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/prepStmtNull.java Tue Feb  7 23:10:47 2006
@@ -13,6 +13,7 @@
     public static void main(String[] args) {
         test1(args);
         test2(args);
+        test3(args);
     }
     
         public static void test1(String []args) {   
@@ -117,6 +118,48 @@
  		}
      }
      
+     /* Test setNull() on Clob/Blob using Varchar/binary types */
+     public static void test3(String []args) {
+          Connection con;
+          ResultSet rs;
+          PreparedStatement stmt = null;
+          PreparedStatement pStmt = null;
+          Statement stmt1 = null;
+          byte[] b2 = new byte[1];
+          b2[0] = (byte)64;
+
+          System.out.println("Test3 prepStmtNull starting");
+
+          try
+          {
+               // use the ij utility to read the property file and
+               // make the initial connection.
+               ij.getPropertyArg(args);
+               con = ij.startJBMS();
+					
+               stmt = con.prepareStatement("create table ClobBlob(cval clob, bval blob(16K))");
+               stmt.executeUpdate();
+   			
+               pStmt = con.prepareStatement("insert into ClobBlob values (?,?)");
+   			   			
+               pStmt.setNull(1, Types.VARCHAR);
+               pStmt.setBytes(2, b2);
+               pStmt.execute();
+
+               stmt1 = con.createStatement();
+               rs = stmt1.executeQuery("select * from ClobBlob");
+               while(rs.next()) {
+                    System.out.println("ResultSet is: "+rs.getObject(1));
+               }
+               String[] testObjects = {"table ClobBlob"};
+               TestUtil.cleanUpTest(stmt1, testObjects);
+          } catch(SQLException sqle) {
+               dumpSQLExceptions(sqle);
+          } catch(Throwable e) {
+               System.out.println("FAIL -- unexpected exception: ");
+          }
+     }
+     
      static private void dumpSQLExceptions (SQLException se) {
                 System.out.println("FAIL -- unexpected exception");
                 while (se != null) {
@@ -124,4 +167,4 @@
                         se = se.getNextException();
                 }
         }
-}     
+}