File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Invalid character encountered Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Invalid character encountered" Watch "Invalid character encountered" New topic
Author

Invalid character encountered

Satej Koli
Greenhorn

Joined: Sep 05, 2012
Posts: 4
Hi All,

There is a scheduled batch job in my application which reads a text file and inserts/updates the processed data into some database tables. The batch job code is first invoked from a shell script which then calls a Jar which then does further job of calling database code to populate some tables.

This job was working fine till yesterday. However, it failed with an error 'Invalid character encountered' today. I observed that there is a special character ú in the text file. I then tried to replicate the issue on my machine. I have the java code setup for the job in Eclipse Helios. So for my local code setup, I just copied the text file to my machine then updated properties file to read the text file from my machine and executed the job. But the job did not throw any exception.

I also executed an update statement on my Toad to update a column with a string containing ú and it worked.

Please help me to find out why it failed as a scheduled batch job. Thanks in Advance
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40029
    
  28
Which machine are you using, which encoding, and where are you displaying that character?
Some versions of the Windows® terminal display £ as ú.
See if you can get the hex value of the char displayed, and you can check whether it is the same as you expected.
Satej Koli
Greenhorn

Joined: Sep 05, 2012
Posts: 4
I am not sure where to check the encoding. I am using Windows XP. I am not dispalying that character. It's there in the text file which I got from other team.


I want to replicate the issue on my machine. I just noticed that the shell script contains following lines:

CLASSPATH=$ORACLE_HOME/jdbc/lib/classes12.jar:$ORACLE_HOME/jdbc/lib/nls_charset12.jar:$CLASSPATH

Is this a reason for failure? How can I do this in Eclipse.

Thanks.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40029
    
  28
Don’t know.
If the ú was in the original file, there may be an error occurring on the other computer. If the two charsets are different, who knows what will go wrong.
Start by reading this while you are waiting, and ask whoever sent you the file what charset and encoding they were using.
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3611
    
  60

That line adds JDBC drivers from local Oracle installation into the classpath. It is somewhat strange, as it needlessly depends on the local installation of Oracle. It is much more common to ship the JDBC driver with the application.

Also, these files indicate the driver is pretty old. See our Oracle FAQ page to get more information about driver/database compatibility; there are also links to newer Oracle JDBC drivers.

In my opinion there are two possibilities for the difference:
  • Your machine uses different JDBC driver that the original machine: perhaps your drivers are newer and handle the character well.
  • The locale of your machine differs from the locale of the original machine: this could cause the file to be read using different encoding (assuming you don't specify an encoding when reading the file).

  • Satej Koli
    Greenhorn

    Joined: Sep 05, 2012
    Posts: 4
    Hi, the batch job is on a unix server. while my machine uses Windows xp. i will try to use the same jars used the job and run the code.
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Invalid character encountered