Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

setting parameter value for preparedstatement dynamically

Status
Not open for further replies.

lowbk

Technical User
Nov 26, 2001
162
SG
suppose I've a preparedstatement that looks like this:

select name from personeltable where id=? and age<?

then I've
int idvalue=123
int agevalue=20
I'll then use setInt(1, idvalue) and setInt(2, agevalue)

my question is how to modify it such that it will work even if the preparedstatment is

select name from personeltable where age<? and id=?

ie how to know the parameterindex for id and age?
is there an existing api or do i need to write another method?
 
suppose i extend the question for SQL like

int startage=20
int endage=50
int id=100

select name from personeltable where age<? and age>? and id=?

how to know which parameterindex is for startage, which is for endage?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top