Forums Register Login

Servlet Problem with JDBC

+Pie Number of slices to send: Send
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
}
+Pie Number of slices to send: Send
Sorry...The actual SQL Statement (for an Access DB) is:
"SELECT * FROM tblLog WHERE serNumber = 233"
Thanks,
Kevin
+Pie Number of slices to send: Send
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?
+Pie Number of slices to send: Send
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
Onion rings are vegetable donuts. Taste this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 863 times.
Similar Threads
how can i send mail with JAVAMAIL API through intranet.
ORA-12514: TNS:listener could not resolve SERVICE_NAME given?
SQL query not giving any result
Error in creating Instance
load: GetMenuGui.class is not public or has no public constructor.
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 18, 2024 23:36:23.