标签:stat pre div cti connect log import etc class
package com.hanqi.dao; import java.sql.Connection; import java.sql.SQLException; //单利模式的数据库工具类 //返回数据连接 import com.mchange.v2.c3p0.ComboPooledDataSource; public class DBHelper { //1.隐藏默认的构造方法 private DBHelper() { } //2.静态的实例 private static DBHelper dh ; //3返回实例的静态方法 public static DBHelper getDBHelper() { if(dh==null) { dh = new DBHelper(); } return dh; } private ComboPooledDataSource cpds = new ComboPooledDataSource("helloc3p0"); //反回连接的方法 public Connection getConnection() throws SQLException { return cpds.getConnection(); } }
标签:stat pre div cti connect log import etc class
原文地址:http://www.cnblogs.com/liuyanzeng/p/6037432.html