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 5 of 5

Thread: JDBC_Servlet: Data not found

  1. #1
    Junior Member
    Join Date
    Jun 2011
    Posts
    10
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default JDBC_Servlet: Data not found

    There is some problem when i check username and validate it against password from the database.After checking password from request.getParamter() and validating it against password column from the database it should say "You have been successfully login"... Perhaps I am getting my own else block message"Incorrect Password..." which means there is some problem with the password thing. Here is my servlet code
    response.setContentType("text/html");
            PrintWriter out= response.getWriter();
            String uname= request.getParameter("txtuname");
            String pass= request.getParameter("txtpass");
            Connection con =null;
            try {
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                con=DriverManager.getConnection("jdbc:odbc:SQL","sa","mith1234");
                String select="select Password from sign_up where U_Name=\'"+uname+"\'";
                Statement st= con.createStatement();
                ResultSet rs= st.executeQuery(select);
                if(rs.next())
                {
                    //out.println(pass);
                    //out.println(rs.getString(1));
                    if(rs.getString(1).equals(pass))
                    {
                        out.println("You have been successfully logged in"+uname);
                    }
                   else 
                    {
                        out.println("Incorrect Password");
                    }
                }
            }
            catch(Exception e)
            {
                out.println(e);
            }
     }
    When i say out.println(rs.getString(1)) it is returning me the data from the database.... Any kind of help appreciated!!!!


  2. #2
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: JDBC_Servlet: Data not found

    Hello mithcool. Welcome to the Java Programming Forums.

    Does rs.getString(1).equals(pass) ever return the correct value when you print it out?
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

  3. #3
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: JDBC_Servlet: Data not found

    This thread has been cross posted here:

    http://www.java-forums.org/java-servlet/45682-jdbc_servlet-data-not-found.html

    Although cross posting is allowed, for everyone's benefit, please read:

    Java Programming Forums Cross Posting Rules

    The Problems With Cross Posting


  4. #4
    Junior Member
    Join Date
    Jun 2011
    Posts
    10
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: JDBC_Servlet: Data not found

    Quote Originally Posted by JavaPF View Post
    Hello mithcool. Welcome to the Java Programming Forums.

    Does rs.getString(1).equals(pass) ever return the correct value when you print it out?

    yup it does...

  5. #5
    Junior Member
    Join Date
    Jun 2011
    Posts
    10
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: JDBC_Servlet: Data not found

    Quote Originally Posted by copeg View Post
    This thread has been cross posted here:

    http://www.java-forums.org/java-servlet/45682-jdbc_servlet-data-not-found.html

    Although cross posting is allowed, for everyone's benefit, please read:

    Java Programming Forums Cross Posting Rules

    The Problems With Cross Posting


    Sorry for cross posting.I t was my first post to this website...

Similar Threads

  1. no data found ms -access sql exception
    By jatinrai199 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: February 16th, 2011, 03:22 PM
  2. application id not found
    By pradeepsetty in forum Java IDEs
    Replies: 3
    Last Post: June 2nd, 2010, 02:37 AM
  3. hi, its nice to found this forum :D
    By ordinarypeople in forum Member Introductions
    Replies: 2
    Last Post: April 4th, 2010, 02:12 PM
  4. Jsp source not found
    By jadeite100 in forum What's Wrong With My Code?
    Replies: 0
    Last Post: January 15th, 2010, 01:00 AM
  5. Main Class Not Found Problem
    By shadow in forum Java Theory & Questions
    Replies: 3
    Last Post: September 29th, 2009, 09:42 AM

Tags for this Thread