tags:

views:

573

answers:

1

I want to specify language for the JDBC connection before it is actually created.

For example if I specify wrong L/P credentials in

DriverManager.getConnection(url, user, password)

I need to get ORA error localized to the language I selected. I use Oracle thin client and setting NLS_LANG environmental variable did not work. :-(

+1  A: 

You may have some success using the DriverManager.getConnection(String url, Properties info) method.

From the documentation:

Parameters:

url - a database url of the form jdbc:subprotocol:subname

info - a list of arbitrary string tag/value pairs as connection arguments; normally at least a "user" and "password" property should be included

Perhaps something like this may work:

String url = ...;
Properties info = new Properties();
info.setProperty("user", ...);
info.setProperty("password", ...);
info.setProperty("NLS_LANG", ...);
DriverManager.getConnection(url, info);
Adam Paynter
I tried that but it does not work for me. :-(
sax