示例#1
0
  public UserDAO() throws DAOException {
    try {
      BeanTable<UserBean> userTable = BeanTable.getInstance(UserBean.class, "onCampusUsers");

      if (!userTable.exists()) userTable.create("userID");

      // Long running web apps need to clean up idle database connections.
      // So we can tell each BeanTable to clean them up.  (You would only notice
      // a problem after leaving your web app running for several hours.)
      userTable.setIdleConnectionCleanup(true);

      // Get a BeanFactory which the actions will use to read and write rows of the "user" table
      factory = userTable.getFactory();
    } catch (BeanFactoryException e) {
      throw new DAOException(e);
    }
  }
示例#2
0
  public EventDAO() throws DAOException {
    try {
      // Get a BeanTable to create the "photo" table
      BeanTable<EventBean> eventTable = BeanTable.getInstance(EventBean.class, "events");

      if (!eventTable.exists()) eventTable.create("eventid");

      // Long running web apps need to clean up idle database connections.
      // So we can tell each BeanTable to clean them up.  (You would only notice
      // a problem after leaving your web app running for several hours.)
      eventTable.setIdleConnectionCleanup(true);

      // Get a BeanFactory which the actions will use to read and write
      // rows of the "photo" table
      factory = eventTable.getFactory();
    } catch (BeanFactoryException e) {
      throw new DAOException(e);
    }
  }