Wednesday, 15 February 2012

How can you load the drivers in JDBC? | Java JDBC


Loading the driver or drivers you want to use is very simple and involves just one line of code. If, for example, you want to use the JDBC-ODBC Bridge driver, the following code will load it:
Eg.
Class.forName(”sun.jdbc.odbc.JdbcOdbcDriver”);
 Your driver documentation will give you the class name to use. For instance, if the class name is jdbc.DriverXYZ , you would load the driver with the following line of code:
E.g.
Class.forName(”jdbc.DriverXYZ”);

What is Driver Manager? | Java JDBC


DriverManager is a class in java.sql package. It is the basic service for managing a set of JDBC drivers.

What are the steps involved in establishing a connection using JDBC in JAVA? | Java JDBC


This involves two steps:
(1) loading the driver and
(2) making the connection.

What are the steps required to execute a query in JDBC? | Java JDBC


First we need to create an instance of a JDBC driver or load JDBC drivers, then we need to register this driver with DriverManager class. Then we can open a connection. By using this connection , we can create a statement object and this object will help us to execute the query.

What is JDBC Driver? | Java JDBC


The JDBC Driver provides vendor-specific implementations of the abstract classes provided by the JDBC API. This driver is used to connect to the database.

What are the flow statements of JDBC? | Java JDBC

A URL string
  1. getConnection
  2. DriverManager
  3. Driver
  4. Connection
  5. Statement
  6. executeQuery
  7. ResultSet. 

What packages are used by JDBC? | Java JDBC


There are 8 packages: java.sql.Driver, Connection,Statement, PreparedStatement, CallableStatement, ResultSet, ResultSetMetaData, DatabaseMetaData.