On Tuesday 04 April 2006 11:48 am, Daniel John Debrunner wrote:
> Anil Samuel wrote:
> > PreparedStatement ps = con.prepareStatement("select
> > TOTAL_TAKEN from DTP.LEAVE_APPROV where EMPLOYEE_ID=" + employee + " and
> > LEAVE_TYPE_ID=" + leaveTypeId);
>
>
> Couple of problems with the code:
>
[SNIP]
> May I suggest that if you are writing samples for others to use that you
> demonstrate use of parameter markers in PreparedStatements. This will
> perfom better on Derby and all other relational database engines.
>
> Here's a reworked version
>
Why use a prepared statement at all? If he already knows the input values, it
would be cleaner to create a statement then excute the statement.
Statement s = con.createStatement();
s.executeUpdate(string stuff);
Less overhead.
--
--
Michael Segel
Principal
Michael Segel Consulting Corp.
[EMAIL PROTECTED]
(312) 952-8175 [mobile]