473,386 Members | 1,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Oracle JDBC unicode parameter corrupted (DB insert proc)

dzenanz
45
Calling a stored procedure from Java with ojdbc 1.4 corrupts (converts to ¿) unicode characters that are not contained in DB's current charset.
Calling this proc from C# works as expected (all unicode characters are properly stored).
Expand|Select|Wrap|Line Numbers
  1. String driver = "oracle.jdbc.OracleDriver";
  2. Class.forName(driver);
  3. DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
  4. conn = DriverManager.getConnection(url, username, password);
  5. CallableStatement storedProc = conn.prepareCall("{call SMSC.p_smsu_campaign_insert(?,?,?,?,?,?)}");
  6.  
  7. String campaign="_šđčćž ò#±¦ţ!ę";
  8. storedProc.setString("Campaign_name", campaign); //<----problem here!
  9. //Campaign_name parameter in DB is nchar type (oracle's unicode type)
  10. /*set other parameters*/
  11. storedProc.execute();
Do you have any idea what is the cause?
Note: this is a simplification of my previous post
Apr 17 '08 #1
2 3526
dzenanz
45
If anyone comes by the same problem again, here is the solution:
Expand|Select|Wrap|Line Numbers
  1. storedProc.setString("Campaign_name", campaign);
  2. ((OraclePreparedStatement) storedProc).setFormOfUse(1, OraclePreparedStatement.FORM_NCHAR); //<---this makes the difference!
Apr 17 '08 #2
JosAH
11,448 Expert 8TB
If anyone comes by the same problem again, here is the solution:
Expand|Select|Wrap|Line Numbers
  1. storedProc.setString("Campaign_name", campaign);
  2. ((OraclePreparedStatement) storedProc).setFormOfUse(1, OraclePreparedStatement.FORM_NCHAR); //<---this makes the difference!
Not that I know another solution to your problem but I find the solution you
showed here very ugly: it ties your code to the Oracle database forever. Better
isolate that trickery-dickery to a small utility class that can be changed when
you have to migrate to another database.

kind regards,

Jos
Apr 17 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Rahul | last post by:
I am getting the following exception when accessing one of my tables. java.lang.reflect.InvocationTargetException: java.lang.ArrayIndexOutOfBoundsException at...
5
by: Kevin | last post by:
Dear all, Could you please advise where should I put the Oracle JDBC driver (classes12.zip or classes12.jar) under Windows XP with Tomcat 4.1? Do I need to set classpath? Many thanks. ...
1
by: mwang | last post by:
We just upgraded JDBC Thin driver from 9.0.1 to 9.2.0.3. After the upgrade we found the applications ran significantly slower. Our test showed the same app running up to 5 times slower with the new...
1
by: Kona | last post by:
Hello, I'm new with Oracle JDBC connection. Is it a way to crypt, hide the password string into a Oracle JDBC connection string ? The goal is to hide the password within script file. Thank's...
0
by: goyald | last post by:
Is their any support for data compression while using Oracle JDBC driver (8i or above) Thanks
1
by: stmfc | last post by:
hi, is there any place where i can download oracle jdbc connector for free other than official oracle site (in oracle.com sign-up procedure takes too much time )
0
by: Jim Kennedy | last post by:
ALL DDL does a commit. Hence Drop Table movies; issues a commit. True you don't issue a commit and the driver does not issue a commit, but the server does for all DDL. That is probably where...
1
by: Debabrata Jana | last post by:
Please go through the JAVA code below: class Main{ public Connection getConnection(){ Connection l_con = null; try { String hostname = "172.10.23.1:1527"; //Host...
0
by: yeshvanth | last post by:
hi i got windows 7 as os and orcle 11g installed in my pc and i set classpath for "ojdbc5.jar" file but still whenever i use "oracle.jdbc.OracleDriver" it shows the following exception in thread...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.