jQuery in Action, 3rd edition
The moose likes JDBC and Relational Databases and the fly likes preparedStatement and setxxx(1, myxxx); Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "preparedStatement and setxxx(1, myxxx);" Watch "preparedStatement and setxxx(1, myxxx);" New topic

preparedStatement and setxxx(1, myxxx);

Heath Lilley
Ranch Hand

Joined: Jan 09, 2001
Posts: 72
I am having trouble setting a bind variable to a (oracle 8) 2 digit number.

(The real query is rather large but it does work with '07' hard coded in place of the ?.)
Now according to the db myMonth is a NUMBER(2) type.
I tried the following:

but I get an Invalid number exception from the oracle drivers.
What do i need to call to bind a 2 digit number in a prepaired statement other than raw string concat'n?

[This message has been edited by Heath Lilley (edited January 16, 2001).]
Peter Tran

Joined: Jan 02, 2001
Posts: 783
Try setInt().
If that doesn't work, then you can try this technique.
1. Get a database connection.
2. Get the metadata object.
3. Execute a getColumns() on that table.
4. Find the correct column name and get its column type from the result set.
5. Using the column type as the type for your setXXX() statement.
[This message has been edited by Peter Tran (edited January 16, 2001).]
I agree. Here's the link: http://aspose.com/file-tools
subject: preparedStatement and setxxx(1, myxxx);
It's not a secret anymore!