Friday, September 16, 2011

JDBC: Building the connection URL

This is on of the uber-random instances in which I am dealing with Java, JDBC, Websphere etc.

We needed to change the Java application to point to a new database.
After much effort we realised that the db connection string is located in an obscure file located here:
WEB-INF/classes/edujini.conf

The line(s) to change were:
database.connection.url=jdbc\:sqlserver\://<ip address>\:1433;databaseName\=<dbname>;user\=<username>;password\=
and
database.connection.password=<encrypted password string>

Looks simple enough, but not when you didn't know about the existence of the 2nd line and spent the whole day figuring out why there wasn't a need to pass in a password in the 1st line.
After realising that there is this 2nd line, there is another complexity in trying to figure out that the password was actually encrypted. (The system was commissioned very very long ago and no one remembered the password in the dev environment).

Thankfully poor encryption algo saved the day. After some random guessing, we managed to break the password and everything came to light.

Now back to the problem at hand. If I simply replace the sqlserver value with the database instance name, it doesn't work. After some poking around again, I realised that you would need to put in this value instead:
<ip address of server>\\instance name

Not fun at all.

No comments:

Post a Comment