File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

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;
con = connectionPool.getConnection();
st = con.createStatement();
}catch(SQLException sqle){if(DEBUG){System.out.println("-------");}}
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"
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.
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, 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="" TARGET=_blank rel="nofollow">JSP: The Complete Reference</A><BR><A HREF="" TARGET=_blank rel="nofollow">Instant Java Servlets</A>
I agree. Here's the link:
subject: Servlet Problem with JDBC
It's not a secret anymore!