Results 1 to 10 of 10

Thread: code login

  1. #1
    kevN is offline Member
    Join Date
    Aug 2008
    Posts
    6
    Rep Power
    0

    Thumbs down code login

    hey guys!
    here is the code for logging in that keeps giving a null pointer exception.
    Can u guys figure out the problem 4 me?
    Class.forName("com.mysql.jdbc.Driver");
    conn = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/project","root","");
    ps = (PreparedStatement) conn.prepareStatement("SELECT UserName,Password,Domain FROM user_details WHERE UserName=?");
    ps.setString(1,CurrentUser);
    ResultSet rset = ps.executeQuery();
    rseto = rset.getMetaData().getColumnCount();

    while(rset.next()){
    for(int i=0;i<=3;i++)
    carer[0] = (String)rset.getObject(i);
    }

    if(carer[1].equals(CurrentUser) && carer[2].equals(password) && carer[3].equals(selectDomain)){
    JOptionPane.showMessageDialog(null,"Welcome to Express Fleet Management.");
    firstInterface f = new firstInterface();
    f.setVisible(true);
    this.dispose();
    }else
    JOptionPane.showMessageDialog(null,"Either your user name,password or domain is incorrect.Please try again.");
    conn.close();

  2. #2
    serjant's Avatar
    serjant is offline Senior Member
    Join Date
    Jun 2008
    Location
    Ukraine,Zaporozhye
    Posts
    487
    Rep Power
    7

    Default

    What is the full error or exception output?

  3. #3
    Deepa is offline Member
    Join Date
    Nov 2008
    Posts
    85
    Rep Power
    0

    Default Re:

    Hi,
    If u pass null value in sql means,u will get the NullPointerException.

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    NullPointerException means you found a null value at runtime in your application. Did you try to debug and see what happen there?

  5. #5
    Deepa is offline Member
    Join Date
    Nov 2008
    Posts
    85
    Rep Power
    0

    Default Re:

    Hi,
    Ya,Null Pointer Exception means found null value at runtime.

  6. #6
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by Deepa View Post
    Hi,
    Ya,Null Pointer Exception means found null value at runtime.
    Are you looking to pass total number of posts of 20? Few times I've seen that you are just posting the same things.

  7. #7
    serjant's Avatar
    serjant is offline Senior Member
    Join Date
    Jun 2008
    Location
    Ukraine,Zaporozhye
    Posts
    487
    Rep Power
    7

    Default

    He wants to become a star hero of the forum.

  8. #8
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Quote Originally Posted by serjant View Post
    He wants to become a star hero of the forum.
    Not in a good way. Did you see his posts? Some of them are completely wrong, and some of them are useless.

  9. #9
    serjant's Avatar
    serjant is offline Senior Member
    Join Date
    Jun 2008
    Location
    Ukraine,Zaporozhye
    Posts
    487
    Rep Power
    7

    Default

    Sure and some of them are similar to yours ones.

  10. #10
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

Similar Threads

  1. mySQL login code??
    By sweet angle in forum JDBC
    Replies: 3
    Last Post: 10-20-2010, 09:42 AM
  2. login.jsp
    By roo7 in forum Enterprise JavaBeans (EJB)
    Replies: 5
    Last Post: 12-02-2008, 03:58 PM
  3. Login Forms
    By dankonsoer in forum New To Java
    Replies: 1
    Last Post: 08-07-2008, 12:06 PM
  4. Replies: 0
    Last Post: 06-25-2008, 12:41 PM
  5. I want to get values from login jsp
    By trill in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 08-07-2007, 07:33 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •