how can i know what type of drivers are used..type1 type2 type3 type3 type 4 ..some guys in my class do that..by just looking at these two statements...help me ..;)

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");	
	   	conn = DriverManager.getConnection("jdbc:odbc:bike","scott","tiger");

Recommended Answers

All 3 Replies

depends by implementations od Java version in Java6 is JDBC v4,

something about that you can find on google

Hi....

Of course, there are 4 types of JDBC drivers types.These are...
Type1 : JDBC-ODBC Bridge plus ODBC driver (use window's built-in ODBC driver)
Type2 : Native-API partly Java driver (follows two-tier approach)
Type3 : JDBC-Net pure Java driver (follows three-tier approach)
Type4 : Native-protocol pure Java driver (fastest in 4 JDBC drivers types)

The most widely used drivers are Type1 and Type4 while Type2 and Type3 are not. However, Type4 needs different driver for each kind of database. For example, if you use Oracle database, you will need Oracle Driver. Type4 is portable but Type1 is not. In general, We can know what type of drivers are used by looking at driver loading statement and connection establishing statement .......

if you see the following 2 statements, you can know it is Type1 ......
- Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); // load the driver
- DriverManager.getConnection("jdbc:odbc:connectionname","username","password"); // Establish connection

if you see the following 2 statements, you can know it is Type4 ......
for SQLServer
===========
- Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
- DriverManager.getConnection("jdbc:sqlserver://machinename:1433;databaseName=Guru","username","password");

***** Note : need to add sqljdbc.jar into your java project *************
(or)
for Oracle
===========
- Class.forName("oracle.jdbc.driver.OracleDriver");
- DriverManager.getConnection("jdbc:oracle:thin: @localhost:1521: XE","username","password");
***** Note : need to add ojdbc14.jar into your java project ***************


I hope to be more power to you ............ best wishes :):):)

il recommend u to use type 4, for mySql db:

Class.forName("com.mysql.jdbc.Driver");					
                        Connection con=DriverManager.getConnection("jdbc:mysql://localhost:3306/bike","scott","tiger");

you can downloads wamp server to manage yur db, then configure mySql connector, check
http://www.mysql.com/products/connector/

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.