Displaying data from mysql database.

Discussion in 'JSP' started by guravharsha, Jul 8, 2008.

  1. guravharsha

    guravharsha New Member

    Joined:
    Jun 10, 2008
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Hi,
    In main.jsp i wish to display the data from the database( user information stored in user table ). my codein main.jsp is:

    <h2> description about user:</h2>
    <% Statement st = null;
    ResultSet rs = null;

    rs = st.executeQuery("Select description from user ");
    %>
    <option value = "<%=rs.getString("description")%>" >
    </option>
    when i run the above code it shows the error:
    java.lang.NullPointerException
    org.apache.jsp.main_jsp._jspService(main_jsp.java:72)
    like at above red color line
    can anybody have solution for above or any alternative code.
    Thanks and regards
    Haresh
     
  2. XXxxImmortalxxXX

    XXxxImmortalxxXX New Member

    Joined:
    Jun 27, 2007
    Messages:
    561
    Likes Received:
    19
    Trophy Points:
    0
    well you are calling the method on an object (st) reference set to NULL doesnt make any sense to me
    that code is going to throw a NullPointerException.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice