Forum Stats

  • 3,874,218 Users
  • 2,266,685 Discussions


ORA-12705: Cannot access NLS data files or invalid environment specified



  • 684610
    684610 Member Posts: 1
    I have the same issue but I am using a different environment, I am using Ubuntu. What I would like to do is to connect to Oracle database when compiling a maven application.

    My question is how do I set the NLS environment in Ubuntu?
  • 712267
    712267 Member Posts: 7
    HI All,

    I am getting the similar error. What i am trying to do is, connect to Oracle 9i database using the OCI driver.

    Following is my java code which is throwing this exception.

    import java.sql.CallableStatement;
    import java.sql.Connection;
    import java.sql.DriverManager;

    import java.sql.CallableStatement;
    import java.sql.Connection;
    import java.sql.DriverManager;


    * @author administrator
    public class OCITest {

    * @param args
    public static void main(String[] args) {

    Connection con = null;
    CallableStatement cstmt = null;

    String url = "jdbc:oracle:oci8:@GPSD1.IN.IBM.COM";
    String userName = "swbapps";
    String password = "swab";

    System.out.println("Registering Driver ...");
    DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());

    System.out.println("Creating Connection ...");
    con = DriverManager.getConnection(url, userName, password);


    } catch(Exception ex) {
    } finally {
    if(cstmt != null) try{cstmt.close();}catch(Exception _ex){}
    if(con != null) try{con.close();}catch(Exception _ex){}


    The exception stack trace is as belows:

    java.sql.SQLException: ORA-12705: Cannot access NLS data files or invalid environment specified

    at oracle.jdbc.driver.SQLStateMapping.newSQLException(
    at oracle.jdbc.driver.DatabaseError.newSQLException(
    at oracle.jdbc.driver.DatabaseError.throwSqlException(
    at oracle.jdbc.driver.T2CConnection.checkError(
    at oracle.jdbc.driver.T2CConnection.logon(
    at oracle.jdbc.driver.PhysicalConnection.<init>(
    at oracle.jdbc.driver.T2CConnection.<init>(
    at oracle.jdbc.driver.T2CDriverExtension.getConnection(
    at oracle.jdbc.driver.OracleDriver.connect(
    at java.sql.DriverManager.getConnection(Unknown Source)
    at java.sql.DriverManager.getConnection(Unknown Source)
    at OCITest.main(

    I am using WAS 7.0 and in my lib folder I have ojdbc6.jar. I have also set native library location to my oracle installation path where all the dll files are present.

    Can anyone please help me out in this? I am not sure where the SID GPSD1.IN.IBM.COM should be present.
  • chinty
    chinty Member Posts: 1

    Months ago, I had the same problem when I tried to connect my Java Application with an Oracle database (I live in Ecuador, and seems my country isn't recognized :(), but I could resolve it without changing the database settings or the cliente pc settings. Here is the code (Attention with the line Locale.setDefault(new Locale(”es”,”ES”)); <-- If you are working with English, you can change for Locale.setDefault(new Locale(”us”,”EN”));).

    you must import java.util.Locale

    public conection()


    Properties connAttr = new Properties();

    Properties props = new Properties();

    connAttr.put(”charSet”, “UTF-8″);

    Locale.setDefault(new Locale(”es”,”ES”));_

    DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
    catch (Exception exc)
    System.out.println(”We have encountered an error”+” : “+exc);

    I hope that this code can help you
  • 721004
    721004 Member Posts: 1
    I had the same problem on windows xp, and I just solved it:

    -check your oracle xe database settings by executing this in sqlplus: select userenv('LANGUAGE') from dual; (one of the above users offered this query, I checked and found my settings were ENGLISH_AMERICA.WE8MSWIN1252)

    -change your regional settings in control panel according to your database (I changed it to English (United States))

    -change NLS parameters in sql developer according to your database and regional settings (in sql developer tools/preferences/database/NLS Parameters, I selected english language, american teritory and pressed default values for the rest of the fields)

    -don't forget to restart your computer for this to take effect
  • 550205
    550205 Member Posts: 7
    Question: I an getting the error "Resolving ORA-12705: Cannot access NLS data files or invalid environment specified" when I change my NLS_LANG setting.

    The developers need to experiment with different character sets but when they issue export NLS_LANG and try to start SQLPLUS after that they get the ORA-12705 error.

    Answer: First, see my notes all about the ORA-12705 error.

    The ORA-12705 error is indeed controlled by NLS_LANG, and the ORA-12705 commonly happens when Oracle does an automatic "alter session" at login time and discovers an invalid NLS_LANG setting. The Oracle documentation notes are not very helpful:

    ORA-12705: "invalid or unknown NLS parameter value specified"

    Cause: There are two possible causes:

    - An attempt was made to issue an ALTER SESSION statement with an invalid NLS parameter or value.

    - The NLS_LANG environment variable contains an invalid language, territory, or character set.

    Action: Check the syntax of the ALTER SESSION command and the NLS parameter, correct the syntax and retry the statement, or specify correct values in the NLS_LANG environment variable.

    Oracle also says that the ORA-12705 can happen under these conditions and MetaLink has resolutions for these ORA-12705 conditions:

    1. ORA-12705 with incorrect NLS_LANG parameter
    2. ORA-12705 with incorrectly specified ORA_NLSx
    3. ORA-12705 from incorrect Oracle install or configuration
    4. ORA-12705 when using Special Character sets
    5. ORA-12705 when connecting with SQL*Net
    6. ORA-12705 during migrations
    7. ORA-12705 when connecting with SQL*Plus
    8. ORA-12705 when connecting with language pre-compilers
    9. ORA-12705 during Export/Import

    For ORA-12705 errors caused by invalid NLS_LANG settings, you need to verify that it is "unset" at the system-level:

    * Windows - The NLS_LANG must be unset in the Windows registry (re-named is best). Look for the NLS_LANG subkey in the registry at \HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE, and rename it.

    * Linux/UNIX - Here you simply issue the Linux command "unset NLS_LANG"

    Reference :
This discussion has been closed.