What are all the possible values for SQLException.getSQLState?

Official documents that include SQLStates can obviously be purchased, at a relatively high price, from ANSI and XOpen. But, the documentation for most databases have lists of SQLStates. Probably the most complete ( and accessible ) online listings are in the DB2 manuals. Check the DB2 Universal Messages manual, for instance. Oracle ( TechNet password required ) and Sybase, among others, also have online listings.

As to the second question, this is the intent of SQLState, however, the various databases have varying degrees of compliance. For example, some map multiple native error messages to the same SQLState. For generic use, one should probably concentrate on the major code ( the first two characters of SQLState, ) then determine if more specific info is available in the minor code ( beyond 000. )

http://www.jguru.com/faq/view.jsp?EID=46397


The X/Open (now Open Group) standards are now available free of charge (but registration required). See Data Management: SQL Call Level Interface (CLI) for the SQL CLI (aka ODBC) standard, SQLSTATE codes are defined in Appendix A. And Data Management: Structured Query Language (SQL), Version 2 for the SQL standard, SQLSTATE codes are defined in Appendix B. As for the ISO standards, while you have to pay for the official versions, the final drafts (which are almost identical) are freely available; for SQL:2011, see page 2017 (by PDF numbering; 1194 by document page numbering) of Final Committee Draft ISO/IEC FCD 9075-2


MySQL provides some info in its reference manual in Server Error Codes and Messages