Getting Exception
java.sql.SQLException: Operation not allowed after ResultSet closed
<%
ResultSet rs=null,rs1=null;
Statement stmt=null,stmt1=null;
String UserID = request.getParameter("UserID");
String Password = request.getParameter("Password");
session.setAttribute("UserID",UserID);
int flag=0;
try{
System.out.println("Validating..1");
//stmt = con.createStatement();
//stmt1 = con.createStatement();
String Query = "select * from login where UserID = '"+UserID+"' and Password='"+Password+"'";
System.out.println(Query);
rs = st.executeQuery(Query);
System.out.println(rs);
if(rs!=null)
{
String Query1="Select * from basicdetails where UserID='"+UserID+"' and Password='"+Password+"'";
System.out.println(Query1);
rs1=st.executeQuery(Query1);
//System.out.println(rs1);
if(!rs1.next())
{
System.out.println("RS1");
while(rs1.next())
{
String PhotoPath=rs1.getString(4);
System.out.println("-------------------"+PhotoPath);
session.setAttribute("PhotoPath",PhotoPath);
}
}
}
if(!rs.next())
{
String Auth=rs.getString(3);
session.setAttribute("Auth",new Integer(Auth));
flag=1;
if(Auth.equals("0"))
{
//Show Admin Menu
%>
<jsp:forward page="AdminMenu.jsp"/>
<%
}
else if(Auth.equals("1"))
{
//Show user Menu
%>
<jsp:forward page="UserHome.jsp"/>
<%
}
}
else
{
flag=0;
%>
<jsp:forward page="Login.jsp"/>
<%
}
stmt.close();
con.close();
}catch(Exception e){
System.out.println(e.getCause());
System.out.println(e.getStackTrace());
System.out.println(e.getClass());
%><%=e%><%
}
%>
And Here is the message shown in output window of Netbeans
Validating..1 select * from login where UserID = 'admin' and Password='admin' com.mysql.jdbc.JDBC4ResultSet@b2c1e7 Select * from basicdetails where UserID='admin' and Password='admin' RS1 null [Ljava.lang.StackTraceElement;@1d8608c class java.sql.SQLException
What is the issue with the above code which is .jsp file trying to validate login credential of admin and other users.
I changed the whole code which I posted in my question, after getting answers from you all experts. We as a beginner expect your right guidance and proper clarification that's all. Here is the code -
Thank you everybody, and sorry for little harsh. Thank you again.