1 2 package org.nemesis.forum.util.jdbc; 3 4 import java.sql.Connection ; 5 import java.sql.DriverManager ; 6 7 import org.apache.commons.logging.Log; 8 import org.apache.commons.logging.LogFactory; 9 import org.nemesis.forum.config.ConfigLoader; 10 11 18 public class NoPool extends DbConnectionProvider { 19 20 static protected Log log =LogFactory.getLog(NoPool.class); 21 22 private static final boolean POOLED = false; 23 24 private static String driver=null; 25 private static String url=null; 26 private static String user=null; 27 private static String pass=null; 28 29 30 31 32 35 public Connection getConnection() { 36 try { 37 return DriverManager.getConnection( 38 url, 39 user, 40 pass); 41 } catch (Exception e) { 42 log.error(e); 43 return null; 44 } 45 } 46 47 protected void start() { 48 49 driver= ConfigLoader.getInstance().getConfig().getJDBCProviderProperties().getProperty("driver"); 50 url=ConfigLoader.getInstance().getConfig().getJDBCProviderProperties().getProperty("url"); 51 user=ConfigLoader.getInstance().getConfig().getJDBCProviderProperties().getProperty("username"); 52 pass=ConfigLoader.getInstance().getConfig().getJDBCProviderProperties().getProperty("password"); 53 54 try { 55 Class.forName(driver); 56 } catch (Exception e) { 57 log.fatal("jdbc driver not found:"+driver,e); 58 } 59 return; 60 } 61 62 63 protected void restart() { 64 destroy(); 65 start(); 66 return; 67 } 68 69 protected void destroy() { 70 return; 71 } 72 73 } 74 | Popular Tags |