1 43 package net.jforum; 44 45 import java.sql.Connection ; 46 47 import org.apache.log4j.Logger; 48 49 import net.jforum.dao.CategoryDAO; 50 import net.jforum.dao.ConfigDAO; 51 import net.jforum.dao.DataAccessDriver; 52 import net.jforum.dao.ForumDAO; 53 import net.jforum.exceptions.DatabaseException; 54 import net.jforum.exceptions.RepositoryStartupException; 55 import net.jforum.repository.ForumRepository; 56 57 61 public class ForumStartup 62 { 63 64 private static final Logger log = Logger.getLogger(ForumStartup.class); 65 66 71 public static boolean startDatabase() 72 { 73 try { 74 if (DBConnection.createInstance()) { 75 DBConnection.getImplementation().init(); 76 77 Connection conn = DBConnection.getImplementation().getConnection(); 79 DBConnection.getImplementation().releaseConnection(conn); 80 } 81 } 82 catch (Exception e) { 83 throw new DatabaseException("Error while trying to start the database: " + e, e); 84 } 85 86 return true; 87 } 88 89 93 public static void startForumRepository() 94 { 95 try { 96 ForumDAO fm = DataAccessDriver.getInstance().newForumDAO(); 97 CategoryDAO cm = DataAccessDriver.getInstance().newCategoryDAO(); 98 ConfigDAO configModel = DataAccessDriver.getInstance().newConfigDAO(); 99 100 ForumRepository.start(fm, cm, configModel); 101 } 102 catch (Exception e) { 103 log.error("Unable to bootstrap JForum repository.", e); 104 throw new RepositoryStartupException("Error while trying to start ForumRepository: " + e, e); 105 } 106 } 107 } 108 | Popular Tags |