SQLException can occur in both the driver and the database. When such an exception occurs, an object of type SQLException is passed to the catch clause.
The passed SQLException object has the following methods that can be used to retrieve additional information about the exception:
Methods | Description |
---|---|
getErrorCode( ) | Get the error number related to the exception. |
getMessage( ) | Get the error message of the JDBC driver handled by the driver, or get the Oracle error number and message of the database error. |
getSQLState( ) | Get the XOPEN SQLstate string. For JDBC driver errors, this method does not return any useful information. For database errors, a five-digit XOPEN SQLstate code is returned. This method can return null. |
getNextException( ) | Get the next Exception object in the exception chain. |
printStackTrace( ) | Print the current exception or throwable exception and trace it back to the standard error stream. |
printStackTrace(PrintStream s) | Print this throwable and its traceback to the print stream you specify.|
printStackTrace(PrintWriter w) | Print this throwable and trace it back to the print writer you specify. |
The above is the detailed content of What are the important methods of the SQLException class?. For more information, please follow other related articles on the PHP Chinese website!