Your resultset isn't null... the result set does just not contain anything... test
if(rs.next())
{
    //The Resultset contain at least 1
    do
    {
    }
    while(rs.next())
 
    //or something, it�s up to you
}
else
{
    //Does not contain any answer 
}
 
Hope I could help
-----Ursprungligt meddelande-----
Fr�n: A mailing list about Java Server Pages specification and reference [mailto:[EMAIL PROTECTED]]F�r Isak Rickyanto
Skickat: den 25 oktober 2001 23:09
Till: [EMAIL PROTECTED]
�mne: If ResultSet is null

Hello all ....
 
I want to ask about this code...
 
This code get resultset from database,,, but if it is null (the null result set) doesn't run the
code in the else section
 
I can't understand what is the problem ... If I use sql tag or not... those have same result...
 
the code in else don't run.... 
 
:< .. Please help me..... :<
 
the code :
 
Statement stmt=myConn.createStatement();
ResultSet myResultSet=stmt.executeQuery("select nama from user where id='"+login+"' and pass='"+pass+"' ");
 
if (myResultSet != null)
{
 while ( myResultSet.next() ) {
String nama= myResultSet.getString("nama");
%> 
<tr>
  <td><%= nama %></td>
  </tr>
  // memulai session
  <%
  session.setAttribute ("user", nama);
  %>
  <jsp:forward page="browsevcd.jsp" />
  
<%
  }
}
else
if (myResultSet == null)
{
         %>
       <jsp:include page="header.htm"  flush="true"/>
      <table>
        <tr><td colspan="2">Tabel</td></tr>
      <%
      out.println("You are not logged in");
      %>
       </table>
 <jsp:include page="footer.htm" flush="true"/>
       <%
 
}
 
stmt.close();
myConn.close();
%>

Reply via email to