Dave Tolls wrote:Well, I used 'name' since I was guessing you might be sending the subject name (which I would assume was unique).
You could always send a subject id. That's up to you.
For the IN, the most secure way is to build the list of '?' placeholders and the do a load of setString (or setInt if using ids) on the PreparedStatement.
The initial answer on this SO thread is the usual way to build up the IN, using String.join and Collections.nCopies...it's a lot easier than it used to be!
Tim Moores wrote:The only method that sets "subj" -which is what the setSubject returns- is "setSubj" - is that ever called? It's hugely confusing to have both setSubj and setSubject methods - you should have only one method, and that should set the value (like setSubj does). I don't see why it needs to return the value it has just set - the calling code already knows which value it has.
Also, class names in Java start with uppercase letters - the class should be called Tutor, not tutor.
nulljava.sql.SQLException: No value specified for parameter 10
Tim Moores wrote:Please explain what "it doesn't work" means - in detail.
Also, the setSubject method doesn't do anything. Surely it should set a value?
Tim Moores wrote:
// m4.setSubject(subject); //setSubject() returned null
What kind of object is m4? You posted an excerpt of a class that does not have a setSubject method (or a setSubjectNames method, for that matter), so we can't say anything.
Tim Moores wrote:What specific problem are you facing with this code? What does or does not work according to your expectations?
Knute Snortum wrote:Do you really mean "amp&" and not "&"?
Tim Holloway wrote:
Knute Snortum wrote:The &s have turned back into just &.
Note for the confused: The JavaRanch message display system also evaluates the '&' entity, so make sure when you type or copy an example to preview the output. If it's getting mangled, use the escapes to make it display as you are actually seeing it on your machine.
Knute Snortum wrote:Change all the & to &