Hi,

and DO NOT FORGET TO ADD "()" at the end of the method "NEXT".

...
if (myResultSet.next())
...

Cheers
Joe

--- Seshubaba <[EMAIL PROTECTED]> wrote:
> In this case, ResultSet object is created, but it doesn't contain
> any rows.
> Try in this way,
>
>
> Statement stmt=myConn.createStatement();
> ResultSet myResultSet=stmt.executeQuery("select nama from user
> where
> id='"+login+"' and pass='"+pass+"' ");
>
> if (myResultSet.next)
> {
>
>  String nama =  myResultSet.getString("nama");
> %>
> <tr>
>   <td><%= nama %></td>
> </tr>
> <%
>  while ( myResultSet.next() ) {
>  nama= myResultSet.getString("nama");
>  }
>
> %>
> <tr>
>   <td><%= nama %></td>
>   </tr>
>   // memulai session
>   <%
>   session.setAttribute ("user", nama);
>   %>
>   <jsp:forward page="browsevcd.jsp" />
>
> <%
>
> }
> else
> {
> %>
> <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();
> %>
>
>
> -Seshubaba
>
> -----Original Message-----
> From: Isak Rickyanto [mailto:[EMAIL PROTECTED]]
> Sent: Friday, October 26, 2001 3:05 AM
> To: [EMAIL PROTECTED]
> Subject: 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();
> %>
>
>


__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://archives.java.sun.com/jsp-interest.html
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.jsp
 http://www.jguru.com/faq/index.jsp
 http://www.jspinsider.com

Reply via email to