1 43 package net.jforum; 44 45 import java.sql.Connection ; 46 47 import net.jforum.util.preferences.ConfigKeys; 48 import net.jforum.util.preferences.SystemGlobals; 49 50 import org.apache.log4j.Logger; 51 52 62 public abstract class DBConnection 63 { 64 private static final Logger logger = Logger.getLogger(DBConnection.class); 65 protected boolean isDatabaseUp; 66 67 private static DBConnection instance; 68 69 75 public static final boolean createInstance() 76 { 77 try { 78 instance = (DBConnection)Class.forName(SystemGlobals.getValue( 79 ConfigKeys.DATABASE_CONNECTION_IMPLEMENTATION)).newInstance(); 80 } 81 catch (Exception e) { 82 logger.warn("Error creating the database connection implementation instance. " + e); 83 e.printStackTrace(); 84 return false; 85 } 86 87 return true; 88 } 89 90 95 public static DBConnection getImplementation() 96 { 97 return instance; 98 } 99 100 106 public boolean isDatabaseUp() 107 { 108 return this.isDatabaseUp; 109 } 110 111 121 public abstract void init() throws Exception ; 122 123 133 public abstract Connection getConnection(); 134 135 144 public abstract void releaseConnection(Connection conn); 145 146 151 public abstract void realReleaseAllConnections() throws Exception ; 152 } 153 | Popular Tags |