|
@@ -0,0 +1,22 @@
|
|
|
|
+package com.person.utils;
|
|
|
|
+
|
|
|
|
+import java.sql.Connection;
|
|
|
|
+import java.sql.SQLException;
|
|
|
|
+
|
|
|
|
+import javax.sql.DataSource;
|
|
|
|
+
|
|
|
|
+import com.mchange.v2.c3p0.ComboPooledDataSource;
|
|
|
|
+
|
|
|
|
+public class DBUtils {
|
|
|
|
+ private static ComboPooledDataSource dataSource = new ComboPooledDataSource();
|
|
|
|
+
|
|
|
|
+ //返回dataSource的方法
|
|
|
|
+ public static DataSource getDataSource() {
|
|
|
|
+ return dataSource;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //返回数据库的连接
|
|
|
|
+ public static Connection getConnection() throws SQLException {
|
|
|
|
+ return dataSource.getConnection();
|
|
|
|
+ }
|
|
|
|
+}
|