Help insert SQL query in jsp file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bylum
    New Member
    • Mar 2007
    • 15

    #1

    Help insert SQL query in jsp file

    Kindly please anyone here helps me how to check in my program,

    i want to insert this SQL query to jsp file:

    SELECT COUNT(id) new
    FROM annaudio
    WHERE id NOT IN (
    SELECT annaudio_id FROM annread WHERE annuser_id=1
    )


    and this is my jsp file's script:
    <%
    Class.forName ("org.gjt.mm.my sql.Driver");
    Connection connection = DriverManager.g etConnection("j dbc:mysql://localhost:3306/ann?user=root") ;
    Statement statement = connection.crea teStatement();

    ResultSet rs = statement.execu teQuery("SELECT COUNT(id) FROM annaudio WHERE id NOT IN(SELECT annaudio_id FROM annread WHERE annuser_id=" + "iduser)");

    out.println(rs) ;
    %>

    My problem is how to display my "ResultSet" ??
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by bylum
    Kindly please anyone here helps me how to check in my program,

    i want to insert this SQL query to jsp file:

    SELECT COUNT(id) new
    FROM annaudio
    WHERE id NOT IN (
    SELECT annaudio_id FROM annread WHERE annuser_id=1
    )


    and this is my jsp file's script:
    <%
    Class.forName ("org.gjt.mm.my sql.Driver");
    Connection connection = DriverManager.g etConnection("j dbc:mysql://localhost:3306/ann?user=root") ;
    Statement statement = connection.crea teStatement();

    ResultSet rs = statement.execu teQuery("SELECT COUNT(id) FROM annaudio WHERE id NOT IN(SELECT annaudio_id FROM annread WHERE annuser_id=" + "iduser)");

    out.println(rs) ;
    %>

    My problem is how to display my "ResultSet" ??
    Have a look at the specs for the Result in the Java api and see the methods that are available there. If you don't understand any of them you can always ask here.

    Comment

    Working...