aspose file tools*
The moose likes Oracle/OAS and the fly likes Need help from Oracle Gurus Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Products » Oracle/OAS
Bookmark "Need help from Oracle Gurus" Watch "Need help from Oracle Gurus" New topic
Author

Need help from Oracle Gurus

Frank Lin
Ranch Hand

Joined: Jan 26, 2001
Posts: 76
I posted this message on JDBC forum as well, not sure which forum Oracle Gurus visit more often.
Problem was found when a CMP entity bean deployed in Weblogic 5.1 with Oracle 8i as backend database, using connection pooling and Oracle thin driver. The finder method did not work while create()/remove() worked fine. The same bean was deployed with SYBASE ASE 12 before and it worked perfectly. Further research showed that the problem is rooting from the setString() method in prepareStatement. Here is the snippet in a test program.
The following code works fine where user_id is defined as int in the table.
String QueryStr = "select * from Users where user_id = ?";
stmt = con.prepareStatement(QueryStr);
stmt.setInt(1, 9999);
rs = stmt.executeQuery();
While the following does not return anything in the ResultSet, where user_name is defined as a varchar in the table
String QueryStr = "select * from Users where user_name = ?";

con = db.getConnection();
rs = stmt.executeQuery(QueryStr);
stmt.setString(1, "lin");
rs = stmt.executeQuery();
If I don't use the setString method, instead use

String QueryStr = "select * from Users where user_name = 'lin'";
It works fine too.
I believe that this has something to do with the setting on Oracle side, maybe with the character set setting. Can someone tell me how to fix it?
Thanks.
Frank Lin
Ranch Hand

Joined: Jan 26, 2001
Posts: 76
Problem went away after changing the column default to NOT NULL. Mystery stays why this could happen.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need help from Oracle Gurus