Results 1 to 2 of 2
  1. #1
    jackdear44 is offline Member
    Join Date
    Dec 2009
    Posts
    1
    Rep Power
    0

    Default Thread: Error 500--Internal Server Error java.lang.NullPointerException

    after executin this code it shows nullpointerexception......pls help


    public int securityLevel(String userid, String password) throws SQLException,
    MalformedURLException,
    IOException {
    connect();
    stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIV E, ResultSet.CONCUR_READ_ONLY);
    String SQL = "select * from USERS";
    int result=1;
    String [] security= new String [2];
    System.out.println("\nExecuting query: " + SQL);
    rset = stmt.executeQuery(SQL);

    while(rset.next()){
    security[0]=rset.getString(1);
    security[1]=rset.getString(2);
    security[2]=rset.getString(3);
    if(userid.equals(security[0])&&password.equals(security[1])){
    result=Integer.parseInt(security[2]);
    System.out.println(security[2]);
    }
    }
    return result;
    }

  2. #2
    pbrockway2 is online now Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,574
    Rep Power
    12

    Default

    The message indicates that you are trying to use a variable or expression whose value is null. The error message will say on what line this is happening: it would be good to share this information.

    But it's certainly before this line:

    Java Code:
    security[2]=rset.getString(3);

    which is going to throw an ArrayIndexOutOfBoundsException as you declare security to be an array of two strings, not three.

Similar Threads

  1. java.lang.NullPointerException Error
    By Manfizy in forum NetBeans
    Replies: 3
    Last Post: 02-24-2011, 07:27 AM
  2. Replies: 4
    Last Post: 04-23-2010, 02:54 PM
  3. The server encountered an internal error ()
    By rakesh_n_mehta in forum Web Frameworks
    Replies: 0
    Last Post: 01-19-2009, 02:09 PM
  4. Replies: 2
    Last Post: 07-02-2007, 03:29 AM
  5. Description the server encountered an internal error
    By Jack in forum Enterprise JavaBeans (EJB)
    Replies: 2
    Last Post: 07-02-2007, 03:24 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
  •