Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Invalid Cursor state!!

843859Oct 23 2008 — edited Oct 23 2008
Hi friends,

Greetings.

I am learning servlets and implemented this in my lab. I know it's not an efficient way of implementing. But when i execute this, during deployment of this servlet, i get the error "Invalid Cursor state". I can send the database if needed, as a mail
import java.io.*;
import java.sql.*;
import java.sql.DriverManager.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class eresult extends HttpServlet
{
 public void doGet(HttpServletRequest req,HttpServletResponse res)throws ServletException,IOException
 {
  Connection con;
  Statement s,t,u,v,w;
  String str1,str2,str3,str4;
  ResultSet rs,st,tu,uv,vw;
  int count=0;
  int a=0,b=0,c=0,d=0;
  
  String s0=req.getParameter("ecode");
  String s1=req.getParameter("ewin");
  String s2=req.getParameter("erun");
  
  res.setContentType("text/HTML");
  PrintWriter out=res.getWriter();

  try{

  Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  con=DriverManager.getConnection("jdbc:odbc:olympics");

  s=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
  t=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
  u=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
  v=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
  w=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
  rs=null;
  st=null;
  tu=null;
  uv=null;
  vw=null;
  rs=s.executeQuery("select * from event where ecode='"+s0+"'");
  while(rs.next())
  {
   count++;
  }
  if(count > 0)
   {
	 s.executeUpdate("update event set ewin='"+s1+"',erun='"+s2+"',status=1 where ecode='"+s0+"'");
	
  
  st=t.executeQuery("select * from player where pcode='"+s1+"'");
  a=st.getInt(3);
  str3=st.getString(4);
  
  tu=u.executeQuery("select * from player where pcode='"+s2+"'");
  b=tu.getInt(3);
  str4=tu.getString(4);

  uv=v.executeQuery("select * from country where ccode='"+str3+"'");
  c=uv.getInt(3);

  vw=w.executeQuery("select * from country where ccode='"+str4+"'");
  d=vw.getInt(3);
  System.out.println("before if");
  

	 t.executeUpdate("update player set ppt="+(a+2)+"where pcode='"+s1+"'");
	 
	 u.executeUpdate("update player set ppt="+(b+1)+"where pcode='"+s2+"'");
	 
	 v.executeUpdate("update country set cpt="+(c+2)+"where ccode='"+str3+"'");
	 
	 w.executeUpdate("update country set cpt="+(d+1)+"where ccode='"+str4+"'");
	 
	 	}
	else
	{
	 out.println("<h1 align=\"center\"><font color=green>OLYMPICS INFORMATION SYSTEM</font></h1><p> EVENT WITH THIS ID DOES NOT EXISTS!!!! SEEMS LIKE YOU ARE IN A HURRY TO FILL IN THE RESULTS!!</p>");
 	}
   con.close();
  }
  catch(Exception e)
  {
   out.println("error" + e);
  }
 }
}
errorjava.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid cursor state


Regards and Thank You for your help!!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 20 2008
Added on Oct 23 2008
2 comments
212 views