JDBC (Java Database Connectivity) is an API that allows Java programs to access the database to read or modify data in databases.
Below given are various databases and their Type 4(thin) JDBC driver details
For each database I have given the driver name and the URL from where you can download the jdbc driver jar file.
Oracle
Driver name: oracle.jdbc.driver.OracleDriver
URL: http://www.oracle.com/technetwork/database/features/jdbc/index-091264.html
(Drivers for various Oracle versions including 8i, 9i,10g, 11g are available here)
Microsoft SQL Server
Driver name: com.microsoft.sqlserver.jdbc.SQLServerDriver
URL: http://www.microsoft.com/download/en/details.aspx?id=21599
( This driver can connect to SQL Server 2008 R2, SQL Server 2008, SQL Server 2005 and SQL Server 2000 versions )
Driver name: java com.ibm.db2.jcc.DB2Jcc
URL: http://www-01.ibm.com/support/docview.wss?uid=swg21363866
( DB2 Version 8.2 , DB2 Version 9.1, DB2 Version 9.5, DB2 Version 9.7 ,DB2 Version 9.8)
Driver name: org.postgresql.Driver
URL : http://jdbc.postgresql.org/download.html
(All versions upto postgreSQL 9.1)
MySQL
Driver name: com.mysql.jdbc.Driver
URL : http://dev.mysql.com/downloads/connector/j/
(Connector version Connector/J 5.1.19)
Once you have downloaded the driver and added it to the classpath of your java program, you can test the connection by a simple java program given below.
Let me know if you want to add JDBC driver information of any other relational database.
Below given are various databases and their Type 4(thin) JDBC driver details
For each database I have given the driver name and the URL from where you can download the jdbc driver jar file.
Oracle
Driver name: oracle.jdbc.driver.OracleDriver
URL: http://www.oracle.com/technetwork/database/features/jdbc/index-091264.html
(Drivers for various Oracle versions including 8i, 9i,10g, 11g are available here)
Microsoft SQL Server
Driver name: com.microsoft.sqlserver.jdbc.SQLServerDriver
URL: http://www.microsoft.com/download/en/details.aspx?id=21599
( This driver can connect to SQL Server 2008 R2, SQL Server 2008, SQL Server 2005 and SQL Server 2000 versions )
Driver name: java com.ibm.db2.jcc.DB2Jcc
URL: http://www-01.ibm.com/support/docview.wss?uid=swg21363866
( DB2 Version 8.2 , DB2 Version 9.1, DB2 Version 9.5, DB2 Version 9.7 ,DB2 Version 9.8)
Driver name: org.postgresql.Driver
URL : http://jdbc.postgresql.org/download.html
(All versions upto postgreSQL 9.1)
MySQL
Driver name: com.mysql.jdbc.Driver
URL : http://dev.mysql.com/downloads/connector/j/
(Connector version Connector/J 5.1.19)
Once you have downloaded the driver and added it to the classpath of your java program, you can test the connection by a simple java program given below.
package com.jdbctest; import java.sql.Connection; import java.sql.DriverManager; public class TestConnection { public static void main (String[] args) { Connection conn = null; String userName = "MyUsername"; String password = "MyPassword"; String url = "MyDatabaseURL"; String jdbcDriverName = "MyJDBCDriverName"; //Replace the username, password, URL and driver with appropriate values try{ Class.forName (jdbcDriverName); } catch(ClassNotFoundException e ) { System.out.println("Driver class "+ jdbcDriverName +" not found."); System.exit(1); } try{ conn = DriverManager.getConnection (url, userName, password); System.out.println ("Hurray!! Database connection established successfully."); } catch(Exception e) { System.out.println("An error occured while creating connection:" +e.getMessage() ); } finally { if (conn != null) { try { conn.close (); System.out.println ("Database connection terminated"); } catch (Exception e) { //Ignore this exception } } } } }
Let me know if you want to add JDBC driver information of any other relational database.
really awesome post it gives lot of information which is very helpful for me.keep sharing
ReplyDelete