Hi Priya,
 
If you set the values in the PreparedStatement, the data selection is done
by the database system, which, probably, is faster in data proccessing than
the program you´re writing. You only get the values that matches
the where clause instead of getting all the values.
Althought the transaction could spend a little more (depends on the amount
of data you have), the data flow is less and, probably, faster. This doesn´t
matter much if you have a good conection and bandwidth.
 
So I advice you to set the values in the PreparedStatement Object.
I hope this helps,
 
Sergio
 
----- Original Message -----
Sent: Thursday, January 24, 2002 2:11 PM
Subject: Re: JDBC question - PreparedStatement

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

Reply via email to