• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Servlet Problem with JDBC

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sorry...The actual SQL Statement (for an Access DB) is:
"SELECT * FROM tblLog WHERE serNumber = 233"
Thanks,
Kevin
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
reply
    Bookmark Topic Watch Topic
  • New Topic