java oracle DB error

Posted on 2006-04-07
Last Modified: 2008-01-09
hello there,

i am working with java and oracle 10g database.first i did a simple test to connect to the database with java and also quered the DB without     when i take values from the user to save in the DB i get an error saying
Connection not done Exception java.sql.SQLException: ORA-00604: error occurred at recursive SQL level 1
ORA-12705: Cannot access NLS data files or invalid environment specified.

Question by:zolf
    LVL 10

    Accepted Solution

    Check out this....

    ORA-12705 "invalid or unknown NLS parameter value specified" usually means, we cannot interpret the NLS information our Client (eg: SQL*Plus) is receiving. This is mostly a configuration issue either in your environment or because we cannot interpret the NLS information we receive from the Server (eg: because of version missmatches between client and server). For an explanation of the error, see  OERR: ORA 12705 "invalid or unknown NLS parameter value specified" As most issues are as a result of the incorrect setting of NLS_LANG and/or ORA_NLSx parameters, they will be discussed in detail in the first two sections, other sections will refer to these two sections and will contain additional information whenever necessary. Contents: 1. ORA-12705 with incorrectly specified NLS_LANG 2. ORA-12705 with incorrectly specified ORA_NLSx 3. ORA-12705 due to Installation Issues 4. ORA-12705 when using Special Charactersets 5. ORA-12705 when connecting via SQL*Net 6. ORA-12705 during Migration 7. ORA-12705 when connecting with SVRMGRL and SQLPLUS 8. ORA-12705 when connecting with Precompiler Aplications 9. ORA-12705 during Export/Import
    1 ORA-12705 with incorrectly specified NLS_LANG 1.1 The NLS_LANG variable defines the client NLS settings.
    It is either defined as an environment variable (UNIX), in the Registry and/or environment (PC with Windows NT / NT 2000), in the ORACLE.INI for 16 bit applications (NT/95 or Windows 3.11),CONFIG.ORA file in the $ORACLE_HOME\NLM directory ( NetWare) or as a logical on OpenVMS.
    1.2 Format of NLS_LANG:
    (For an explanation of the different parts: LANGUAGE, TERRITORY, CHARACTERSET, check the  NLS Frequently Asked Questions and NLS_LANG Explained )
    1.3 What to consider when setting NLS_LANG:
    a) The variable needs to be in Uppercase on Unix Systems.
    b) If there is any mistake in the value setting of this variable (eg: a spelling mistake), you may encounter the ORA-12705. For a list of valid languages, territories and character sets the relevant National Language Support Guide for your version should be consulted.
    c) Completely unsetting the NLS_LANG will use the default value, that is AMERICAN_AMERICA.US7ASCII. This should always fix the ORA-12705, however may give unexpected results, because we are only dealing correctly with characters that can be represented completely with 7 bits. As soon as special characters (usually stored using the 8th bit) are used, this will result in conversion problems.
    For a discussion about 7bit/8bit conversions check
    d) On NT: if there are several Oracle_HOMEs on the machine you need to make sure, that you verify in the settings in the correct ORACLE_HOME. On how to determine the correct Oracle_Home, see  "How To Identify Which Registry Hive Is Used By A Specific Oracle Executable". Once the correct ORACLE_HOME has been determined, open the registry and verify the NLS_LANG entry in the special path. See also 1.4a)
    e) On NT: if you set NLS_LANG as an environment variable this will take precedence over the value set in the Registry. In most cases this is not preferable, so you may unset this variable. For further information on how to do this see 1.4a)
    f) On Unix: depending on the shell, you have to export the environment variable to make it visible to the subprocesses. Usually, it makes sense to set NLS_LANG in your specific Login-Script. See also 1.4b) on how to set the environment variable in different shells. 1.4 To check/set the values on different OS Systems:
    a) windows NT /2000/2003
    When there are several Oracle Installations (eg: Oracle Developer and Oracle Server Enterprise Edition) on your machine, then check which HOMEn value is being used. The entry in the Oracle.Key-File, which can be found in the $ORACLE_HOME\bin directory will point you to the correct entry in the Registry. See also 1.3d)
    Once you have determined the value for the HOMEn, open the registry with the registry editor (eg: regedit), then go to
    HOMEn, is the value you took out of the Oracle.Key-File (eg: HOME2)
    The next time you startup your application, the new value should be taken. If you have an open DOS-Box, the box has to be closed and reopened in order to get the new registry value.
    To check if you have set an environment variable click on the START button, the choose SETTINGS -> CONTROL PANEL -> SYSTEM ->
    Depending on your version goto:
    Win2000: Advanced -> Environment Variables
    WinNT: Environment
    For the correct setting of the parameter please see: The correct NLS_LANG in a Windows Environment
    b) Unix
    On how to verify/set environment variables on Unix, see  How to Set Unix Environment Variables
    This is also valid for NLS_LANG.
    c) VMS
     VMS: How to Research Oracle-Related Logicals on OpenVMS
    Gives you an overview on how to set/verify Logicals on OpenVMS. The same is true for NLS_LANG.
    1.5 Related issues
    You may also see the ORA-12705, when some other NLS-related environment variables are not set correctly.
    See: ORA-12705 when changing NLS_NUMERIC_CHARACTERS value
    2 ORA-12705 with incorrectly specified ORA_NLSxx
    2.1 The ORA_NLSxx variables point to the actual location of the NLS Data files.
    2.2 Format of ORA_NLSxx
    Prior to starting the database, to allow for non-standard configurations the actual location of the NLS Data files is specified by the ORA_NLSxx environment variable, where xx depends on theNLSRTL version number. If the variable is not defined, the default value of $ORACLE_HOME/ocommon/nls/admin/data, or a Windows equivalent is used. If the variable is defined, the default location is not searched anymore. Thus the variable must not have a bogus value.
    Depending on the Database Version a different ORA_NLSxx variable is needed:
    LVL 10

    Expert Comment

    Did u have something like this in your code...


    It should be NLS_LANG=AMERICAN_AMERICA.UTF8 (replace - with _ )...this is wat is a common mistake .

    Author Comment


    i am using AMERICAN_AMERICA.AR8MSWIN1256 because i have to insert persian character


    Author Comment


    using this simple test it inserts in the oracle DB without error.but when i let users enter data i get that error

    import java.sql.*;

    public class SimpleInsertJDBC
          public static void main(String[] args) throws SQLException,ClassNotFoundException
                // Load the JDBC Driver
                System.out.println("Driver loaded");
                System.out.println("java.version=" + System.getProperty("java.version"));

                //establish a connection
                Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@","dsl","dsl");
                System.out.println("Database connected");
                //create a statement
                Statement sqlStatement= conn.createStatement();
                // Prepare a statement to insert a record
            String sql = "INSERT INTO City VALUES(20,'eeewi','sadf','0351')";

            // Execute the insert statement
                //close the connection
                //Statement stmt = connection.createStatement();

    LVL 86

    Assisted Solution

    Try the encoding that jagadeesh_motamarri mentioned. This Q is not really a Java Q of course

    Author Comment


    that does not work what jagadeesh mentioned.

    i thought may be someone might have come across this error in java because i asked the question here.

    Author Comment


    does anyone know what is wrong in this code

    String strCityEng = txtCityEng.getText();             
    String strCityFar = txtCityFar.getText();
    String strCityPrefix = txtCityPrefix.getText();
    String sqlString = "Insert into City values(54,'"+strCityEng+"','"+strCityFar+"','"+strCityPrefix+"')";
          String driverName = "oracle.jdbc.driver.OracleDriver";

    }catch(ClassNotFoundException e4)
          System.out.println("Driver not found Exception " +e4);
          conn = DriverManager.getConnection("jdbc:oracle:thin:@"," "," ");

                            }catch(SQLException e1)
                                  System.out.println("Connection not done Exception " +e1);
                                  stmt = conn.createStatement();
                            }catch(SQLException e2)
                                       System.out.println("Statement not created Exception "+e2);

                            }catch(SQLException e3)
                                        System.out.println("Statement not created Exception "+e3);

    LVL 86

    Expert Comment


    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
    Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
    This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
    This video teaches viewers about errors in exception handling.

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now