Consider the following scenario:
- You install Microsoft SQL Server JDBC Driver 3.0 on a computer.
- You create a Java-based application that connects to a SQL Server by using the Java Database Connectivity (JDBC) driver.
- You use the getSQLState method to catch the state code of an exception in the application.
- You run the application.
- A SQL Server database error occurs.
In this scenario, the application receives an incorrect state code value for the database error.
For example, a Java-based application inserts a duplicate record in a table that contains a unique cluster index by using SQL Server JDBC Driver 3.0. In this scenario, the correct
SQLState value is
23000. However, you receive the following error message that contains an incorrect
SQLState value:
SQL Error Message= Cannot insert duplicate key row in object '<table name>' with unique index '<index name>'.
SQLState=S0001
SQL Error Code=2601