File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Servlet Problem with JDBC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Servlet Problem with JDBC" Watch "Servlet Problem with JDBC" New topic
Author

Servlet Problem with JDBC

Kevin Wright
Ranch Hand

Joined: Jul 10, 2001
Posts: 38
This is my problem...when I run the servlet, I get the SQLException below. What's the problem? Thanks,Kevin

/***Creates SQL String and executes Query
******SQLException caught*******
* Message: Get operation not allowed. No current row
* SQLState: null
* Error Code: 0
* Date/Time: Fri Aug 03 09:27:13 EDT2001
*****************************************
*
*
*/
private void executeQuery() throws SQLException
{
String s = null;
try{
con = connectionPool.getConnection();
st = con.createStatement();
}catch(SQLException sqle){if(DEBUG){System.out.println("-------");}}
if(DEBUG){System.out.println(SQLSTATEMENT+ewoNumber);}
rs = st.executeQuery(SQLSTATEMENT+ewoNumber);//create the statement, send it out
}
Kevin Wright
Ranch Hand

Joined: Jul 10, 2001
Posts: 38
Sorry...The actual SQL Statement (for an Access DB) is:
"SELECT * FROM tblLog WHERE serNumber = 233"
Thanks,
Kevin
Joe Wolf
Ranch Hand

Joined: Jul 05, 2001
Posts: 42
I'm not that experienced with JDBC so this is only an observation, but "Message: Get operation not allowed. No current row" to me sounds like the ResultSet cursor isn't in the right place.
http://java.sun.com/j2se/1.3.0/docs/api/java/sql/ResultSet.html
describes all the cursor-related functions. Try moving the cursor to the beginning of the table with first() before executing the query. That's the best I can think of.
Also, out of curiosity, what is the ewoNumber for and how do you use it?
Phil Hanna
Ranch Hand

Joined: Apr 05, 2001
Posts: 118
You aren't showing the code that gets the exception. You've created a result set (rs) but you're probably trying to access it elsewhere. If you haven't called rs.next(), that's the problem.
BTW, your executeQuery() method doesn't declare the rs variable. If you're declaring it as an instance variable in the servlet, you've got problems. Servlets are multithreaded, and if two requests occurs at or about the same time, the second one will overlay the instance variables of the first. Don't use instance variables; either keep the variables local to a method, or save them in an HttpSession object.

------------------
Phil Hanna
Sun Certified Programmer for the Java 2 Platform
Author of :
JSP: The Complete Reference
Instant Java Servlets


Phil Hanna<BR>Sun Certified Programmer for the Java 2 Platform<BR>Author of :<BR><A HREF="http://www.amazon.com/exec/obidos/ASIN/0072127686/electricporkchop/107-3548162-1137317" TARGET=_blank rel="nofollow">JSP: The Complete Reference</A><BR><A HREF="http://www.amazon.com/exec/obidos/ASIN/0072124253/electricporkchop/107-3548162-1137317" TARGET=_blank rel="nofollow">Instant Java Servlets</A>
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Servlet Problem with JDBC