Re: Java SQL interface




"lakshmi Ashok" wrote...

Bjorn A wrote:

If the DB even makes use of a query plan, in most cases it's
the DB itself that decides upon that.

So, if I use a java prepared statement, there is no confirmation
that the DB may re-use the query plan?

In this case, its as good as using 'Statement' ??

The above issue I have raise is valid if at all a query plan
cache mechanism is in place in the target DB?

Once again, that depends on the implementation.

If the DB makes use of query (or execution) plans, it will do so regardless
if you're using PreparedStatements or only Statements.

The use of PreparedStatements will though increase the possibility to use
possible extended functionality in the DB, e.g. if it internally makes use
of parameterised statements, etc, which menas that it *could* affect the
execution plans.

It could very well be the case that it uses the PreparedStatement to refine
the execution plan further, as you with a PreparedStatement explicitly
define what parameters that can be exhanged for others in the statement.

But, once again, that depends on the implementation, *both* in the DB and in
the PreparedStatement as such. There is no "general rule" for that. The only
thing you can be sure of is what the "contract" for PreparedStatement says:

http://java.sun.com/j2se/1.5.0/docs/api/java/sql/PreparedStatement.html

/// Bjorn A






Inviato da X-Privat.Org - Registrazione gratuita http://www.x-privat.org/join.php
.



Relevant Pages

  • Re: Statement and Resultset
    ... it is more efficient to use the EXECUTE IMMEDIATE statement ... the query plan produced for a prepared statement ... Prepared SQL events should be much larger than the number of Prepare ... If the underlying DB does not support PreparedStatement, ...
    (comp.lang.java.programmer)
  • Re: PreparedStatement
    ... RCS wrote: ... > if the PreparedStatement has been closed in the meantime? ... The DBMS may keep the query plan for ... until the connection is closed). ...
    (comp.lang.java.databases)