Basically, I'm trying to figure out how to use a
PreparedStatement with an
oracle sequence.
Connection con = getConnectionFromSomewhere();
PreparedStatement ps = con.perpareStatment( " Insert into tableA (id, name) values (?,?);
ps.set???( 1, myOraclesequence.nextval); <--dunno how to do this line
ps.setString(1, "TFECW");
I tried setString(1, "myOraclesequence.nextval") but i get an sql exception
because id is a number type in oracle and i'm sending it as a string. Java obviously won't compile something like
setInt(1, myOraclesequence.nextval);
My search yeilded this
link
While the solution there makes sense, I looking for something that doesn't require a db change and all the forms, essays, and tps reports that go along with a db change.
Is there something I can wrap my sequence in?
Basically, we're trusting data from an outside system. Well, they are sending us bad data this causes an sql exception because the ' aren't escaped.
I know it'd take less than 2 seconds to add a method to escape the SQL characters, but i'm trying to avoid it. We have enough gum and duck tape holding this application together.
Thanks.
Felissa