When the Vertica JDBC driver encounters an error, it throws a SQLException
or one of its subclasses. The specific subclass it throws depends on the type of error that has occurred. Most of the JDBC method calls can result in several different types of errors, in response to which the JDBC driver throws a specific SQLException
subclass. Your client application can choose how to react to the error based on the specific exception that the JDBC driver threw.
Note
The specificSQLException
subclasses were introduced in the JDBC 4.0 standard. If your client application runs in a Java 5 JVM, it will use the older JDBC 3.0-compliant driver which lacks these subclasses. In that case, all errors throw a SQLException
.
The hierarchy of SQLException
subclasses is arranged to help your client application determine what actions it can take in response to an error condition. For example:
-
The JDBC driver throws
SQLTransientException
subclasses when the cause of the error may be a temporary condition, such as a timeout error (SQLTimeoutException
) or a connection issue (SQLTransientConnectionIssue
). Your client application can choose to retry the operation without making any sort of attempt to remedy the error, since it may not reoccur. -
The JDBC driver throws
SQLNonTransientException
subclasses when the client needs to take some action before it could retry the operation. For example, executing a statement with a SQL syntax error results in the JDBC driver throwing the aSQLSyntaxErrorException
(a subclass ofSQLNonTransientException
). Often, your client application just has to report these errors back to the user and have him or her resolve them. For example, if the user supplied your application with a SQL statement that triggered aSQLSyntaxErrorException
, it could prompt the user to fix the SQL error.
SeeSQLState mapping to Java exception classes for a list Java exceptions thrown by the JDBC driver.