Results 1 to 3 of 3
  1. #1
    Haresh gurav is offline Member
    Join Date
    Jul 2008
    Posts
    1
    Rep Power
    0

    Default Displaying data from mysql database.

    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 abovered color line
    can anybody have solution for above or any alternative code.
    Thanks and regards
    Haresh

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    8

    Default

    Define your statement and don't use scriptlets in JSP (they're only really still there for backwards compatability use a bean).

  3. #3
    Eku
    Eku is offline Senior Member
    Join Date
    May 2008
    Location
    Makati, Philippines
    Posts
    234
    Rep Power
    6

    Default

    where is your driver?
    where is the connection string? You dont even have a connection. ^_^

    And as masijade said, please avoid using scriptlets. You can also use Servlets ^_^
    Mind only knows what lies near the heart, it alone sees the depth of the soul.

Similar Threads

  1. database with mysql using the netbeans 6.0
    By kwesiaryee in forum New To Java
    Replies: 2
    Last Post: 05-02-2008, 04:27 AM
  2. MySQL Database and Java
    By shaggymac in forum Advanced Java
    Replies: 1
    Last Post: 05-01-2008, 09:01 PM
  3. Help needed with updating mysql database
    By SilentCodingOne in forum New To Java
    Replies: 1
    Last Post: 12-11-2007, 10:23 PM
  4. connecting to mysql database
    By javagal in forum NetBeans
    Replies: 2
    Last Post: 08-04-2007, 12:36 PM
  5. Displaying different columns with database query
    By jennybgh in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 08-02-2007, 05:04 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •