Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

creating a forum??

  • 04-04-2006 12:22AM
    #1
    Closed Accounts Posts: 18


    ok guys i am creating a message forum (trying any way), i have an oracle database with message,username, and message date, i'm trying to get this to loop on a jsp page that will loop and create and display my forum, i have it displaying once but when i use a for loop it just screws up and exits tomcat any ideas?


Comments

  • Moderators, Politics Moderators, Paid Member Posts: 44,249 Mod ✭✭✭✭Seth Brundle


    Show us your code.

    Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/ .



  • Closed Accounts Posts: 18 piemaster


    <% myForm1.forumFill();
    for(int i = 0; i < myForm1.getforumcount();i++)
    { %>
    <tr>
    <td width="102" height="84" bordercolor="#000000" background="pics/background.gif" bgcolor="#FFFFFF"><img name="" src="" width="102" height="99" alt="">1</td>
    <td width="17" valign="top" background="pics/background.gif" bgcolor="#D9EDF5"><p><%= myForm1.getusername1()%> </p>
    <p><%=myForm1.getmesdate1()%> </p>
    <p> </p></td>
    <td width="590" valign="top" background="pics/background.gif" bgcolor="#D9EDF5"><%= myForm1.getmessage1()%>
    <%myForm1.forumnext(); }%></td>
    </tr>



    public int getforumcount()
    {
    try
    {
    Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
    forumRset1 = stmt.executeQuery("SELECT count(post_id) from forum");


    postcount = forumRset1.getInt(1);
    }
    catch (SQLException e)
    {
    System.out.print("SQL Exception " + e);
    System.exit(1);
    }
    System.out.print(postcount);
    return postcount;

    }

    }
    public ResultSet forumRset,forumRset1;
    int postcount;
    String username1;
    String message1;
    Date mesdate1;

    public void setusername1(String name){username1 = name;}
    public void setmessage1(String message){message1 = message;}
    public void setmesdate1(Date mesdate){mesdate1 = mesdate;}


    public String getusername1(){return username1;}
    public String getmessage1(){return message1;}
    public Date getmesdate1(){return mesdate1;}



    public void forumFill()
    {

    try
    {
    Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
    forumRset = stmt.executeQuery("SELECT * from forum_post_view");
    forumRset.first();
    forumwrap();




    }
    catch (SQLException e)
    {
    System.out.print("SQL Exception " + e);
    System.exit(1);
    }


    }
    public void forumnext()
    {
    try
    {
    forumRset.next();
    forumwrap();
    }
    catch (SQLException e)
    {
    System.out.print("SQL Exception " + e);
    System.exit(1);
    }
    }


    public void forumwrap()
    {
    try
    {
    setusername1(forumRset.getString(1));
    setmessage1(forumRset.getString(2));
    setmesdate1(forumRset.getDate(3));

    }
    catch (SQLException e)
    {
    System.out.print("SQL Exception " + e);
    System.exit(1);
    }
    }


  • Moderators, Politics Moderators, Paid Member Posts: 44,249 Mod ✭✭✭✭Seth Brundle


    1. use the code tags when inserting code - can make it easier to read.
    2. I glanced through your code and there are a few initial things:-
    * the closing tr & td tags are outside of the loop
    * there are two closing braces used after postcount and there may be others but Im in a bit of a hurry to try indenting the code.

    Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/ .



  • Closed Accounts Posts: 18 piemaster


    ok well ih vae got it working now and its displaying the forum, but when i post a message and go to redisplay the forum page it throws up an error saying the connection is clossed, any ideas on whats wrong? (i'm not closing the connection at any point)


Advertisement