JDBC connection strings and drivers

jdbcWhen I have to configure a connection in Java to a database, I almost always have to go for help to the internet. I simply don't remember the exact form of connection strings and driver class names. Perhaps, it is because I deal with different database engines and I do it not often enough to remember all details. Interestingly, all information required in such task is spread over different web sites. That's why I decided to gather all of them in one place: connection string, driver class name and driver download URL for SQL Server, Oracle, MySQL, Firebird.

 

 

SQL Server

JDBC driver download page
https://www.microsoft.com/en-us/download/details.aspx?displaylang=en&id=11774

Driver class name
com.microsoft.sqlserver.jdbc.SQLServerDriver

Connection string examples
Database testDb is located on localhost on the default SQL Server service - jdbc:sqlserver://localhost;databaseName=testDb
Database testDb is located on localhost on the SQLDEV01 service - jdbc:sqlserver://localhost\SQLDEV01;databaseName=testDb
Database testDb is located on localhost, the SQL Server service is listening on port 1433 and authentication is done with the Windows Authentication method - jdbc:sqlserver://localhost:1433;databaseName=testDb;integratedSecurity=true
Database testDb is located on localhost, port 1433 and credentials are provided in the connection string (dba/dbaPass) -jdbc:sqlserver://localhost:1433;databaseName=testDb;user=dba;password=dbaPas

 

Oracle

JDBC driver download page
http://www.oracle.com/technetwork/database/features/jdbc/index-091264.html

Driver class name
oracle.jdbc.driver.OracleDriver

Connection string examples
Database with SID devdb is located on localhost, port 1521 -jdbc:oracle:thin:@//localhost:1521:devdb
Database accessible through a service name devsrv is located on localhost, port 1521 -jdbc:oracle:thin:@//localhost:1521/devsrv

 

MySQL

JDBC driver download page
https://dev.mysql.com/downloads/connector/j/

Driver class name
com.mysql.jdbc.Driver

Connection string examples
Database testDb is located on localhost accessible on port 3306 -jdbc:mysql://localhost:3306/testDb
Database testDb is located on localhost accessible on port 3306 and credentials are provided in the connection string (dba/dbaPass) -jdbc:mysql://localhost:3306/testDb?user=dba&password=dbaPass

Would you like to learn db performance? Enroll to my course on Udemy.

Promo code: PERF_OPT_0522

liquibase course promo

Firebird

JDBC driver download page
http://ibphoenix.com/download/connectivity/java

Driver class name
org.firebirdsql.jdbc.FBDriver

Connection string examples
Database in file c:/app/data/database.fdb on localhost in Windows environment: jdbc:firebirdsql://localhost/c:/app/data/database.fdb
Database in file /var/lib/firebird/2.5/data/database.fdb on 192.168.1.40 in Linux environment: jdbc:firebirdsql://192.168.1.40//var/lib/firebird/2.5/data/database.fdb

We use cookies

We use cookies on our website. Some of them are essential for the operation of the site, while others help us to improve this site and the user experience (tracking cookies). You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.