I think with your alternative 1 you spoiled the advantage of preparing a
statement as it is actually a new statement
each time you prepare! Therefore db must allways prepare, preparing is expensive
btw. This means preparing a stament is only usefull if you must call the same
statements really often. If seen measurement charts for Orcal which state a
advantage of prepared statement over 'simple' statement after several 10s
invocations (sorry can't recall source right now)

The 2nd alternative it is the same statement all the time but with different
parameters. db prepares the statement only once

Peter Huber


"Ramaswamy, Rathnapriya (CORP, GTS, L531741)" wrote:

> Thanx Mark, but what I actually wanted to know was....(Sorry I did not
> convey properly)
>
> String query1="update table1 set field1 = ?, field2= ? where field3
> ='"+someBeanInstance.getName()+"' and field4 =
> '"+someBeanInstance.getDesc()+"'";
>
> String query2="update table1 set field1 = ?, field2 = ? where field3 = ? and
> field4=?;
>
> I wanted to know, if setting values in where clause directly rather than
> setting it in the PreparedStatement object has any adv/disadv? Is it better
> to always set the values in the PreparedStatement Object?
>
> Hope I have put across my doubt now.
>
> Thanx,
> Priya
>
> -----Original Message-----
> From: Mark Galbreath [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 24, 2002 6:30 PM
> To: [EMAIL PROTECTED]
> Subject: Re: JDBC question - PreparedStatement
>
> Not worth worrying about.  After the first call on the prepared statement,
> all variables will be set for any subsequent calls.  The nanosecond taken to
> set an additional couple of variables' values on the first call is
> negligible.
>
> Mark
>
> -----Original Message-----
> From: Ramaswamy, Rathnapriya
> Sent: Thursday, January 24, 2002 7:32 AM
>
> Is there any difference b/w usage of these two queries while using
> PreparedStatement.
>
> 1) String query = "update table1 set field1 = ?, field2= ? where field3 =
> 'value3' and field4 = 'value4';
>
> 2) String query = "update table1 set field1 = ?, field2 = ? where field3 = ?
> and field4 = ?;
>
> Thanx,
> Priya.
>
> ___________________________________________________________________________
> 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
>
> "THIS E-MAIL MESSAGE ALONG WITH ANY ATTACHMENTS IS INTENDED ONLY FOR THE
> ADDRESSEE and may contain confidential and privileged information.
> If the reader of this message is not the intended recipient,
> you are notified that any dissemination, distribution or copy of this
> communication is strictly Prohibited.
> If you have received this message by error, please notify us
> immediately, return the original mail to the sender and delete the
> message from your system."
>
> ___________________________________________________________________________
> 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

--

Peter Huber
(IT Consultant)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

evodion Information Technologies
GmbH & Co KG
Geschäftsstelle München
Witneystr.1
D-82008 Unterhaching
Telefon: +49-89-66561 - 128
Fax:     +49-89-66561 - 199
e-mail: mailto:[EMAIL PROTECTED]
Germany Web: http://www.evodion.de

___________________________________________________________________________
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