This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes JSP-DataBase problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JSP-DataBase problem" Watch "JSP-DataBase problem" New topic
Author

JSP-DataBase problem

Aris Doxakis
Ranch Hand

Joined: Dec 05, 2004
Posts: 136

Hello,
i connected my jsp page(index.jsp) with a ms access database.and i have the same error.dont know what it is.hope someone knows.here is the error page

org.apache.jasper.JasperException: Result set type is TYPE_FORWARD_ONLY
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:254)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2422)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:163)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:199)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:828)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:700)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:584)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:536)


root cause

javax.servlet.ServletException: Result set type is TYPE_FORWARD_ONLY
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:536)
at org.apache.jsp.index_jsp._jspService(index_jsp.java:266)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:210)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2422)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:163)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:199)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:828)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:700)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:584)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:536)



--------------------------------------------------------------------------------
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60804
    
  65

Please be careful to post questions in the appropriate forum.

Moved to the JDBC forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Maximilian Xavier Stocker
Ranch Hand

Joined: Sep 20, 2005
Posts: 381
The root cause is "Result set type is TYPE_FORWARD_ONLY"

This means that somewhere you attempt to move out of sequence with a result set and it doesn't like it.

Please post the code sample that causes this error.
Aris Doxakis
Ranch Hand

Joined: Dec 05, 2004
Posts: 136

Hello,

this is the code were i call the result set

<%
Connection con;
con = null;

try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); //load the driver
String url = "jdbc dbc ABookStore";
con = DriverManager.getConnection(url);
}
catch (ClassNotFoundException e) {
}
catch (SQLException e) {
}

Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select * from Category;");

Statement NewReleaseStmt = con.createStatement();
ResultSet NewReleaseSet = NewReleaseStmt.executeQuery("select ISBN,Author,Title,Price,Url,Pub_Date,Region from products order by Pub_Date");
%>


and here is the code were i use it

<td width="58%"><select name="Category">
<%
rs.first();
while (rs.next())
{
String Category = rs.getString("Category.CategoryName");
%>
<option value = <%=Category%>> <%=Category%>
<% } %>
</select></td>
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

There is first mistake of semi-colon ( in 2nd SQL statement.
& 2nd with a Category Field Name (Category.CategoryName) b/c u just retrieve one entity data in ur first SQL statement

String Category = rs.getString("CategoryName");


Saifuddin..
[Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
Aris Doxakis
Ranch Hand

Joined: Dec 05, 2004
Posts: 136

I tried it but the error persists.
If someone can explain me the error so i can understand it.That will help.
it worked perfectly for MySQL but when i changed the database to ms access i haven't seen it work
Aris Doxakis
Ranch Hand

Joined: Dec 05, 2004
Posts: 136

I've managed to specify the error and i can see that the error is produced at this part of my code

<td width="58%"><select name="Category">
<%
rs.first();
while (rs.next())
{
String Category = rs.getString("Category.CategoryName");
%>
<option value = <%=Category%>> <%=Category%>
<% } %>
</select></td>

were i use it to populate my selection from a database called category taking the fieln CategoryName.
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
Arg! SQL code in JSP! Now that's out of my system, why don't you try
omitting the rs.first() statement?


There is no emoticon for what I am feeling!
Aris Doxakis
Ranch Hand

Joined: Dec 05, 2004
Posts: 136

is there any other way to do ehat i want without using sql in jsp???
if there is i am open to suggestions..
will it work without using rs.first();???

thnx for reply
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
As for removing SQL from JSP, this is a matter of separating the presentation
layer of your app (JSP) from the backend (database). Options include:

* Using a framework like JSF or Struts
* Writing servlets that do the heavy lifting (usually by delegation) then
forward to a JSP to display the results.

One big advantage to this separation is that you can (unit) test your code
without involving the JSP.

As for removing the SQL from your app, there are ORMs like Hibernate
Aris Doxakis
Ranch Hand

Joined: Dec 05, 2004
Posts: 136

at this application that im working on it doesnt need this kind of "privacy"..
but your suggestions are very good.

but my problem still persists.any idea how to make it work??

as i said at a previouse post it worked perfectly with MYSQL but when i changed my database to MS Access it produced the error..

cant find out why.
Jeff Albertson
Ranch Hand

Joined: Sep 16, 2005
Posts: 1780
Again, why are you calling first()? I've written plenty of JDBC code and
I've never used that method.

And getting SQL/JDBC off your JSP page isn't about "privacy", it's
about simplifying the overall application. Mixing layers together
complicates debugging, testing and maintenance.
Aris Doxakis
Ranch Hand

Joined: Dec 05, 2004
Posts: 136

i thought that first() was needed to return index to beginig of table..
didnt try it yet without first() but will try .
thnx for your help....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP-DataBase problem
 
Similar Threads
Error in deploying struts: Attribute name invalid according to the specified TLD
What's the real cause of this?
argument type mismatch --- Please help
executing mail example in webapps/examples of Tomcat
Action Mappings Error!!!!!!!!!