Working With Type 4 Driver
In this tutorial, we are going to discuss about Working With Type 4 Driver. Type 4 driver also known as Pure Java Driver OR Thin Driver.
Type-2 and Type-4 Drivers of Oracle having same Jar File, same Driver Class Name, but different JDBC URL’s.
Driver Class Name : oracle.jdbc.driver.OracleDriver oracle.jdbc.OracleDriver
JDBC URL : jdbc:oracle:thin:@localhost:1521:XE
import java.sql.*;
/**
*
* @author ashok.mariyala
*
*/
public class Type4DbConnectDemo {
public static void main(String[] args) throws Exception {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","scott","tiger");
Statement st = con.createStatement();
ResultSet rs = st.executeQuery("select * from emp");
while(rs.next()) {
System.out.println(rs.getInt(1)+"\t"+rs.getString(2)+"\t"+rs.getInt(3)+"\t"+rs.getString(4));
}
con.close();
}
}
That’s all about the Working With Type 4 Driver in JDBC. If you have any queries or feedback, please write us email at contact@waytoeasylearn.com. Enjoy learning, Enjoy Java.!!
Working With Type 4 Driver