Example #1
0
  public static void main(String args[]) {
    Connection conn = null;
    Statement stmt = null;
    try {
      conn = getConnection();
      stmt = conn.createStatement();
      stmt.executeUpdate(USER_TABLE);
      stmt.executeUpdate(PUBLICATION_TABLE);
      stmt.executeUpdate(AUTHOR_TABLE);
      stmt.executeUpdate(PUBLICATION_AUTHOR_TABLE);
      stmt.executeUpdate(ARTICLE_TABLE);
      stmt.executeUpdate(BOOK_TABLE);
      stmt.executeUpdate(THESIS_TABLE);
      stmt.executeUpdate(EDITOR_TABLE);
      stmt.executeUpdate(EDITOR_PUBLICATION_TABLE);
      stmt.executeUpdate(SCHOOL_TABLE);
      stmt.executeUpdate(SCHOOL_THESIS_TABLE);

      stmt.executeUpdate("insert into User(email, password) values('rootemail', 'rootpassword')");
      // stmt.executeUpdate("insert into MyEmployees3(id, firstName) values(200, 'B')");
      ReadXMLFile(stmt);
      System.out.println("CreateEmployeeTableMySQL: main(): table created.");
    } catch (ClassNotFoundException e) {
      System.out.println("error: failed to load MySQL driver.");
      e.printStackTrace();
    } catch (SQLException e) {
      System.out.println("error: failed to create a connection object.");
      e.printStackTrace();
    } catch (Exception e) {
      System.out.println("other error:");
      e.printStackTrace();
    } finally {
      try {
        stmt.close();
        conn.close();
      } catch (SQLException e) {
        e.printStackTrace();
      }
    }
  }