• public class SQLException extends Exception
Exceptions that are thrown by JDBC
• 1. SQL Exception
• 2. SQLWarning
• 3. DataTruncation
• The SQL syntax error that are found in the user given query are reflected
by the SQLException.
• This exception is thrown by many of the java.sql package methods.
• The connectivity issues with the database and the coding errors such has
trying to access a closed object give rise to such exceptions.
• The details of SQL error or a null are returned by using the
getNetException() method of the SQLException object and the vendorspecific error codes are retrieved by using the getErrorCode() method of
the SQLException object.
public class SQLWarning extends SQLException
An exception that provides information on database access warnings.
Warnings are silently chained to the object whose method caused it to be
• Warnings may be retrieved from Connection, Statement,
and ResultSet objects. Trying to retrieve a warning on a connection after it
has been closed will cause an exception to be thrown. Similarly, trying to
retrieve a warning on a statement after it has been closed or on a result
set after it has been closed will cause an exception to be thrown. Note
that closing a statement also closes a result set that it might have
public class DataTruncationextends SQLWarning
An exception thrown as a DataTruncation exception (on writes) or
reported as a DataTruncation warning (on reads) when a data values is
unexpectedly truncated for reasons other than its having
• The SQLstate for a DataTruncation during read is 01004.
• The SQLstate for a DataTruncation during write is 22001.