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

Do not miss valuable content. You will receive a monthly summary email. You can unsubscribe anytime.

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

If you like what I do, consider buying me a coffee :)

Buy me a coffeeBuy me a coffee