Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Problems processing .jsp: Invalid Cursor State  RSS feed

 
Nick Orbit
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I've got a problem processing .jsp. All I want to do is a database query with the help of an html form. But every time I send the request to the browser I get an error code like this:
"javax.servlet.ServletException: Exception thrown processing JSP page.
java.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid cursor state
at sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLGetDataInteger(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcResultSet.getDataInteger(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcResultSet.getInt(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcResultSet.getObject(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcResultSet.getObject(Unknown Source)
at jrun__ultra__html__results2ejsp17._jspService(jrun__ultra__html__results2ejsp17.java:117)
at allaire.jrun.jsp.HttpJSPServlet.service(HttpJSPServlet.java:40)
at allaire.jrun.servlet.JRunSE.service(JRunSE.java:1013)
at allaire.jrun.servlet.JRunSE.runServlet(JRunSE.java:925)
at allaire.jrun.servlet.JRunNamedDispatcher.forward(JRunNamedDispatcher.java:34)
at allaire.jrun.jsp.JSPServlet.service(JSPServlet.java:174)
at allaire.jrun.servlet.JRunSE.service(JRunSE.java:1013)
at allaire.jrun.servlet.JRunSE.runServlet(JRunSE.java:925)
at allaire.jrun.servlet.JRunRequestDispatcher.forward(JRunRequestDispatcher.java:88)
at allaire.jrun.servlet.JRunSE.service(JRunSE.java:1131)
at allaire.jrun.servlet.JvmContext.dispatch(JvmContext.java:330)
at allaire.jrun.jrpp.ProxyEndpoint.run(ProxyEndpoint.java:354)
at allaire.jrun.ThreadPool.run(ThreadPool.java:267)
at allaire.jrun.WorkerThread.run(WorkerThread.java:74)"
I don't know what I could do now. I must admit, that I have no experience coding jsp and therefore I use Macromedia Dreamweaver UltraDev 4. I include the generated code in this message. It would be nice, if somebody could help me please.
Here the generated code begins:
<%@page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*"%>
<%@ include file="../Connections/connAccesspc511a.jsp" %>
<%
String results__MMColParam = "1";
if (request.getParameter("form1") !=null) {results__MMColParam = (String)request.getParameter("form1");}
%>
<%
Driver Driverresults = (Driver)Class.forName(MM_connAccesspc511a_DRIVER).newInstance();
Connection Connresults = DriverManager.getConnection(MM_connAccesspc511a_STRING,MM_connAccesspc511a_USERNAME,MM_connAccesspc511a_PASSWORD);
PreparedStatement Statementresults = Connresults.prepareStatement("SELECT * FROM ultra1 WHERE name LIKE '%" + results__MMColParam + "%'");
ResultSet results = Statementresults.executeQuery();
boolean results_isEmpty = !results.next();
boolean results_hasData = !results_isEmpty;
Object results_data;
int results_numRows = 0;
%>
<%
// *** Recordset Stats, Move To Record, and Go To Record: declare stats variables
int results_first = 1;
int results_last = 1;
int results_total = -1;
if (results_isEmpty) {
results_total = results_first = results_last = 0;
}
//set the number of rows displayed on this page
if (results_numRows == 0) {
results_numRows = 1;
}
%>
<%
// *** Recordset Stats: if we don't know the record count, manually count them
if (results_total == -1) {
// count the total records by iterating through the recordset
for (results_total = 1; results.next(); results_total++);
// reset the cursor to the beginning
results.close();
results = Statementresults.executeQuery();
results_hasData = results.next();
// set the number of rows displayed on this page
if (results_numRows < 0 | | results_numRows > results_total) {
results_numRows = results_total;
}
// set the first and last displayed record
results_first = Math.min(results_first, results_total);
results_last = Math.min(results_first + results_numRows - 1, results_total);
}
%>
<html>
<head>
<title>results</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<p>This is the original result page. 2001.</p>
<p> <%=(results_total)%></p>
<p><%=(((results_data = results.getObject("roomnumber"))==null | | results.wasNull())?"":results_data)%></p>

</body>
</html>
<%
results.close();
Connresults.close();
%>
End of generated code.
Thanks,
NIck
 
Rohit Ahuja
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
 
Rohit Ahuja
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi mate,
well i have encountered this problem before. nothing it is all too simple ,no big deal.
well, u r using a resultset to retrive the data,right??
okie wherever u r using the ResultSet rs got there.
Consider the following case,
there are two columns in the database,
taliban,osama.
now what u r trying to do is
rs.getString("osama");
and then rs.getString("taliban");
this is wrong as u have to first retrieve taliban and then only u will get osama.okie??
the other problem could be u rnt closing ur resultset and connection and statement in sequence 1.resultset,2.statement,3.connection.
do it
take care,
love deepak.
if it works mail me at deepak_a@rediffmail.com
waiting for a mail that ur code ran successfully.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!