You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Enrique Prados Valiente <ep...@solusoft.es> on 2001/05/29 15:01:24 UTC

Problems with ResultSet

Hi! 
I'm using Tomcat and JSP but there are problem, my JSP don' work.....
I have this code in my JSP
(code.....)
Statement s=cn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);

(more code........)


           if (!rs.isFirst()) rs.previous(); 

              %><tr> 
              <td><%=rs.getString(1)%></td><%

           }

(more code........)

In begin of my JSP there is this code line <%@ page language="java" import="java.sql.*,java.io.*,java.util.*" %>

but when I run the server and JSP, it appears this error


	[Microsoft][ODBC Driver Manager] Invalid cursor state


I think that Jsp fails in this code line,             <td><%=rs.getString(1)%></td><%


                               
Can anyone out there help me? 
Thanks in advance, 
Enrique.







Re: Problems with ResultSet

Posted by Guido Medina <gu...@ns2.iiac.net>.
It also happens with MS Access if your try to getType(int n), Type = {String
| Int | ...} more than once, it means that you cannot do the follow with MS
Access:

Statement st = con.createStatement();
ResultSet rs = st.executeQuery("......");
while (rs.next()) {
   out.println(String a = rs.getString(1));
   ...
   ...
   ...
   out.println(String a = rs.getString(1));
}

This should work in every database manager but doesn't work, you must do:
String a = rs.getString(1) and keep using a instead of try to get the value
again...

This happens with MS Access, I don't know if with some else database
manager...

Guido.
----- Original Message -----
From: "Moin Anjum H." <mo...@yahoo.com>
To: <to...@jakarta.apache.org>
Sent: Wednesday, May 30, 2001 1:14 AM
Subject: Re: Problems with ResultSet


> Hi,
>
> Is your Database MSAccess?
>
> If yes then try Statement
s=cn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_O
NLY);
> for a full blown Explain Explaination Please go through Java Docs.
>
> HTH
> Best Regards
> Moin.
>
> Enrique Prados Valiente wrote:
>
> > Hi!
> > I'm using Tomcat and JSP but there are problem, my JSP don' work.....
> > I have this code in my JSP
> > (code.....)
> > Statement
s=cn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ
_ONLY);
> >
> > (more code........)
> >
> >            if (!rs.isFirst()) rs.previous();
> >
> >               %><tr>
> >               <td><%=rs.getString(1)%></td><%
> >
> >            }
> >
> > (more code........)
> >
> > In begin of my JSP there is this code line <%@ page language="java"
import="java.sql.*,java.io.*,java.util.*" %>
> >
> > but when I run the server and JSP, it appears this error
> >
> >         [Microsoft][ODBC Driver Manager] Invalid cursor state
> >
> > I think that Jsp fails in this code line,
<td><%=rs.getString(1)%></td><%
> >
> >
> > Can anyone out there help me?
> > Thanks in advance,
> > Enrique.
>


Re: Problems with ResultSet

Posted by "Moin Anjum H." <mo...@yahoo.com>.
Hi,

Is your Database MSAccess?

If yes then try Statement s=cn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
for a full blown Explain Explaination Please go through Java Docs.

HTH
Best Regards
Moin.

Enrique Prados Valiente wrote:

> Hi!
> I'm using Tomcat and JSP but there are problem, my JSP don' work.....
> I have this code in my JSP
> (code.....)
> Statement s=cn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
>
> (more code........)
>
>            if (!rs.isFirst()) rs.previous();
>
>               %><tr>
>               <td><%=rs.getString(1)%></td><%
>
>            }
>
> (more code........)
>
> In begin of my JSP there is this code line <%@ page language="java" import="java.sql.*,java.io.*,java.util.*" %>
>
> but when I run the server and JSP, it appears this error
>
>         [Microsoft][ODBC Driver Manager] Invalid cursor state
>
> I think that Jsp fails in this code line,             <td><%=rs.getString(1)%></td><%
>
>
> Can anyone out there help me?
> Thanks in advance,
> Enrique.


Re: Problems with ResultSet

Posted by Jim Cheesman <jc...@msl.es>.
At 03:01 PM 29/05/01, you wrote:

>Hi!
>I'm using Tomcat and JSP but there are problem, my JSP don' work.....
>I have this code in my JSP
>(code.....)
>Statement 
>s=cn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READ_ONLY);
>
>(more code........)
>
>
>            if (!rs.isFirst()) rs.previous();


Is there any particular reason you're going backwards through the result 
set? Wouldn't it be more efficient/logical to use rs.next()?

<snip>

>         [Microsoft][ODBC Driver Manager] Invalid cursor state


Try something like:
if (rs.next()) {
   <%= rs.getString(1) %>
}



Salud2.
Jim




--

                           *   Jim Cheesman   *
             Trabajo: 
jchees@msl.es - (34)(91) 724 9200 x 2360
              Not only am I 
redundant and superfluous, but I
                also tend to use more 
words than necessary.