servlets thread: The request has been accepted, but it failed to complete due to a problem querying DB
It also helps, ESPECIALLY DURING DEVELOPMENT, if you print out a stack
trace in the catch block so that you know exactly which line caused the
problem. At best, all we can say is that one of the lines (but you don't
know which line) in the try block had a problem.
However, looking at your code I can see that the problem is that you tried
to get data from the result set when you were not positioned on any row.
You cannot get any data from the result set UNTIL you move it to a row.
When the result set comes back from the query, it is positioned prior to
the first row. You need to call rs.next() or some other positioning method
call and check that the return value is true, then you can get data from
the result set.
> try
> {
> stmt = dbCon.createStatement();
> rs = stmt.executeQuery(qry.toString());
if (rs.next()) {
> r1 = rs.getString("LOGON_PASSWORD");
}
> }
> catch(SQLException e)
> {
> res.sendError(res.SC_ACCEPTED, "The request has
b> een accepted, but it failed to complete due to a problem querying DB");
> return;
> }
You may want to consult some JDBC tutorials before you attempt to do any
more database programming. Sun's web site has a pretty good JDBC tutorial
Kevin Mukhar
Co-Author Beginning Java Databases
http://home.earthlink.net/~kmukhar