Professional Documents
Culture Documents
This driver converts JDBC method calls into native calls of the database API.
In order to interact with different database, this driver needs their local API, that’s
why data transfer is much more secure as compared to type-1 driver.
Network Protocol driver
This network protocol driver uses the middle software like an application server. The JDBC clients use the standard
network sockets to communicate with the middleware application server.
The middleware application server internally converts the JDBC calls to the vendor’s specific database protocol.
Thin driver
This driver interact directly with database. It does not require any native database library, that is why it is
also known as Thin Driver.
Loading the drivers:
Using Class.forName :
Class.forName(Sun.jdbc.odbc.JdbcOdbcDriver);
Class.forName(oracle.jdbc.driver.OracleDriver);
Using DriverManager.registerDriver :
public static void registerDriver (java.sql.Driver);
Obtaining the Connection
Main Protocol : Sub Protocol : Data Source
JDBC ODBC Oracle
DriverManager.getConnection(..);
//type 4 driver
Connection con=DriverManager.getConnection (
“jdbc : oracle : thin :@ localhost : 1521 : chandrashekhar”, “scott”, “tiger”);
// Execute query
ResultSet rs = stmt.executeQuery("select Name from table name");
// Process data
while(rs.next()) {
System.out.println("Artist Name: " + rs.getString("Name"));
}
// Clean up
rs.close();