Java doest run prepare statements with parameter

Posted by Zaiman Noris on Stack Overflow See other posts from Stack Overflow or by Zaiman Noris
Published on 2011-03-03T06:33:26Z Indexed on 2011/03/03 7:25 UTC
Read the original article Hit count: 173

Filed under:
|
|

If using PreparedStatement to query my table. Unfortunately, I have not been able to do so.

My code is as simple as this :-

PreparedStatement preparedStatement = connection.prepareStatement(
"Select favoritefood from favoritefoods where catname = ?");

preparedStatement.setString(1, "Cappuccino");                
ResultSet resultSet = preparedStatement.executeQuery();

Error thrown is java.sql.SQLException: ORA-00911: invalid character. As if it never run through the parameter given.

Thanks for your time. I've spend a day to debug this yet still unsuccessful.

As mention by Piyush, if I omit the semicolon at the end of statement, new error is thrown. java.sql.SQLException: ORA-00942: table or view does not exist. But I can assure you this table is indeed exist.

UPDATE

shoot. i edited the wrong sql. now it is successful. thx for your time.

© Stack Overflow or respective owner

Related posts about java

Related posts about sql