java oracle DB error

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.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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 .
zolfAuthor Commented:

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

Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

zolfAuthor Commented:

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();

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

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.
zolfAuthor Commented:

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);

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.