Java. Lang. NullPointerException: always invoke a "Java. SQL. The ResultSet. Next ()" because "rs" is null
& lt; % @ page language="Java" contentType="text/HTML. Charset=ISO - 8859-1 "
PageEncoding="ISO - 8859-1" % & gt;
<% @ page import="Java. SQL. *" % & gt;
<% @ page import="qwer. DbBean" % & gt;
Verify the page & lt;/title>
<meta HTTP - equiv="content-type" Content="text/HTML. Charset=utf-8 "& gt;
<meta charset="ISO - 8859-1" & gt;
Insert the title here
<body>
<%
The String with username1 is=request. The getParameter (" username ");
String password1=request. The getParameter (" password ");
Boolean validated=false;
Boolean validated1=false;
The Connection conn=null;
The Statement Statement=null;
The ResultSet rs=null;
Try {
DbBean myDbBean=new DbBean ();
MyDbBean. OpenConnection ();
String SQL="select * from excel";
//if (myDbBean. Conn==null) out. Print (" no!" );
Rs=myDbBean. ExecuteQuery (SQL);
} the catch (Exception e) {
e.printStackTrace();
}
While (rs), next ()) {
Out. Print (rs. Get string (" id ") + "- & gt;" );
Out. Print (rs. Get string (" username ") + "- & gt;" );
Out. Print (rs. Get string (" password "));
}
/* the try {
Class.forName("com.mysql.jdbc.Driver");
The String url="JDBC: mysql://127.0.0.1:3306/wwy? ServerTimezone=UTC ";
String user="root";
String password="wwy112358";
Conn=DriverManager. GetConnection (url, user, password);
The statement=conn. CreateStatement ();
If (conn==null) out. Println (" NO connect!
" );
String SQL="select * from excel";
Rs=statement. ExecuteQuery (SQL);
While (rs), next ()) {
Out.println (rs. Get string (" id ") + "- & gt;" );
Out.println (rs. Get string (" username ") + "- & gt;" );
Out.println (rs. Get string (" password "));
}
Out.println (" success!
" );
} the catch (Exception e) {
//TODO Auto - generated the catch block,
e.printStackTrace();
} the finally {
Try {
If (rs!=null) rs. The close ();
} the catch (SQLException e) {
e.printStackTrace();
} the finally {
Try {
If (the statement!=null) statement. The close ();
} the catch (SQLException e) {
e.printStackTrace();
} the finally {
Try {
If (conn!=null) conn. Close ();
} the catch (SQLException e) {
e.printStackTrace();
}
}
}
}
*/
%>