Menu

Database error: unable to create Events table

Help
2003-10-12
2003-10-23
  • Pablo Moreno

    Pablo Moreno - 2003-10-12

    Let's say the whole application is compiled correctly. Let's say that I am able to browse in all section (uploads, contents etc.), BUT, when I try to join the calendar section I have the following situation:

    FIRST ATTEMPT (Previous step made: The database is totally empty , after I have successfully registered the first teacher, I set the home page to show the calendar link and I try to enter the calendar section):

    Entering the calendar section I have a very little calendar WITHOUT the days field (as i saw in the demo version of your site), say that I have a calendar like this:

    <-settembre   Calendar for ottobre 2003     novembre &#8212;>
               Sun Mon Tue Wed Thu Fri Sat
          New Calendar Events table created. Please refresh this page to view.
               <&#8212; agosto Go To Current Month ottobre &#8212;>

    So I refresh the page as the system asks me

    And I have:

    Database error: unable to create Events table. null
    <&#8212; settembre estarteacher Calendar for ottobre 2003 novembre &#8212;>
                  Sun Mon Tue Wed Thu Fri Sat
    <&#8212; agosto      Go To Current Month     ottobre &#8212;>

    At this point the doubt is: Was the servlet able to create the events table?
    So I open mysq to check this and I have:

    mysql> SHOW TABLES;
    +------------------------+
    | Tables_in_estarteacher |
    +------------------------+
    | courseparameters       |
    | coursesections         |
    | events                 |
    | loggingparameters      |
    | navbarlinks            |
    | students               |
    | templateitems          |
    | templatepages          |
    | templatesections       |
    | webpages               |
    +------------------------+
    10 rows in set (0.00 sec)

    Yes! There's!

    But I want to be sure:

    mysql> DESCRIBE events
        -> DESCRIBE events;
    ERROR 1064: You have an error in your SQL syntax.  Check the manual that corresponds
    to your MySQL server version for the right syntax to use near 'DESCRIBE events
    nts' at line 2
    mysql> DESCRIBE events;
    +-------------+-------------+------+-----+---------+----------------+
    | Field       | Type        | Null | Key | Default | Extra          |
    +-------------+-------------+------+-----+---------+----------------+
    | EventID     | int(11)     |      | PRI | NULL    | auto_increment |
    | Sdate       | datetime    | YES  |     | NULL    |                |
    | Edate       | datetime    | YES  |     | NULL    |                |
    | User        | varchar(50) | YES  |     | NULL    |                |
    | Description | text        | YES  |     | NULL    |                |
    | Notes       | text        | YES  |     | NULL    |                |
    | Flagged     | int(11)     | YES  |     | NULL    |                |
    | Section     | char(3)     | YES  |     | 1       |                |
    +-------------+-------------+------+-----+---------+----------------+
    8 rows in set (0.01 sec)

    (I don't understand the reason of which sometimes I have to write the commands two times in order to mysql accepts them...but I don't think it can depends on this).

    So, before asking to the kind programmer of this application, I try to check Calendar.java in order to understand where the error occurs, and I have two principal method the first (placed on row 565 of Calendar.java)create the events table:

    boolean createEventsTable() {
        try {
          Class.forName(mySqlJdbcDriver).newInstance();
          Connection conn = DriverManager.getConnection(Course.dbName,Course.mySQLUser,Course.mySQLPass);
          Statement stmt = conn.createStatement();
          stmt.executeUpdate("CREATE TABLE Events (EventID INT PRIMARY KEY AUTO_INCREMENT,"
          + "Sdate DATETIME,Edate DATETIME,User VARCHAR(50),Description TEXT,Notes TEXT,Flagged INT,Section VARCHAR(3) DEFAULT '1')");
          return true;
        }
        catch (Exception e) {
          return false;
        }
      }

    it throws a boolean that is caught from this other snips of code (placed on rows 230/231)

    if (createEventsTable()) return "<tr><td COLSPAN=7>" + res.getString("str_table_made")+"</td></tr>";
         
    else return res.getString("str_error_db") + e.getMessage();

    I think that the application drops on rows 231, but I can't imagine the reason (I didn't touch anything of Calendar.java neither the related resource bundle except for the package name).

    Thanks in advance for the help, I am finishing to translating the whole project in Italian ('cause teacher asked me to translate in Italian as I know It).

     
    • Robert D. Zeigler

      It's a null pointer exception. It's fixed in the cvs version of eledge (soon to e released as eledge 3.1.0 =) Try dling the cvs version of calendar and using that

      robert

       
    • Pablo Moreno

      Pablo Moreno - 2003-10-13

      Thanks for the reply, but

      How can I obtain the cvs version of calendar? How long does it take to complete it?

      Thanks in advance

       
    • Robert D. Zeigler

      There should be a link to "CVS"... you can browse the cvs repository from that page, and go to calendar to get the version that you want. Hm. Actually, let me just e-mail you the revision that you want. ;) The latest revision of Calendar.java would give you compile errors, so... ;) I'll send Calendar.java your way. =) Then you can just drop the new file into your existing directory (rename the package if necessary), recompile, and, voila, you should be good to go. =)

       
    • Pablo Moreno

      Pablo Moreno - 2003-10-14

      Dear Robert

      Thanks for your precious help! My email is: winpass1@inwind.it        
      thank you very much and I hope my efforts will contribute to eledge community!

       
    • Robert D. Zeigler

      Incidentally.... eledge 3.1.0 has been released, if  you hadn't noticed... you might consider taking a look... it has a nifty new TA system... and other new and improved stuff, too. ;)

       

Log in to post a comment.

MongoDB Logo MongoDB