But line 15 takes an
int as ist first parameter, obviously to set the index in the prepared statement. What did you intend the index to be?
Don't presume somebody will call that method. If
setDataSource() isn't called, the template object won't be created and cannot be used in line 12. Force them to initialise it. If you can't set the user name
via the constructor,
test whether the data source has been initialised by line 11 and throw an illegal state exception (or a checked exception of some sort) if it hasn't. And write some documentation comments to make it clear to users. If they ignore the comments, you can tell them off.
If that is the only constructor you write, users
must initialise the template. Why is the template field marked
protected? That is tempting other code to change it, without your knowing about it.