How can we handle SQL exception in Java?
SQL Exception is associated with a failure of a SQL statement. This exception can be handled like an ordinary exception in a catch block.
Example: catch(SQLException sqle)
{
// code to handle this exception
}
The statement
Import java.sql.SQLException;
Should be given in the beginning of the corresponding .java file.
The classes used to handle the SQL exceptions are:
- ClassNotFoundException
- SQLException