File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes dreamweaver & access Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "dreamweaver & access" Watch "dreamweaver & access" New topic
Author

dreamweaver & access

Kenny Lawyer
Greenhorn

Joined: Jul 06, 2006
Posts: 4
HELLO EVERYONE IM BUILDING MY FIRST WEB PAGE USING ACCESS AND DREAMWEAVER. I am trying to build a page to delete a record from the database using the tools provided by Dreamweaver and things work well until i click the Fixed link to goto my delete confirmation page: I get this error:

exception

org.apache.jasper.JasperException: Exception in JSP: /conPage.jsp:110

107: <body>
108: <form id="form1" name="form1" method="POST" action="<%=MM_editAction%>">
109: <p>
110: <input name="hiddenField" type="hidden" value="<%=(((DeleteRecord_data = DeleteRecord.getObject("cpu"))==null || DeleteRecord.wasNull())?"" eleteRecord_data)%>" />
111: </p>
112: <p><%=(((DeleteRecord_data = DeleteRecord.getObject("cpu"))==null || DeleteRecord.wasNull())?"" eleteRecord_data)%></p>
113: <p><%=(((DeleteRecord_data = DeleteRecord.getObject("issue"))==null || DeleteRecord.wasNull())?"" eleteRecord_data)%></p>


Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:504)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:375)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

javax.servlet.ServletException: [Microsoft][ODBC Driver Manager] Invalid cursor state
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:858)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
org.apache.jsp.conPage_jsp._jspService(conPage_jsp.java:223)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)


root cause

java.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid cursor state
sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
sun.jdbc.odbc.JdbcOdbc.SQLGetDataString(Unknown Source)
sun.jdbc.odbc.JdbcOdbcResultSet.getDataString(Unknown Source)
sun.jdbc.odbc.JdbcOdbcResultSet.getString(Unknown Source)
sun.jdbc.odbc.JdbcOdbcResultSet.getObject(Unknown Source)
sun.jdbc.odbc.JdbcOdbcResultSet.getObject(Unknown Source)
org.apache.jsp.conPage_jsp._jspService(conPage_jsp.java:185)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

Anyone know what could be wrong as this is where im stuck at the names in the table are cpu, issue, comment and the are the same in the result set.

[ July 06, 2006: Message edited by: Bear Bibeault ]

[edited subject from "need help" to make meaningful"
[ July 06, 2006: Message edited by: Jeanne Boyarsky ]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65

Step 1: Learn how to use JavaRanch as a resource.

I'd suggest reading this as a start to discover why "Need help" is a poor way to try and get that help.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60053
    
  65

And, since this appears to be a JDBC problem more than a JSP one, I've moved this off to the JDBC forum.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29239
    
139

Kenny,
I assume DeleteRecord is a JDBC ResultSet object? If not, what is it.

If it is a ResultSet, you need to call DeleteRecord.next() before calling any getters. Otherwise, the result set is pointing at the row before the first row of data - which is an invalid cursor state.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29239
    
139

Kenny,
Welcome to JavaRanch!

I edited your subject so people get a better feel for the question. That way people who know will be more likely to read the question.

For the future, note that all caps is often considered shouting on the Internet.
Kenny Lawyer
Greenhorn

Joined: Jul 06, 2006
Posts: 4
thank you all so much and sorry for messin up the boards DeleteRecord is a resultset so i will check that and see if it corrects the problem
Kenny Lawyer
Greenhorn

Joined: Jul 06, 2006
Posts: 4
ok i checked things out in my dreaweaver code and this is what I was looking at:

<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<%@ include file="Connections/db.jsp" %>
<%
// *** Edit Operations: declare variables

// set the form action variable
String MM_editAction = request.getRequestURI();
if (request.getQueryString() != null && request.getQueryString().length() > 0) {
String queryString = request.getQueryString();
String tempStr = "";
for (int i=0; i < queryString.length(); i++) {
if (queryString.charAt(i) == '<') tempStr = tempStr + "<";
else if (queryString.charAt(i) == '>') tempStr = tempStr + ">";
else if (queryString.charAt(i) == '"') tempStr = tempStr + """;
else tempStr = tempStr + queryString.charAt(i);
}
MM_editAction += "?" + tempStr;
}

// connection information
String MM_editDriver = null, MM_editConnection = null, MM_editUserName = null, MM_editPassword = null;

// redirect information
String MM_editRedirectUrl = null;

// query string to execute
StringBuffer MM_editQuery = null;

// boolean to abort record edit
boolean MM_abortEdit = false;

// table information
String MM_editTable = null, MM_editColumn = null, MM_recordId = null;

// form field information
String[] MM_fields = null, MM_columns = null;
%>
<%
// *** Delete Record: construct a sql delete statement and execute it

if (request.getParameter("MM_delete") != null &&
request.getParameter("MM_delete").toString().equals("form1") &&
request.getParameter("MM_recordId") != null) {

MM_editDriver = MM_db_DRIVER;
MM_editConnection = MM_db_STRING;
MM_editUserName = MM_db_USERNAME;
MM_editPassword = MM_db_PASSWORD;
MM_editTable = "issue";
MM_editColumn = "cpu";
MM_recordId = "'" + request.getParameter("MM_recordId") + "'";
MM_editRedirectUrl = "COBA_home.html";

// append the query string to the redirect URL
if (MM_editRedirectUrl.length() != 0 && request.getQueryString() != null) {
MM_editRedirectUrl += ((MM_editRedirectUrl.indexOf('?') == -1)?"?":"&") + request.getQueryString();
}
}
%>
<%
// *** Delete Record: construct a sql delete statement and execute it

if (request.getParameter("MM_delete") != null &&
request.getParameter("MM_recordId") != null) {

// create the delete sql statement
MM_editQuery = new StringBuffer("delete from ").append(MM_editTable);
MM_editQuery.append(" where ").append(MM_editColumn).append(" = ").append(MM_recordId);

if (!MM_abortEdit) {
// finish the sql and execute it
Driver MM_driver = (Driver)Class.forName(MM_editDriver).newInstance();
Connection MM_connection = DriverManager.getConnection(MM_editConnection,MM_editUserName,MM_editPassword);
PreparedStatement MM_editStatement = MM_connection.prepareStatement(MM_editQuery.toString());
MM_editStatement.executeUpdate();
MM_connection.close();

// redirect with URL parameters
if (MM_editRedirectUrl.length() != 0) {
response.sendRedirect(response.encodeRedirectURL(MM_editRedirectUrl));
return;
}
}
}
%>
<%
String DeleteRecord__MMColParam = "1";
if (request.getParameter("recordID") !=null) {DeleteRecord__MMColParam = (String)request.getParameter("recordID");}
%>
<%
Driver DriverDeleteRecord = (Driver)Class.forName(MM_db_DRIVER).newInstance();
Connection ConnDeleteRecord = DriverManager.getConnection(MM_db_STRING,MM_db_USERNAME,MM_db_PASSWORD);
PreparedStatement StatementDeleteRecord = ConnDeleteRecord.prepareStatement("SELECT * FROM issue WHERE cpu = '" + DeleteRecord__MMColParam + "'");
ResultSet DeleteRecord = StatementDeleteRecord.executeQuery();
boolean DeleteRecord_isEmpty = !DeleteRecord.next();
boolean DeleteRecord_hasData = !DeleteRecord_isEmpty;
Object DeleteRecord_data;
int DeleteRecord_numRows = 0;
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<form id="form1" name="form1" method="POST" action="<%=MM_editAction%>">
<p>
<input name="hiddenField" type="hidden" value="<%=(((DeleteRecord_data = DeleteRecord.getObject("cpu"))==null || DeleteRecord.wasNull())?""eleteRecord_data)%>" />
</p>
<p><%=(((DeleteRecord_data = DeleteRecord.getObject("cpu"))==null || DeleteRecord.wasNull())?""eleteRecord_data)%></p>
<p><%=(((DeleteRecord_data = DeleteRecord.getObject("issue"))==null || DeleteRecord.wasNull())?""eleteRecord_data)%></p>
<p><%=(((DeleteRecord_data = DeleteRecord.getObject("comment"))==null || DeleteRecord.wasNull())?""eleteRecord_data)%></p>
<p>
<label>
<input type="submit" name="Submit" value="Issue Fixed" />
</label>
</p>
<p> </p>

<input type="hidden" name="MM_delete" value="form1">
<input type="hidden" name="MM_recordId" value="<%=(((DeleteRecord_data = DeleteRecord.getObject("cpu"))==null || DeleteRecord.wasNull())?""eleteRecord_data)%>">
</form>
</body>
</html>
<%
DeleteRecord.close();
StatementDeleteRecord.close();
ConnDeleteRecord.close();
%>

It appears that the DeleteRecord is being called before other getters but im still commin up with the same problem
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29239
    
139

Kenny,
That code has a bug in it.

It has booleans for whether the result isEmpty/hasData. However, it never checks those booleans. So if there is no data in the result set, it is still trying to read an empty result set.
Kenny Lawyer
Greenhorn

Joined: Jul 06, 2006
Posts: 4
Thank you so much for all the help with this problem. I noticed the boolean expressions that Dreamweaver put in as well. My question is should those be removed all together. I will comment out the expressions and see what happens then and will let you know
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29239
    
139

Kenny,
Commenting out the expressions won't help eliminate the error. The JSP needs an if statement based on those booleans to see whether to even call rs.getXXX().
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: dreamweaver & access
 
Similar Threads
IntegratedParserConfiguration classcast exception
Getting exception on deployment to Tomcat using JSF
javax.servlet.ServletException: Name java: is not bound in this Context
Problem with LoginAction.java
Connecting JSP to MySQL