Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> JDBC string binding problem
I am getting a "Character set mismatch error" when trying to insert a string
into a nvarchar column on an oracle database. When inserting a literal
string, the operation works, but when string binding is used, the above
error is returned. The examples below illustrate this.
Anyone got any ideas?
Chris.
try {
strSQL = "select achar2 from ahm where achar1 = 'achar1 row 2'";
Statement sstmt = con.createStatement();
result = sstmt.executeQuery(strSQL);
while (result.next()) {
data = result.getString(1);
MyOutput("SELECT 1: DATA FETCHED: partnum = <" + data + ">");
}
}
catch (Exception e) {
MyOutput(e.getMessage());
System.exit(1);
}
Above fails with the following error: ORA-12704: character set mismatch
try {
strSQL = "select achar2 from ahm where achar1 = N'achar1 row 2'";
Statement sstmt = con.createStatement();
result = sstmt.executeQuery(strSQL);
while (result.next()) {
data = result.getString(1);
MyOutput("SELECT 1: DATA FETCHED: partnum = <" + data + ">");
}
}
catch (Exception e) {
MyOutput(e.getMessage());
System.exit(1);
}
Above works:
Received on Fri Nov 09 2001 - 10:36:31 CST