JDBC Connection strings for Oracle (thin driver)

This is a subject that I am often asked about by developers and support teams changing  application configuration details: What is the correct format of JDBC connection strings for the thin driver?

Oracle’s JDBC Thin driver uses Java sockets to connect directly to Oracle. It provides its own TCP/IP version of Oracle’s SQL*Net protocol. Because it is 100% Java, this driver is platform independent and can also run from a Web Browser (applets).

Old syntax, supporting instance (SID) names only::

jdbc:oracle:thin:@HOST:PORT:SID

New syntax, supporting both SID and SERVICE names:

jdbc:oracle:thin:@//HOST:PORT/SERVICE

There are also some drivers that support a URL syntax which allow to put Oracle user id and password in URL.

jdbc:oracle:thin:[USER/PASSWORD]@HOST:PORT:SID
jdbc:oracle:thin:[USER/PASSWORD]@//HOST:PORT/SERVICE

Finally, you can also give a tnsnames.ora entry-like in the string:

jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCPS)(HOST=<host>)(PORT=<port>))(CONNECT_DATA=(SERVICE_NAME=<service>)))

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at WordPress.com.

Up ↑

%d bloggers like this: