Java Database Connectivity Question and Answers

5. What are the different types of exceptions in JDBC?
 
  • batchUpdate Exception
  • Data Truncation
  • SQL Exception
  • SQL Warning
 
Your Name Your Email-ID
Your Answer
6. What are the steps for connecting to the database using JDBC?
  Using DriverManager:
  • Load the driver class using class.forName(driverclass) and Class.forName() loads the driver class and passes the control to DriverManager class.
  • DriverManager.getConnection() creates the connection to the database.
Using DataSource:
  • DataSource is used instead of DriverManager in Distributed Environment with the help of JNDI.
  • Use JNDI to lookup the DataSource from Naming service server.
  • DataSource.getConnection method will return Connection object to the database.
 
Your Name Your Email-ID
Your Answer
7. Briefly tell about the JDBC Architecture?
  The JDBC Architecture consists of two layers
  • The JDBC API
  • The JDBC Driver API
  • The JDBC API provides the applications JDBC Manager connection.
  • The JDBC Driver API supports the JDBC Manager to Driver Connection.
  • The JDBC driver manager authenticate that the correct driver has been used to access each data source.
  • The JDBC Driver API interacts with a driver manager, database specific driver for providing transparent connectivity for the heterogeneous databases.
  • The driver manager supports multiple concurrent drivers connected to the multiple heterogeneous databases.
 
Your Name Your Email-ID
Your Answer
8. What are the two major components of JDBC?
  One implementation interface fir database manufacturers, the other implementation interface for application and applet writers.
 
Your Name Your Email-ID
Your Answer
1234 Page 2 of 4