Modified:
branches/branch_5_0/connector-j/CHANGES
branches/branch_5_0/connector-j/src/com/mysql/jdbc/ResultSet.java
branches/branch_5_0/connector-j/src/testsuite/regression/ResultSetRegressionTest.java
Log:
Fixed BUG#30851, NPE with null column values when "padCharsWithSpace" is set to "true".
Modified: branches/branch_5_0/connector-j/CHANGES
===================================================================
--- branches/branch_5_0/connector-j/CHANGES 2007-09-05 16:02:17 UTC (rev 6562)
+++ branches/branch_5_0/connector-j/CHANGES 2007-09-06 14:02:01 UTC (rev 6563)
@@ -52,6 +52,9 @@
- Fixed BUG#27915 - DatabaseMetaData.getColumns() doesn't
contain SCOPE_* or IS_AUTOINCREMENT columns.
+ - Fixed BUG#30851, NPE with null column values when
+ "padCharsWithSpace" is set to "true".
+
07-19-07 - Version 5.0.7
- Setting the configuration parameter "useCursorFetch" to "true" for
Modified: branches/branch_5_0/connector-j/src/com/mysql/jdbc/ResultSet.java
===================================================================
--- branches/branch_5_0/connector-j/src/com/mysql/jdbc/ResultSet.java 2007-09-05 16:02:17
UTC (rev 6562)
+++ branches/branch_5_0/connector-j/src/com/mysql/jdbc/ResultSet.java 2007-09-06 14:02:01
UTC (rev 6563)
@@ -5543,7 +5543,7 @@
public String getString(int columnIndex) throws SQLException {
String stringVal = getStringInternal(columnIndex, true);
- if (this.padCharsWithSpace) {
+ if (stringVal != null && this.padCharsWithSpace) {
Field f = this.fields[columnIndex - 1];
if (f.getMysqlType() == MysqlDefs.FIELD_TYPE_STRING ) {
Modified:
branches/branch_5_0/connector-j/src/testsuite/regression/ResultSetRegressionTest.java
===================================================================
---
branches/branch_5_0/connector-j/src/testsuite/regression/ResultSetRegressionTest.java 2007-09-05
16:02:17 UTC (rev 6562)
+++
branches/branch_5_0/connector-j/src/testsuite/regression/ResultSetRegressionTest.java 2007-09-06
14:02:01 UTC (rev 6563)
@@ -4435,5 +4435,31 @@
} finally {
closeMemberJDBCResources();
}
- }
+ }
+
+ /**
+ * Tests fix for BUG#30851, NPE with null column values when
+ * "padCharsWithSpace" is set to "true".
+ *
+ * @throws Exception
+ */
+ public void testbug30851() throws Exception {
+ Connection padConn = getConnectionWithProps("padCharsWithSpace=true");
+
+ try {
+ createTable("bug30851", "(CharCol CHAR(10) DEFAULT NULL)");
+ this.stmt.execute("INSERT INTO bug30851 VALUES (NULL)");
+ this.rs = padConn.createStatement().executeQuery("SELECT * FROM bug30851");
+ this.rs.first();
+ String strvar = this.rs.getString(1);
+ //assertNotNull("Should be null", strvar);
+
+ } finally {
+ closeMemberJDBCResources();
+
+ if (padConn != null) {
+ padConn.close();
+ }
+ }
+ }
}
\ No newline at end of file
| Thread |
|---|
| • Connector/J commit: r6563 - in branches/branch_5_0/connector-j: . src/com/mysql/jdbc src/testsuite/regression | mmatthews | 6 Sep |