1 43 package net.jforum; 44 45 import java.sql.Connection ; 46 import java.sql.DriverManager ; 47 48 import net.jforum.exceptions.DatabaseException; 49 import net.jforum.util.preferences.ConfigKeys; 50 import net.jforum.util.preferences.SystemGlobals; 51 52 63 public class SimpleConnection extends DBConnection 64 { 65 68 public void init() throws Exception 69 { 70 try { 71 Class.forName(SystemGlobals.getValue(ConfigKeys.DATABASE_CONNECTION_DRIVER)); 72 73 Connection conn = this.getConnection(); 75 if (conn != null) { 76 this.releaseConnection(conn); 77 } 78 79 this.isDatabaseUp = true; 80 } 81 catch (Exception e) { 82 this.isDatabaseUp = false; 83 throw e; 84 } 85 } 86 87 90 public Connection getConnection() 91 { 92 try { 93 return DriverManager.getConnection(SystemGlobals.getValue(ConfigKeys.DATABASE_CONNECTION_STRING)); 94 } 95 catch (Exception e) { 96 e.printStackTrace(); 97 throw new DatabaseException(e); 98 } 99 } 100 101 104 public void releaseConnection(Connection conn) 105 { 106 try { 107 conn.close(); 108 } 109 catch (Exception e) {} 110 } 111 112 115 public void realReleaseAllConnections() throws Exception {} 116 } 117 | Popular Tags |