Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Re: java.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid cursor state

  1. #1
    Junior Member
    Join Date
    Jul 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Re: java.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid cursor state

    //plz solve this prblm

    import java.io.IOException;
    import java.io.PrintWriter;
    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import java.sql.*;
    /**
    *
    * @author Windows 7
    */
    @WebServlet(name = "login", urlPatterns = {"/login"})
    public class login extends HttpServlet {

    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
    response.setContentType("text/html;charset=UTF-8");
    PrintWriter out = response.getWriter();
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection("jdbcdbc:yashdsn","", "");
    Statement stmt=con.createStatement();
    String str="select * from users_detail";
    ResultSet rs=stmt.executeQuery(str);

    String un=rs.getString("usern");
    String pw=rs.getString("pwrd");
    while(rs.next())
    {
    if(un.equals(request.getParameter("usname")))
    {
    if(pw.equals(request.getParameter("pwd")))
    {
    out.println("<font color=green font=8>Welcome.. "+un+"</font>");
    break;
    }
    }

    }
    out.println("<font color=red font=8>Invalid userid/password... </font>");
    stmt.close();
    con.close();
    }catch(Exception e){
    out.println("<font color=red >Error....:"+e.getMessage()+"</font>");
    } finally {
    out.close();
    }
    }


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,335
    Thanks
    181
    Thanked 830 Times in 773 Posts
    Blog Entries
    5

    Default Re: java.sql.SQLException: [Microsoft][ODBC Driver Manager] Invalid cursor state

    Please read the forum rules, and don't hijack someone else's post. I also suggest reading the link in my signature entitled "Getting Help"

Similar Threads

  1. Replies: 2
    Last Post: January 9th, 2012, 09:03 AM
  2. Replies: 0
    Last Post: December 25th, 2011, 12:59 PM
  3. Replies: 2
    Last Post: November 17th, 2011, 07:03 AM
  4. Replies: 1
    Last Post: September 9th, 2011, 02:30 PM
  5. Replies: 6
    Last Post: August 30th, 2009, 04:31 AM