HI friends,

I opened jdbc connection in the post method ,no
compilation error but giving the following error
during run time.

Exceptionjava.sql.SQLException:[Microsoft][ODBC Driver
Manager] Function Sequence error

I am using this in a servlet chain,means this servlet
is generated from otherservlet and the same procedure
i used in that but it didn't give any error.Is there
fundamental I am missing here?

pl help me out

thanks
kishore

///  CODE here
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;

public class Sample100 extends HttpServlet{
   PrintWriter out;


   public void doPost(HttpServletRequest
request,HttpServletResponse response) throws
ServletException{
            try{

                         out=response.getWriter();
                         response.setContentType("text/html");

int h=Integer.parseInt(request.getParameter("count"));
String maincol;
String mainmain[]=new String[50];
int
colcnt=Integer.parseInt(request.getParameter("colcount"));

for (int i=1;i<=colcnt;i++)
{
    maincol="colmain"+Integer.toString(i);
        mainmain[i-1]=request.getParameter(maincol);
}


        String qstr10=request.getParameter("qstr");
        int colv[]=new int[50];
        String colnam[]=new String[20];
        String t;
        for (int i=0;i<h;i++)
        {
            t="colnam"+Integer.toString(i);
            colnam[i]=request.getParameter(t);
        }

        String colval[][]=new String[50][50];

        for (int j=0;j<h;j++)
                     {

colv[j]=Integer.parseInt(request.getParameter("rmax"+Integer.toString(j)));
                 }
        for (int i=0;i<h;i++)
               for (int j=0;j<colv[i];j++)
                   {

t="colval"+Integer.toString(i)+Integer.toString(j);
                                 colval[i][j]=request.getParameter(t);
                                 //colval[i][j]=(String)session.getValue(t);
                           }
         out.println("<HTML><HEAD><TITLE>");
                  out.println("Search");

***********  some logic here for generating query(its
generating correctly)********


 out.println("QSTR:"+qstr10+qstr);
 qstr=qstr10+qstr;



Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
 Connection
con=DriverManager.getConnection("jdbc:odbc:test","sa","");
     Statement stmt=con.createStatement();
 ResultSet rs;
rs=stmt.executeQuery(qstr);


 int rcount=0;
 int flag=0;
 for (int i=0;i<h;i++)
   {
       if(flag==0)
       {
                        rs=stmt.executeQuery(qstr);
                while(rs.next())
                    rcount++;
                        rs.close();
              if (rcount>0)
         {
              out.println("No of Matches:"+rcount);
              flag=1;
         }
      else
         {
                        k=qstr.lastIndexOf("and (");
                    qstr=qstr.substring(0,k);
                 }
          }
   }

rs.close();

out.println("<form method='post'
action='Sample100'>");
out.println("<input type='hidden' name='count'
value='"+zvarr+"'>");
out.println("<input type='hidden' name='colcount'
value='"+colcnt+"'>");
out.println("<table border='1' align='center'
width='60%'>");
        k=0;
    int zvar2=0;
        for(int i=0;i<h;i++)
     {
                 if (zarr[i]==0)
                {
                out.println("<tr><td width='30%'
bgcolor='#CAC9B9'>"+colnam[i]+"</td>");

                out.println("<td width='50%'
bgcolor='#008080' style='color: rgb(128,0,0)'>");

            for(int j=0;j<colv[i];j++)
                   out.println("<input type='checkbox'
name='C"+Integer.toString(zvar2)+Integer.toString(j)+"'
value='"+colval[i][j]+"' style='background-color:
rgb(0,128,128)'>"+colval[i][j]);

                        out.println("</td></tr>");
                        zvar2=zvar2+1;
                        }
                        k=k+1;
         }
         out.println("</table>");

    out.println("<div align='center'><center><p><input
type='submit' value='Search'></center></div></form>");

//   TO RETRIEVE THE VALUES FROM THE DATABASE
rs=stmt.executeQuery(qstr);

out.println("<table align='center' border='1'>");
       while (rs.next())
      {
                   out.println("<tr>");
                   for(int i=1;i<=colcnt;i++)

out.println("<td>"+rs.getString(i)+"</td>");
           out.println("</tr>");
      }

   rs.close();
   stmt.close();
con.close();

    out.println("</body></html>");

    }catch(Exception e){
                      System.out.println("Exception"+e);
                }

        }

        public void destroy(){
                out.close();
        }
}

__________________________________________________
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://im.yahoo.com

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to