Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> java method setObject() problem in Oracle JDBC drivers
Hello all,
I'm trying unsuccessfully to use setObject() in a CallableStatement from
a Java application. After setting the statement with the following
command
CallableStatement stmt =
conn.prepareCall("begin :1 := get_default_users(:2,:3); end;") (where get_default_users is a PL/SLQ function accepting two int parameters), I try to set the statement's parameters as follows:
stmt.setObject(2,myValue,myType);
where myValue is a string containing the value, and myType is a java.sql.Types constant with the appropriate type for myValue. For example, in our case myValue may be "1" and myType may be Types.INTEGER. When I try this, I get the following Exception:
java.lang.ClassCastException: java.lang.String at
oracle.jdbc.driver.OraclePreparedStatement.setObject(OraclePreparedStatement.
java:780) at
oracle.jdbc.driver.OraclePreparedStatement.setObject(OraclePreparedStatement.
java:860) at Test2.main(Test2.java:18)
I have similar code on some Informix drivers, and it works, so I don't know if this is a driver problem or something I'm doing wrong. I'm using Oracle thin drivers with RDK 1.1.1 on an Oracle 8.0.4 database.
I could get this to work if I used stmt.setInt(), but in my implementation I don't know the type of the value I'm inserting ahead of time, and I'd have to build a huge case that would fit the appropriate setXXX with the value type.
Any suggestions or help will be greatly appreciated.
Thanks,
Adi.
Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Thu Oct 21 1999 - 11:45:08 CDT
![]() |
![]() |