Skip to Main Content

Java Programming

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!

can you tell me why this is returning false?

770463Apr 11 2011 — edited Apr 12 2011
the following code works how ever is always returning false. so can you tell me why? and what i should do to fix it?
 public boolean checkUser(String user, String password){
        boolean connected = false;
        try{
           Class.forName("com.mysql.jdbc.Driver").newInstance();
           Connection con = DriverManager.getConnection("jdbc:mysql://localhost/finalprojects", "root", "password");
           Statement st = con.createStatement();
           ResultSet rs = st.executeQuery("select * from users where user ='" + user + "' and password ='" + password +"';");
           connected = true;
           rs.close();
           st.close();
           return connected;
        }catch(Exception e){
            e.printStackTrace();
        }

        return connected;
    }
This post has been answered by 796440 on Apr 11 2011
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 10 2011
Added on Apr 11 2011
41 comments
3,254 views