A Suresh wrote:

> hi,thanks for the information. could u pls carify me further?i would like to
> know where this prepared statement residesduring the execution of a servlet.
> Is the compiled version ofthe stmt stored in the PreparedStatement obj or is
> it storedin the database server? In either case, pls elaborate on theprocess
> that goes on when using a
> PreparedStatement.thanks,______________________________________________
> A Suresh
> [EMAIL PROTECTED]
> + 91 - 040 - 7896008 ( Ext. 4611 )

I think you don't have to worry for where the compiled version is stored this is
handled internally, its life time depends on your connection life time and  your
prepare statement lifetime,
if you close one of them the compiled part should be dispossed, the exactly
moment depends of your database and drivers.
As I know the compiled part resides on your database, is not like a storage
procedure that has a life time that can trascend your connection.

These are some extracs from Sun documentation that can help you to clarify the
issue:

2.1.6     Sending SQL Statements

Once a connection is established, it is used to pass SQL statements to its
underlying database. JDBC does not put any restrictions on the kinds of SQL
statements that can be sent; this provides a great deal of
flexibility, allowing the use of database-specific statements or even non-SQL
statements. It requires, however, that the user be responsible for making sure
that the underlying database can process the SQL statements
being sent and suffer the consequences if it cannot. For example, an application
that tries to send a stored procedure call to a DBMS that does not support
stored procedures will be unsuccessful and generate an
exception. JDBC requires that a driver provide at least ANSI SQL-2 Entry Level
capabilities in order to be designated JDBC COMPLIANTTM. This means that users
can count on at least this standard level of
functionality.

JDBC provides three classes for sending SQL statements to the database, and
three methods in the Connection interface create instances of these classes.
These classes and the methods which create them are listed
below:

   1.Statement- -created by the method createStatement. A Statement object is
used for sending simple SQL statements.
   2.PreparedStatement- -created by the method prepareStatement. A
PreparedStatement object is used for SQL statements that take one or more
parameters as input arguments (IN parameters).
     PreparedStatement has a group of methods which set the value of IN
parameters, which are sent to the database when the statement is executed.
Instances of PreparedStatement extend Statement and
     therefore include Statement methods. A PreparedStatement object has the
potential to be more efficient than a Statement object because it has been
pre-compiled and stored for future use.
   3.CallableStatement- -created by the method prepareCall. CallableStatement
objects are used to execute SQL stored procedures- -a group of SQL statements
that is called by name, much like
     invoking a function. A CallableStatement object inherits methods for
handling IN parameters from PreparedStatement; it adds methods for handling OUT
and INOUT parameters.

The following list gives a quick way to determine which Connection method is
appropriate for creating different types of SQL statements:

     createStatement method is used for

          simple SQL statements (no parameters)

     prepareStatement method is used for

          SQL statements with one or more IN parameters

          simple SQL statements that are executed frequently

     prepareCall method is used for

          call to stored procedures


Regards.

Demch :)

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to