• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jsp errror found

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
im in java beginers,i have found this error
[Microsoft][SQLServer 2000 Driver for JDBC]Invalid operation for the current cursor position.
pliz tell me where is the mistake and how to solve it.
i have givn the stak trace here plize give me the solution

<%
try
{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
Connection conn = DriverManager.getConnection("jdbc:microsoft:sqlserver://logindatabase:1433","sa","smcc123");
Statement st3=conn.createStatement();
String sql3 = "SELECT * FROM news.dbo.polledresult";
ResultSet rs3=st3.executeQuery(sql3);
rs3.next();

question=rs3.getString("lastques");
bs=rs3.getString("res2");
cs=rs3.getString("res3");
ds=rs3.getString("res4");
as=rs3.getString("res1");

%>
<center><font color="#1010A5" size="2" face="Verdana, Arial, Helvetica, sans-serif">Last poll result</font></center>
<% if(question != null){%>
<font color="#1010A5" size="2"><%=question%></font>
<%}%>
<applet code="swiftchart.class" width="249" height="200">
<param name="chart_type" value="bar3d">
<param name="x_value" value="a,b,c,d">
<param name="s1_value" value="<%=as%>,<%=bs%>,<%=cs%>,<%=ds%>">
<param name="s1_label" value="poll">
</applet>
</td></tr>
</table>

<%
st3.close();
rs3.close();
conn.close();
}
catch(Exception ex)
{
System.err.println("Error: " + ex );
out.println(ex.getMessage());
}
%>
<% session.setAttribute("insertTag","false"); %>
</td></tr></table>
</body>
</html>
 
Ranch Hand
Posts: 5575
Eclipse IDE Windows XP Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
your code is difficult to read.please use UBB code tag to post your coding part.
 
Ranch Hand
Posts: 398
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

It looks like you are not on a valid row or the result set might have closed. You should check what rs3.next() returns before accessing result set contents. next() will return false if you are not in a valid row.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
when multipple sets of data is returned you need to use loops to retrieve the entire data.
Use 'While(rs3.next()){}' instead of 'rs3.next();'
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Further, its not a good idea to do database stuff inside your JSP. If you are writing a test or something, then consider to use SQL tags.
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what is your version of sql 2000 db.maybe your database is missing to install something .
 
reply
    Bookmark Topic Watch Topic
  • New Topic