JDBC Type1 drivers

Can we use Type1 driver in web Application?

If possible give me a simple example for all driver types?

Questions by jagadesh05

Showing Answers 1 - 27 of 27 Answers

sampra

  • Feb 13th, 2008
 

Java Test


/*create table student
(
sid number(5),
sname char(15),
email char(15),
phone number(12)
); */
import java.sql.*;
class Test
{
public static void main(String as[])
{
try{
int sid=Integer.parseInt(as[0]);
String sname=as[1];
String email=as[2];
long phone=Long.parseLong(as[3]);
//step 1-load the class
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//step 2-establish the connection
Connection con=DriverManager.getConnection("jdbc:odbc:studentDSN","scott","tiger");
//step 3 create the statment
Statement st=con.createStatement();
//step 4 prepare sql queary and execute
String sql="insert into student values("+sid+",'"+sname+"','"+email+"',"+phone+")";
int x=st.executeUpdate(sql);
//step 5..process result
if(x==1)
{
System.out.println("Inserted...");
}
else
{


System.out.println("Not.Inserted");
}
//step 6-clean up
st.close();
con.close();
}catch(Exception e)
{
e.printStackTrace();
}


}
}

  Was this answer useful?  Yes

There are four types of JDBC drivers, Type1 driver is not purely java driver, here we can uploaded so many databse libraries ( these are the middleware softwares).So better to use type-4 driver (also called Oracle thin driver )

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions