Reputation: 838
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
Upvotes: 3
Views: 9109
Reputation: 4659
This worked best for me, as stated in NLS_LANG setting for JDBC thin driver?
-Duser.language=en -Duser.region=US
Upvotes: 5
Reputation: 3499
As per documentation----
Providing Globalization Support
The basic Java Archive (JAR) files, ojdbc5.jar and ojdbc6.jar, contain all the necessary classes to provide complete globalization support for:
Oracle character sets for CHAR, VARCHAR, LONGVARCHAR, or CLOB data that is not being retrieved or inserted as a data member of an Oracle object or collection type.
CHAR or VARCHAR data members of object and collection for the character sets US7ASCII, WE8DEC, WE8ISO8859P1, WE8MSWIN1252, and UTF8.
To use any other character sets in CHAR or VARCHAR data members of objects or collections, you must include orai18n.jar in the CLASSPATH environment variable of your application.
Upvotes: 1
Reputation: 46948
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);
Upvotes: 1