Working With Type 1 Driver

Working With Type 1 Driver

In this tutorial, we are going to discuss about Working With Type 1 Driver. Type 1 Driver also known as JDBC ODBC Bridge Driver.

1 1

Type-1 Driver is available as the Part of JDK and hence we are not required to set any Class Path explicitly.

Driver Class Name : sun.jdbc.odbc.JdbcOdbcDriver
JDBC URL : jdbc:odbc:demodsn
username : scott
password : tiger
query : select * from emp;

Note

We should create emp table in the Database and insert some sample Data.

create table emp(eno number, ename varchar2(20), sal number(7,2),Address varchar2(50));
insert into emp values(1,'Ashok',50000,'Bhimavaram');
insert into emp values(2,'Vinod',120000,'Banglore');
insert into emp values(3,'Murty',75000,'Hyderabad'); 
import java.sql.*;
/**
 * 
 * @author ashok.mariyala
 *
 */
public class Type1DbConnectDemo { 
   public static void main(String[] args) throws Exception { 
      Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 
      Connection con=DriverManager.getConnection("jdbc:odbc:demodsn","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();
   }
}

Note

  • Type-1 Driver is available until 1.7 Version only.
  • From 1.8 Version on wards, the above Program won’t work.

That’s all about the Working With Type 1 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 1 Driver
Scroll to top