what are the Different types of exceptions in JDBC?



what are the Different types of exceptions in JDBC?..

Answer / venu gopal.c t.c.s

Exceptions in JDBC are usually of two types:

Exceptions occurring in the JDBC driver

Exceptions occurring in the Oracle 8i database itself

Just as PL/SQL provides for an implicit or explicit RAISE
statement for an exception, Oracle JDBC programs have a
throw statement that is used to inform that JDBC calls
throw the SQL exceptions. This is shown below.

throws SQLException
This creates instances of the class java.sql.SQLException
or a subclass of it.

And, like in PL/SQL, SQL exceptions in JDBC have to be
handled explicitly. Similar to PL/SQL exception handling
sections, Java provides a try..catch section that can
handle all exceptions including SQL exceptions. Handling an
exception can basically include retrieving the error code,
error text, the SQL state, and/or printing the error stack
trace. The SQLException class provides methods for
obtaining all of this information in case of error
conditions.

Is This Answer Correct ?    9 Yes 6 No

Post New Answer

More JDBC Interview Questions

How can I manage special characters when I execute an insert query?

0 Answers  


What does adapter class provide?

0 Answers  


java.lang.ClassNotFoundException:oracle.jdbc.driver.OracleDr iver? I get this error at run time.I used oracle10G. I set CLASS PATH:C:\oraclexe\app\oracle\product\10.2.0 \server\jdbc\lib\ojdbc14.jar; I write JDBC PROGRAM like import java.sql.*; class Example { public static void main(String args[]) { try { Class.forName ("oracle.jdbc.driver.OracleDriver"); System.out.println("Driver Loaded"); Connection con=DriverManager.getConnection ("jdbc:oracle:thin:@localhost:1521:xe","system","salmas"); System.out.println("Driver Connected"); Statement st=con.createStatement(); ResultSet rs=st.executeQuery("select * from emp"); while(rs.next()) { System.out.println(rs.getInt(1)); System.out.println(rs.getString(2)); System.out.println(rs.getString(3)); } st.close(); con.close(); } catch(Exception e) { System.out.println(e); } finally { System.out.println("it's finally block executed"); } } }

6 Answers   CTS,


How do java applications access the database using jdbc?

0 Answers  


How do I insert/update records with some of the columns having NULL value?

0 Answers  






How do I receive a ResultSet from a stored procedure?

0 Answers  


Explain the difference between rowset vs. Resultset in jdbc?

0 Answers  


What are the higher level apis under development on top of jdbc currently?

0 Answers  


Why “no suitable driver” error occurs?

0 Answers  


What is statement and resultset in jdbc?

0 Answers  


Does jdbc use odbc?

0 Answers  


Why would you use setautocommit(false) in jdbc?

0 Answers  


Categories