Modified:
branches/branch_3_1/connector-j/CHANGES
branches/branch_3_1/connector-j/src/com/mysql/jdbc/PreparedStatement.java
branches/branch_3_1/connector-j/src/testsuite/regression/StatementRegressionTest.java
Log:
Fixed BUG#15383 - PreparedStatement.setObject() serializes
BigInteger as object, rather than sending as numeric value
(and is thus not complementary to .getObject() on an UNSIGNED
LONG type).
Modified: branches/branch_3_1/connector-j/CHANGES
===================================================================
--- branches/branch_3_1/connector-j/CHANGES 2005-12-19 16:28:40 UTC (rev 4708)
+++ branches/branch_3_1/connector-j/CHANGES 2005-12-19 16:47:38 UTC (rev 4709)
@@ -10,6 +10,11 @@
- Fixed BUG#15544, no "dos" character set in MySQL > 4.1.0
+ - Fixed BUG#15383 - PreparedStatement.setObject() serializes
+ BigInteger as object, rather than sending as numeric value
+ (and is thus not complementary to .getObject() on an UNSIGNED
+ LONG type).
+
11-30-05 - Version 3.1.12
- Fixed client-side prepared statement bug with embedded ? inside
Modified: branches/branch_3_1/connector-j/src/com/mysql/jdbc/PreparedStatement.java
===================================================================
--- branches/branch_3_1/connector-j/src/com/mysql/jdbc/PreparedStatement.java 2005-12-19
16:28:40 UTC (rev 4708)
+++ branches/branch_3_1/connector-j/src/com/mysql/jdbc/PreparedStatement.java 2005-12-19
16:47:38 UTC (rev 4709)
@@ -33,6 +33,7 @@
import java.io.StringReader;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
+import java.math.BigInteger;
import java.net.URL;
import java.sql.Array;
import java.sql.Clob;
@@ -2508,6 +2509,8 @@
} else if (parameterObj instanceof java.util.Date) {
setTimestamp(parameterIndex, new Timestamp(
((java.util.Date) parameterObj).getTime()));
+ } else if (parameterObj instanceof BigInteger) {
+ setString(parameterIndex, parameterObj.toString());
} else {
setSerializableObject(parameterIndex, parameterObj);
}
Modified:
branches/branch_3_1/connector-j/src/testsuite/regression/StatementRegressionTest.java
===================================================================
---
branches/branch_3_1/connector-j/src/testsuite/regression/StatementRegressionTest.java 2005-12-19
16:28:40 UTC (rev 4708)
+++
branches/branch_3_1/connector-j/src/testsuite/regression/StatementRegressionTest.java 2005-12-19
16:47:38 UTC (rev 4709)
@@ -35,6 +35,7 @@
import java.io.StringReader;
import java.io.Writer;
import java.math.BigDecimal;
+import java.math.BigInteger;
import java.sql.BatchUpdateException;
import java.sql.Blob;
import java.sql.Clob;
@@ -2946,4 +2947,48 @@
}
}
+ /**
+ * Tests fix for BUG#15383 - PreparedStatement.setObject()
+ * serializes BigInteger as object, rather than sending as
+ * numeric value (and is thus not complementary to .getObject()
+ * on an UNSIGNED LONG type).
+ *
+ * @throws Exception if the test fails.
+ */
+ public void testBug15383() throws Exception {
+ createTable("testBug15383", "(id INTEGER UNSIGNED NOT NULL "
+ + "AUTO_INCREMENT,value BIGINT UNSIGNED NULL DEFAULT 0,PRIMARY "
+ + "KEY(id))ENGINE=InnoDB;");
+
+ this.stmt.executeUpdate("INSERT INTO testBug15383(value) VALUES(1)");
+
+ Statement updatableStmt = this.conn.createStatement(
+ ResultSet.TYPE_FORWARD_ONLY,
+ ResultSet.CONCUR_UPDATABLE);
+
+ try {
+ this.rs = updatableStmt.executeQuery("SELECT * from testBug15383");
+
+ assertTrue(rs.next());
+
+ Object bigIntObj = rs.getObject("value");
+ assertEquals("java.math.BigInteger", bigIntObj.getClass().getName());
+
+ this.rs.updateObject("value", new BigInteger("3"));
+ this.rs.updateRow();
+
+ assertEquals("3", this.rs.getString("value"));
+ } finally {
+ if (this.rs != null) {
+ ResultSet toClose = this.rs;
+ this.rs = null;
+ toClose.close();
+ }
+
+ if (updatableStmt != null) {
+ updatableStmt.close();
+ }
+ }
+ }
+
}
| Thread |
|---|
| • Connector/J commit: r4709 - in branches/branch_3_1/connector-j: . src/com/mysql/jdbc src/testsuite/regression | mmatthews | 19 Dec |