there is no dynamic way to decide how many ? are needed for each individual query. You have to decide at the time of the prepareStatement() the number of ? needed for your query. You can prepare a new statement for each query though, and append the number of ? needed for that query. You would do use it if you wanted all the benefits of PreparedStatement (such as special character handling) but would not have the all performance benefits as if you reuse the PreparedStatement
eg.
but you can't decide after you prepare the preparedStatement
I haven't taken a look at the jdk1.4 yet (and specifically
jdbc 3.0) but up to the jdk1.3.x it is not possible
Jamie