Quellcode durchsuchen

上传文件至 'src/com/person/utils'

1801010606 vor 6 Jahren
Ursprung
Commit
436c4c37d9
1 geänderte Dateien mit 22 neuen und 0 gelöschten Zeilen
  1. 22 0
      src/com/person/utils/DBUtils.java

+ 22 - 0
src/com/person/utils/DBUtils.java

@@ -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();
+	}
+}