Jonathan Myers
Jonathan Myers

Reputation: 930

Reverse Engineer JDBC Oracle Connection String

Through my research, I wasn't able to find a duplicate of this question (a similar format wasn't include in any of these answers), but please mark it as such if it already exists.

I have the following JDBC connection string to connect to an Oracle database that I am trying to reverse engineer to connect elsewhere, but I don't know which components are server and which are database.

jdbc:oracle:thin:@word1://word2:port/word3,cn=word4,dc=word5,dc=word6

This was used to connect as part of a Sqoop job. The username and password are provided separately, so I don't believe any of these components are username or password. Could someone help me map these words and what their use case is?

Are any of these the database?

Upvotes: 0

Views: 1241

Answers (1)

Stephen C
Stephen C

Reputation: 719426

To reverse engineer this URL you start with @word1.

According to the Oracle documentation (see reference below), the part of the URL following the jdbc:oracle:thin: is the data source. There are a variety of different data source types, and the syntax of the next first component (including the @ if present) will determine the type. The documentation lists the following data source types:

  • Oracle Net connection descriptor - @(...)
  • Thin-style service name - name@
  • LDAP syntax - @ldap
  • Bequeath syntax - oci:path/@
  • TMSNames alias - @name

If there was no more context, you just read the documentation to decode the rest of the URL, per the data source type.

But you have revealed that there are cn and dc parameters in the URL. That makes it 99.9% likely that this is actually an @ldap data source.

The structure of an JDBC URL with an LDAP data source is:

jdbc:oracle:thin:@ldap://<host>:<port>/<name>,<ldap context param>...

where <host> and <port> are for an LDAP service, and the ldap context parameters are a list of name=value pairs which should include cn=OracleContext.

This tells the JDBC driver to lookup <name> in the LDAP server with the given context, and then use the associated information to establish the database connection. I couldn't find a definitive reference for what <name> actually is. The Oracle documentation just gives an example.

The best I could find is this:

Database Service Name: The database service name tells the driver what database to connect to. For example, if the database is named "dmart", dmart should be entered as the database service name.

(Source: https://razorsql.com/articles/oracle_ldap_jdbc_connect.html)

The "@ldap" can replaced by "ldaps:", which means LDAP over SSL.

References:

Upvotes: 4

Related Questions