List:Commits« Previous MessageNext Message »
From:tikeda Date:January 25 2006 11:33pm
Subject:Connector/J commit: r4853 - in branches/branch_5_1/connector-j/src: com/mysql/jdbc testsuite/simple
View as plain text  
Modified:
   branches/branch_5_1/connector-j/src/com/mysql/jdbc/PreparedStatement.java
   branches/branch_5_1/connector-j/src/testsuite/simple/StatementsTest.java
Log:
upgraded PreparedStatement.setNString and test

Modified: branches/branch_5_1/connector-j/src/com/mysql/jdbc/PreparedStatement.java
===================================================================
--- branches/branch_5_1/connector-j/src/com/mysql/jdbc/PreparedStatement.java	2006-01-25 22:49:15 UTC (rev 4852)
+++ branches/branch_5_1/connector-j/src/com/mysql/jdbc/PreparedStatement.java	2006-01-25 23:33:08 UTC (rev 4853)
@@ -2433,8 +2433,13 @@
         
         // if the passed string is null, then set this column to null
         if (x == null) {
-            setNull(parameterIndex, Types.CHAR);
-        } else {
+            //setNull(parameterIndex, Types.NCHAR);
+            x = "null";
+            this.isNull[parameterIndex - 1] = true;
+        }
+
+            
+        //} else {
             int stringLength = x.length();
             // Ignore sql_mode=NO_BACKSLASH_ESCAPES in current implementation.
 
@@ -2521,7 +2526,7 @@
             }
 
             setInternal(parameterIndex, parameterAsBytes);
-        }
+        //}
     }
 
 	/**

Modified: branches/branch_5_1/connector-j/src/testsuite/simple/StatementsTest.java
===================================================================
--- branches/branch_5_1/connector-j/src/testsuite/simple/StatementsTest.java	2006-01-25 22:49:15 UTC (rev 4852)
+++ branches/branch_5_1/connector-j/src/testsuite/simple/StatementsTest.java	2006-01-25 23:33:08 UTC (rev 4853)
@@ -1433,12 +1433,16 @@
         Connection conn1 = getConnectionWithProps(props1);
         com.mysql.jdbc.PreparedStatement pstmt1 = (com.mysql.jdbc.PreparedStatement)
             conn1.prepareStatement("INSERT INTO testSetNString (c1) VALUES (?)");
+        pstmt1.setNString(1, null);
+        pstmt1.execute();
         pstmt1.setNString(1, "aaa");
         pstmt1.execute();
         pstmt1.setNString(1, "\'aaa\'");
         pstmt1.execute();
         ResultSet rs1 = this.stmt.executeQuery("SELECT c1 FROM testSetNString");
         rs1.next();
+        assertEquals("null", rs1.getString(1));
+        rs1.next();
         assertEquals("aaa", rs1.getString(1));
         rs1.next();
         assertEquals("\'aaa\'", rs1.getString(1));
@@ -1454,14 +1458,10 @@
         Connection conn2 = getConnectionWithProps(props2);
         com.mysql.jdbc.PreparedStatement pstmt2 = (com.mysql.jdbc.PreparedStatement)
             conn2.prepareStatement("INSERT INTO testSetNString (c1) VALUES (?)");
-        pstmt2.setNString(1, "aaa");
-        pstmt2.execute();
         pstmt2.setNString(1, "\'aaa\'");
         pstmt2.execute();
         ResultSet rs2 = this.stmt.executeQuery("SELECT c1 FROM testSetNString");
         rs2.next();
-        assertEquals("aaa", rs2.getString(1));
-        rs2.next();
         assertEquals("\'aaa\'", rs2.getString(1));
         rs2.close();
         pstmt2.close();

Thread
Connector/J commit: r4853 - in branches/branch_5_1/connector-j/src: com/mysql/jdbc testsuite/simpletikeda26 Jan