Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

creating a forum??

  • 03-04-2006 11:22pm
    #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 Posts: 41,246 Mod ✭✭✭✭Seth Brundle


    Show us your code.


  • 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 Posts: 41,246 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.


  • 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