public CourseDAOFactoryImpl(String jdbcDriver, String jdbcURL) throws MyDAOException { this.jdbcDriver = jdbcDriver; this.jdbcURL = jdbcURL; try { BeanTable<Course> table = BeanTable.getSQLInstance(Course.class, "fanc_course", jdbcDriver, jdbcURL); if (!table.exists()) { table.create("courseName"); } factory = table.getFactory(); } catch (BeanFactoryException e) { throw new MyDAOException(e); } }
public synchronized List<Note> getSelectedCourseNotesList(String courseSelected) throws MyDAOException { BeanFactory<Note> factory; ArrayList<Note> al = new ArrayList<Note>(); try { BeanTable<Note> table = BeanTable.getSQLInstance(Note.class, "fanc_note", jdbcDriver, jdbcURL); factory = table.getFactory(); al = new ArrayList( Arrays.asList(factory.match(MatchArg.equals("courseName", courseSelected)))); } catch (RollbackException e) { throw new MyDAOException(e); } return al; }
public CommunityDAO(String jdbcDriver, String jdbcURL, UserDAO userDAO) throws DAOException { try { BeanTable<Community> communityTable = BeanTable.getSQLInstance( Community.class, "team17_community", jdbcDriver, jdbcURL, userDAO.getFactory()); if (!communityTable.exists()) communityTable.create("name"); communityTable.setIdleConnectionCleanup(true); factory = communityTable.getFactory(); } catch (BeanFactoryException e) { throw new DAOException(e); } }
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); } }
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); } }