01: package org.nemesis.forum.util.jdbc;
02:
03: import java.sql.Connection;
04: import java.sql.DriverManager;
05:
06: import org.apache.commons.logging.Log;
07: import org.apache.commons.logging.LogFactory;
08: import org.nemesis.forum.config.ConfigLoader;
09:
10: /**
11: * @author dlaurent
12: *
13: * 10 févr. 2003
14: * NoPool.java
15: * some jdbc driver have internal pool...
16: */
17: public class NoPool extends DbConnectionProvider {
18:
19: static protected Log log = LogFactory.getLog(NoPool.class);
20:
21: private static final boolean POOLED = false;
22:
23: private static String driver = null;
24: private static String url = null;
25: private static String user = null;
26: private static String pass = null;
27:
28: /**
29: * Returns a database connection.
30: */
31: public Connection getConnection() {
32: try {
33: return DriverManager.getConnection(url, user, pass);
34: } catch (Exception e) {
35: log.error(e);
36: return null;
37: }
38: }
39:
40: protected void start() {
41:
42: driver = ConfigLoader.getInstance().getConfig()
43: .getJDBCProviderProperties().getProperty("driver");
44: url = ConfigLoader.getInstance().getConfig()
45: .getJDBCProviderProperties().getProperty("url");
46: user = ConfigLoader.getInstance().getConfig()
47: .getJDBCProviderProperties().getProperty("username");
48: pass = ConfigLoader.getInstance().getConfig()
49: .getJDBCProviderProperties().getProperty("password");
50:
51: try {
52: Class.forName(driver);
53: } catch (Exception e) {
54: log.fatal("jdbc driver not found:" + driver, e);
55: }
56: return;
57: }
58:
59: protected void restart() {
60: destroy();
61: start();
62: return;
63: }
64:
65: protected void destroy() {
66: return;
67: }
68:
69: }
|