Shah -
It is hard to answer your specific question wo/ seeing some code, but
here is what I do and it works fine. The key is to make sure the "more
= rs.next();" statement is within your while loop. You probably have
this in place, being somewhat obvious, but since I don't have your code
I had to mention that.
Here is my snippet:
===============================
[...]
String userid = "user1";
[...]
String qs = "select passwd from usertable where id = ?";
prepStmt = con.prepareStatement(qs);
prepStmt.setString(1, userid);
ResultSet rs = prepStmt.executeQuery();
String strUserPasswordFromDB = null;
boolean more = rs.next();
while (more) {
props = new java.util.Properties();
props.put("userid", "autdbo");
props.put("password", "autdbo");
strUserPasswordFromDB = rs.getString("passwd");
more = rs.next();
}
===============================
If the problem lies with the JDBC driver you are using, then this code
snippet may not be helpful.
Hope this helps, Mike Drummond
----------
From: Shaheen.Hussain
To: SERVLET-INTEREST
Subject: JDBC PreparedStatement
Date: Tuesday, July 13, 1999 6:34AM
Hey all,
I have just noticed odd behaviour with prepared statements in JDK1.2.
I have a preparedStatement which I create at the beginning of a function.
However if I substitue the place holders for values, within a loop, I get
the following error on second iteration:
java.sql.SQLException: Invalid state for getResultSet
However if I reinitialise the statement within the loop, that is, create a
new object for each iteration, it works fine.
Surely any new parameter values should clear the previous value, shouldn't
it?
Secondly, the function containing the above code is refusing to throw the
error back to the calling function. It contains a try/finally block.
Shah.
p.s. This code works fine with 1.1
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html