I have to read the below SQL statement from one properties.
update scoreconfig set scorestatus=0 where scoreversion=props.getProperty("scoreversion");
And value for score version I’ve to take it from other properties file.
But, when I prepare a statement in java function as below:
final String query = strLine;
PreparedStatement ps=con.prepareStatement(query);
where query has
update scoreconfig set scorestatus=0 where scoreversion=props.getProperty("scoreversion");
But I get
Error: ORA-00911: invalid character
…when I do ps.execute();
I assume
propsis aPropertiesinstance or similar. If so, theprops.getProperty("scoreversion")part is meant to happen at the Java layer, not in the database. Instead:…or if scoreversion is an int, use this instead of the
setStringline:…etc., convert as appropriate.
Basically, when you use
prepareStatement, you use?where parameters should go, and then you usesetXyzon thePreparedStatementinstance to set those parameters. (Oddly, they start with1, not0.) Note that even when the parameter is a String, you don’t put quotes around it in the SQL you pass intoprepareStatement; that’s handled for you (along with properly escaping that string to prevent SQL injection, soPreparedStatementandsetXyzare your friends, you’ll get to know them well).