Java JDBC: List of Drivers and URL for all databases

In this article, we will list down all drivers and URL formation for all leading databases

 

Q) How to get Connection object for interacting with Database ?

  • DriverManager class helps to get connection object using one of the overloaded static getConnection() methods i.e.;
    getConnection(String dbURL);
    
    getConnection(String dbURL, Properties props);
    
    getConnection(String dbURL, String username, 
    		String password);
    
  • Using connection, user can create SQL statement and then execute SQL queries against database

Q) How to load driver ?

  • Before getting connection object, appropriate driver needs to be loaded using either of the following methods,
    forName(“driverName”);
    
    registerDriver(appropriateDriverObject);
    
  • There are 3 ways to create connection objects from overloaded static getConnection() methods available in the DriverManager class and all 3 requires database URL
  • Therefore, we will look into driver class name and their corresponding database URL formation in tabular form,

 

Database, driver and URL with example :

 
Relational Database
 
 
Driver Name
(qualified class name)

 
 
Database URL & Example
 
MySQL com.mysql.jdbc.Driver jdbc:mysql://<server>
:<port>/<databaseName>

Eg: jdbc:mysql://localhost
:3306/myDBName

Oracle oracle.jdbc.driver.OracleDriver jdbc:oracle:thin:@<server>
:<port>:<databaseName>

Eg: jdbc:oracle:thin:@localhost
:1521:xe

IBM DB2 App com.ibm.db2.jdbc.app.DB2Driver jdbc:db2:<databaseName>

Eg: jdbc:db2:myDBName

IBM DB2 Net com.ibm.db2.jdbc.net.DB2Driver jdbc:db2//<server>
:<port>/<databasebName>

Eg: jdbc:db2://localhost:6789/myDBName

Sybase com.sybase.jdbc.SybDriver jdbc:sybase:Tds:<server>
:<port>/<databaseName>

Eg: jdbc:sybase:Tds:localhost
:4100/myDBName

Teradata com.teradata.jdbc.TeraDriver jdbc:teradata://<server>
/database=<databaseName>
,tmode=ANSI,charset=UTF8

Eg: jdbc:teradata://localhost
/database=myDBName
, tmode=ANSI, charset=UTF8

Microsoft SQL Server com.microsoft.sqlserver
.jdbc.SQLServerDriver
jdbc:sqlserver://<server>
:<port>;databaseName=<databaseName>

Eg: jdbc:sqlserver://localhost
:1433;databaseName=myDBName

Postgre org.postgresql.Driver jdbc:postgresql://<server>
:<port>/<databaseName>

Eg: jdbc:postgresql://localhost
:5432/myDBName

MS Access (JDBC-ODBC Bridge) sun.jdbc.odbc.JdbcOdbcDriver jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};
DBQ=<myDBName.mdb>;

Eg: jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};
DBQ=myDBName.mdb;

Above things are mandatory for establishing connection with corresponding databases before actually creating/executing any SQL queries

 

Read Also:

 

References:

 

Happy Coding !!
Happy Learning !!

Java JDBC: Core Components
Java JDBC: Driver Types