?
Solved

java oracle DB error

Posted on 2006-04-07
8
Medium Priority
?
862 Views
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.

cheers
zolf
0
Comment
Question by:zolf
  • 4
  • 2
  • 2
8 Comments
 
LVL 10

Accepted Solution

by:
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:
LANGUAGE_TERRITORY.CHARACTERSET
(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
NLS 7-BIT/8-BIT CONVERSION
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
HKEY_LOCAL_MACHINE -> SOFTWARE -> ORACLE -> HOMEn
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:
0
 
LVL 10

Expert Comment

by:jagadeesh_motamarri
ID: 16406236
Did u have something like this in your code...

NLS_LANG=AMERICAN-AMERICA.UTF8


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

Author Comment

by:zolf
ID: 16406267

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

0
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

by:zolf
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
            Class.forName("oracle.jdbc.driver.OracleDriver");
            System.out.println("Driver loaded");
            System.out.println("java.version=" + System.getProperty("java.version"));

            //establish a connection
            Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@192.168.32.3:1521:orcl1","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')";
          

          System.out.println(sql);
        // Execute the insert statement
        sqlStatement.executeUpdate(sql);            
                        
            //close the connection
            conn.close();
            
            
            //Statement stmt = connection.createStatement();
   
       

      }
}
0
 
LVL 86

Assisted Solution

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

Author Comment

by:zolf
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.
0
 

Author Comment

by:zolf
ID: 16406675

does anyone know what is wrong in this code

else
{
String strCityEng = txtCityEng.getText();             
String strCityFar = txtCityFar.getText();
String strCityPrefix = txtCityPrefix.getText();
String sqlString = "Insert into City values(54,'"+strCityEng+"','"+strCityFar+"','"+strCityPrefix+"')";
System.out.println(sqlString);
                        
try
{
      String driverName = "oracle.jdbc.driver.OracleDriver";
                                                            Class.forName(driverName);

}catch(ClassNotFoundException e4)
{
      System.out.println("Driver not found Exception " +e4);
}
                        //System.exit(0);
try
{
                              
      conn = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:orcl"," "," ");

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

                        try
                        {
                              stmt.executeUpdate(sqlString);
                              
                        }catch(SQLException e3)
                        {
                                    System.out.println("Statement not created Exception "+e3);
                        }


                              txtCityEng.setText("");
                              txtCityFar.setText("");
                              txtCityPrefix.setText("");
                  }
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 16434604
:-)
0

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