-
javax.servlet.ServletException: General error - invalid cursor state
I have an SQL statement that is returning a ResultSet and looping through rows in the database.
I've run the SQL in the database and it works perfectly, but when I run it on the browser, I am getting the following message:
javax.servlet.ServletException: General error
The code is as follows:
String sql = "SELECT patient.FName,patient.LName, patientClaim.claimNo, claim.claimNo, claim.submittedDate,"
+"claim.totalCost, claim.SOB_ID, claim.visitID, claimStatus.statusID, status.StatusName,"
+"employee.employeeID, SOB.claimType FROM SOB, status, employee, claim, patient, employeeClaim ,"
+"claimStatus, patientClaim WHERE patient.patientID = patientClaim.patientID AND claim.claimNo = patientClaim.claimNo"
+"AND claim.claimNo = employeeClaim.claimNo AND employeeClaim.employeeID = employee.employeeID AND"
+" patientClaim.claimNo = claimStatus.claimNo AND claim.claimNo = claimStatus.claimNo AND status.statusID = claimStatus.statusID AND"
+" SOB.SOB_ID = claim.SOB_ID AND status.StatusName='Pending' AND employeeClaim.employeeID =9;";
Statement stmt =con.createStatement();
ResultSet rs = stmt.executeQuery(sql);
%>
<table border = "1" align = "center">
<tr>
<th> Claim No </th>
<th> Submitted Date</th>
<th> Total Cost </th>
<th> Date of Symptoms</th>
<th> Claim Status</th>
<th> Patient Name</th>
</tr>
<%
while (rs.next())
out.println("<tr> <td>");
out.println("+rs.getInt("claimNo")+"</td>");
out.println("<td>"+rs.getDate("submittedDate") +"</td>");
out.println("<td>"+rs.getInt("totalCost") +"</td>");
out.println("<td>"+rs.getDate("dateOfSymptoms") +"</td>");
out.println("<td>"+rs.getString("statusName") +"</td>");
out.print("<td>"+rs.getString("FName")+ "</td></tr>");
%>
</table>
<% rs.close(); %>
If I change the line with the out.println("claimNo") I get an error message of invalid cursor state.
Can anyone kindly suggest a way out of this problem.
PS. I have run a simpler sql statement such as select * from claim and I got the same error message.
Last edited by Maria Modeste; 10-11-2005 at 08:43 AM.
Reason: Added invalid cursor state to the subject. The subject was too vague
-
Does anyone out there know how to fix this?
-
I'm not sure how to fix it exactly but I can point out at least one issue:
Code:
String sql = "SELECT patient.FName,patient.LName, patientClaim.claimNo,
claim.claimNo, claim.submittedDate,"
...
out.println("+rs.getInt("claimNo")+"</td>");
Right away, which claimNo should JDBC get out of the ResultSet - you have patientClaim.claimNo and claim.claimNo? You may be better off using the integer version of the ResultSet get methods than the String version. For example, maybe you'd instead like something like:
Code:
...
out.println("+rs.getInt(3)+"</td>");
out.println("<td>"+rs.getDate(4) +"</td>");
...
though you can mix and match the integer versions and the string versions.
Similar Threads
-
By clarence_rollins in forum .NET
Replies: 21
Last Post: 09-11-2002, 11:32 AM
-
By Khalizan in forum VB Classic
Replies: 1
Last Post: 11-28-2001, 01:32 AM
-
By Brian in forum VB Classic
Replies: 3
Last Post: 01-07-2001, 05:14 PM
-
Replies: 1
Last Post: 10-24-2000, 11:38 AM
-
By Tom Shreve in forum Enterprise
Replies: 0
Last Post: 04-07-2000, 09:19 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks