java oracle DB error

Posted on 2006-04-07
Medium Priority
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 error.now     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
  • 4
  • 2
  • 2
LVL 10

Accepted Solution

jagadeesh_motamarri earned 450 total points
ID: 16406233
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

ID: 16406236
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

ID: 16406267

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 16406320

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.*;
import java.io.*;

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

CEHJ earned 300 total points
ID: 16406355
Try the encoding that jagadeesh_motamarri mentioned. This Q is not really a Java Q of course

Author Comment

ID: 16406363

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

ID: 16406675

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

ID: 16434604

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses
Course of the Month15 days, 4 hours left to enroll

839 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