Heakyung Park wrote:
> Hello!
>
> Does anyone know why the following sql query doesn't work in servlet,
> although it works as sql command line query? It returns the first column
> value instead of the sum of the hours column.
>
> PreparedStatement get_time = dbc.prepareStatement(select SUM(hours) as
> time where SSN LIKE ? and code=?");
You can change this to:
PreparedStatement get_time = dbc.prepareStatement(select SUM(hours) where SSN
LIKE ? and code=?");
>
> get_time.setString(1, ssn);
> get_time.setInt(2, 0);
> ResultSet rs = get_time.executeQuery();
>
> rs.next();
> int time = rs.getInt(time);
And, change this to:
int time = rs.getInt(1);
This should work.
Sanjesh
>
>
> ___________________________________________________________________________
> 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
___________________________________________________________________________
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