Retrieving SQLException Errors with JDBC
Posted in 2000
Topics: Error Codes & Troubleshooting, Connectivity: ODBC / JDBC / .NET, Data Types & Schema Design, Migration, Import/Export & Data Conversion, Java & JDBC Development
When a SQLException is raised, the "Message:" returned from e.getMessage() is always null. I would expect that the message text from "finderr" would be retreived. Is there a setting that I need for this to happen? Here is a code snip of the catch: catch (SQLException e) { System.out.println( "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\\n" + "A transaction error has occured. A rollback() command has been issued.\\n" + "See below for details.\\n\\n" + "SQLState: " + e.getSQLState() + "\\n" + "Message: " + e.getMessage() + "\\n" + "Error Code: " + e.getErrorCode() + "\\n" + "SQL Statement:\\n\\n" + cmd + "\\n" + "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *"); return false; } So, for "Error Code: -79741", I would expect "Message: " to contain: Can't convert to. No data conversion is possible from the column data type to the one specified. The actual data type is appended to the end of this message. Review your program logic to make sure that the conversion you asked for is supported. For the data mapping matrix, see the Informix JDBC Driver Programmer's Guide. Any ideas? Steve Romankiw
Steve, This is a documented bug with Informix's JDBC 2.11 driver -- the getMessage method is broken. Workaround is to use the debug version of the driver. Here's the ticket from Informix's own bug database: Bug: 134686 JDBC 2.11 GETMESSAGE() CLASS RETURNS NULL FOR ALL ERROR NUMBERS WHEN USING THE IFXJDBC.JAR. WORKS FINE WITH IFXJDBC-G.JAR Date: 2000-10-05 Category: JDBC Type: SW Submitter: jeakins Description: First of all, I should note that this is NOT bug 101027, 103288 or 104291. Each of those bugs are fixed in JDBC 2.00.JC1. This is a new issue in JDBC 2.11 When an applications try/catch block calls the getMessage() class, a NULL value is always returned if using the ifxjdbc.jar in your CLASSPATH. The problem does NOT reproduce if using ifxjdbc-g.jar. Workaround: 8096 Use the ifxjdbc-g.jar in your CLASSPATH environment variable Now you'd think that this kind of information would be available via the Informix website -- and some of it is: there is an exceptionally poorly designed query screen into the bug database off the Tech Info link that if you use any of the above keywords will not yield the ticket. I only got it because of the efforts of one of Informix tech support's more diligent people. Way to web. Steve Romankiw1 wrote: > When a SQLException is raised, the "Message:" returned from e.getMessage() > is always null. I would expect that the message text from "finderr" would > be retreived. Is there a setting that I need for this to happen? > > Here is a code snip of the catch: > catch (SQLException e) > { > System.out.println( > "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * > * * * *\\n" + > "A transaction error has occured. A rollback() command has been > issued.\\n" + > "See below for details.\\n\\n" + > "SQLState: " + e.getSQLState() + "\\n" + > "Message: " + e.getMessage() + "\\n" + > "Error Code: " + e.getErrorCode() + "\\n" + > "SQL Statement:\\n\\n" + cmd + "\\n" + > "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * > * * * *"); > > return false; > > } > > So, for "Error Code: -79741", I would expect "Message: " to contain: > > Can't convert to. > > No data conversion is possible from the column data type to the one > specified. The actual data type is appended to the end of this message. > > Review your program logic to make sure that the conversion you asked for is > supported. For the data mapping matrix, see the Informix JDBC Driver > Programmer's Guide. > > Any ideas? > > Steve Romankiw
I noticed that. If I tried to do something like jLabel.setText(e.getMessage()); it didn't work, but if I used System.out.println(e.getMessage()); it worked fine. Now that's weird... Steve Romankiw1 wrote: > When a SQLException is raised, the "Message:" returned from e.getMessage() > is always null. I would expect that the message text from "finderr" would > be retreived. Is there a setting that I need for this to happen? > > Here is a code snip of the catch: > catch (SQLException e) > { > System.out.println( > "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * > * * * *\\n" + > "A transaction error has occured. A rollback() command has been > issued.\\n" + > "See below for details.\\n\\n" + > "SQLState: " + e.getSQLState() + "\\n" + > "Message: " + e.getMessage() + "\\n" + > "Error Code: " + e.getErrorCode() + "\\n" + > "SQL Statement:\\n\\n" + cmd + "\\n" + > "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * > * * * *"); > > return false; > > } > > So, for "Error Code: -79741", I would expect "Message: " to contain: > > Can't convert to. > > No data conversion is possible from the column data type to the one > specified. The actual data type is appended to the end of this message. > > Review your program logic to make sure that the conversion you asked for is > supported. For the data mapping matrix, see the Informix JDBC Driver > Programmer's Guide. > > Any ideas? > > Steve Romankiw