tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "GB Developer" <gb107...@globallyboundless.com>
Subject RE: Servlet problem/Data Source Problem
Date Tue, 21 Feb 2006 15:56:44 GMT
Did you look in the catalina.out file for any thrown Exceptions?  You are
try/catching and then System.out.println'ing them. You should have seen a
SQLException trace of some sort, read inline below...


> -----Original Message-----
> From: Mark Whitby [mailto:ug82msw@cs.bham.ac.uk] 
> Sent: Tuesday, February 21, 2006 7:38 AM
> To: Tomcat Users List
> Subject: Servlet problem/Data Source Problem
> 
>    ResultSet rst = stmt.executeQuery("select id, chest from 
> testdata");

you're missing this:
     if (rst.next()) {

>             blob = rst.getInt("chest");
     }

you're also missing a WHERE clause in the query. You'll select everything
from testdata, by rs.next() will only get you to the first row.  To process
all rows, you make it a "while (rst.next()) { ", but then it would have to
be some sort of concatenation operation instead of just
blob=rst.getInt("chest"), because of course, if you did 'while', blob would
only contain the *last* row. So if you're interested in just the first row
or just the last row, there are more efficient ways of obtaining them.


>             address = "/testy.jsp?errorcode=" + blob;
>             stmt.close();
>             con.close();
>         } catch(NamingException e){
>             System.out.println(e.toString());
>         } catch(SQLException sql){
>             System.out.println(sql.toString());
>         }
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message