Skip to main content

JDBC Drivers for relational databases

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 jdbc driver
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)


sqlserver jdbc driver




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 )


ibm db2 jdbc driver  IBM DB2


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)


postgresql jdbc driverPostgreSQL 


Driver name: org.postgresql.Driver

URL :  http://jdbc.postgresql.org/download.html
(All versions upto postgreSQL 9.1)


my sql jdbc driver




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.

Comments

  1. really awesome post it gives lot of information which is very helpful for me.keep sharing

    ReplyDelete

Post a Comment

Have some feedback, comment or question ?
Post it here in comments section.

Popular posts from this blog

Five most useful spring modules

  Java Spring framework is one of the popular java frameworks. A thread on 5 commonly used spring modules 1. Spring Boot and Spring MVC These modules makes it easy and quick to create stand-alone, production-grade Spring based Applications that you can "just run". Example Use:- A RESTful service with self-container server. 2. Spring Batch This module is used to build batch applications that need to recurrently process large volumes of data. Features: Chunk based processing, retry, skip Example Use:- Everyday, read data of daily trades from database and update the credit on customer's accounts. 3.Spring Data Provides a spring based programming model for accessing data. This module has very powerful features and supports wide range of databases. Example Use:- Read, Write data from PostgreSQL for your application. 4.Spring Cloud Provides tools for developers to quickly build some of the common patterns of distributed systems. Libraries for Service registration and discovery,...

Five important aspects of microservices

  5 important aspects/components of microservices architecture 1. Microservices - Services that are built small enough so that their entire lifecycle can be owned and managed by a small team. 2. Service Discovery - A mechanism of how microservices can locate each other over network.  Example : if Microservice A wants to call microservice B:  It will use service discovery mechanism to fetch IP address and port of B and then call B. Implementations : ZooKeeper, Consul, etcd, Eureka 3. External configuration - Enable services to run on various environments without a code modification inside the service. Enable different configuration values for those services for different environments.  Dynamically change configurations without changing application code or restart/redeploy application. Example - DB credentials and other details, application properties, environment variables for Dev, QA and Prod env. Implementations : Consul, Spring cloud (enables various datastores ...

More about Me

You can find more about me on my linkedIn profile  https://www.linkedin.com/in/amolrlimaye/   I have written a blog series on microservices which you can read here  https://medium.com/@amol.limaye   My open source contributions are less, but you can see my github activity here  https://github.com/amollimaye