On Thu, 11 Apr 2002, Barry Lind wrote:
> I'm not sure that JDBC would use this feature directly. When a
> PreparableStatement is created in JDBC there is nothing that indicates
> how many times this statement is going to be used. Many (most IMHO)
> will be used only once.
Well, the particular PreparedStatement instance may be used only
once, yes. But it's quite likely that other, identical PreparedStatement
objects would be used time and time again, so it's still good if
you don't need to do much work on the second and subsequent
preparations of that statement.
> If it only is used once, it will actually perform worse than
> without the feature (since you need to issue two sql statements to the
> backend to accomplish what you were doing in one before).
I'm not sure that it would be much worse unless you need to wait
for an acknowledgement from the back-end for the first statement.
If you had a back-end command along the lines of "prepare this
statement and execute it with these parameters," it would have
pretty much the same performance as giving the statement directly
with the parameters already substituted in, right?
> Thus if someone wanted to use this functionality from jdbc they would
> need to do it manually, i.e. issue the prepare and execute statements
> manually instead of the jdbc driver doing it automatically for them.
I'd say that this is awfully frequent, anyway. I use PreparedStatements
for pretty much any non-constant input, because it's just not safe
or portable to try to escape parameters yourself.
cjs
--
Curt Sampson <cjs@cynic.net> +81 90 7737 2974 http://www.netbsd.org Don't you know, in this new Dark Age, we're
alllight. --XTC