Bug #38943 SQLException.getMessage() returns null, no indication of reason for error
Submitted: 21 Aug 2008 16:13 Modified: 2 Jun 2015 20:14
Reporter: Robert Simpson Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:5.1.6 OS:Any (Win XP 5.1.2600)
Assigned to: Alexander Soklakov CPU Architecture:Any
Tags: getMessage, getstring, SqlException

[21 Aug 2008 16:13] Robert Simpson
Description:
After upgrading to Connector/J 5.1.6 (to resolve an AbstractMethodError problem after upgrading to Java SDK 1.6), the application which previously worked was getting a NullPointerException.  Adding code to handle that revealed that the SQLException.getMessage() method was returning null, so there's no indication of why the error occurred....

SQLState S1000 from com.mysql.jdbc.JDBC4ResultSet.getString for column 1 of ResultSet from "java.sql.DatabaseMetaData.getTables()"
java.sql.SQLException
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926)
        at com.mysql.jdbc.ResultSetImpl.checkRowPos(ResultSetImpl.java:815)
        at com.mysql.jdbc.ResultSetImpl.getStringInternal(ResultSetImpl.java:5528)
        at com.mysql.jdbc.ResultSetImpl.getString(ResultSetImpl.java:5448)

How to repeat:
connect to database

call DatabaseMetaData.getTables()

call getString(1) to return the first column of the ResultSet
[21 Aug 2008 20:04] Sveta Smirnova
Thank you for the report.

I can not repeat described behavior with generic test case. Please provide example of code bug is repeatable with.
[22 Aug 2008 14:37] Robert Simpson
See also forum message:

   http://forums.mysql.com/read.php?39,199533,200282#msg-200282

which says "getMessage() ... was null ... not very helpful"
[23 Aug 2008 10:48] Sveta Smirnova
Thank you for the feedback.

Verified as described.
[23 Aug 2008 10:49] Sveta Smirnova
test case for the testsuite

Attachment: bug38943.java (text/plain), 647 bytes.

[2 Jun 2015 20:14] Daniel So
Added the following entry to the Connector/J 5.1.7 changelog:

"When an application using Connector/J ran into an error, the SQLException.getMessage() method was returning null instead of an error description. This has been fixed by calling the setRowPositionValidity() method in the ResultSetImpl constructor."