Successfully reported this slideshow.
Exceptions
java.sql.SQLException
• public class SQLException extends Exception
implements Iterable<Throwable>
• {
• }
Exceptions that are thrown by JDBC
• 1. SQL Exception
• 2. SQLWarning
• 3. DataTruncation
SQLException
• The SQL syntax error that are found in the user given query are reflected
by the SQLException.
• This excep...
SQLWarning
•
•
•
•
•

Import java.sql.SQLWarning;
public class SQLWarning extends SQLException
{
}
An exception that provi...
DataTruncation
•
•
•
•
•

java.sql.DataTruncation
public class DataTruncationextends SQLWarning
{
}
An exception thrown as...
Upcoming SlideShare
Loading in …5
×

Exceptions

384 views

Published on

http://rajjdbc.blogspot.in/

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Exceptions

  1. 1. Exceptions java.sql.SQLException
  2. 2. • public class SQLException extends Exception implements Iterable<Throwable> • { • }
  3. 3. Exceptions that are thrown by JDBC • 1. SQL Exception • 2. SQLWarning • 3. DataTruncation
  4. 4. SQLException • 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.
  5. 5. SQLWarning • • • • • Import java.sql.SQLWarning; 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 reported. • 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 produced.
  6. 6. DataTruncation • • • • • java.sql.DataTruncation 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 execeeded MaxFieldSize. • The SQLstate for a DataTruncation during read is 01004. • The SQLstate for a DataTruncation during write is 22001.

×