db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Segel <de...@segel.com>
Subject Re: unable to execute procedure
Date Tue, 04 Apr 2006 17:03:22 GMT
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.
derby@segel.com
(312) 952-8175 [mobile]

Mime
View raw message