Results 1 to 2 of 2
- 12-05-2009, 05:55 AM #1
Member
- Join Date
- Dec 2009
- Posts
- 1
- Rep Power
- 0
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;
}
- 12-05-2009, 08:28 AM #2
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,716
- Rep Power
- 18
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
-
java.lang.NullPointerException Error
By Manfizy in forum NetBeansReplies: 3Last Post: 02-24-2011, 07:27 AM -
compiler error:"AWT-EventQueue-0" java.lang.NullPointerException at java.io.Reader.
By Ms.Ranjan in forum New To JavaReplies: 4Last Post: 04-23-2010, 02:54 PM -
The server encountered an internal error ()
By rakesh_n_mehta in forum Web FrameworksReplies: 0Last Post: 01-19-2009, 02:09 PM -
Error Java.lang.NullPointerException in JBuilder2006
By Jack in forum Other IDEsReplies: 2Last Post: 07-02-2007, 03:29 AM -
Description the server encountered an internal error
By Jack in forum Enterprise JavaBeans (EJB)Replies: 2Last Post: 07-02-2007, 03:24 AM
Bookmarks