wangwei 5 years ago
parent
commit
dfd6b2e42b
1 changed files with 15 additions and 2 deletions
  1. 15 2
      src/main/java/cn/com/qmth/examcloud/commons/util/DBUtil.java

+ 15 - 2
src/main/java/cn/com/qmth/examcloud/commons/util/DBUtil.java

@@ -11,6 +11,7 @@ import javax.sql.DataSource;
 
 import org.apache.commons.lang3.StringUtils;
 
+import cn.com.qmth.examcloud.commons.exception.ExamCloudRuntimeException;
 import cn.com.qmth.examcloud.commons.logging.ExamCloudLog;
 import cn.com.qmth.examcloud.commons.logging.ExamCloudLogFactory;
 
@@ -46,9 +47,21 @@ public class DBUtil {
 	public static DataSource initDataSource(final String dataSourceName) {
 		Class<?> c = null;
 		try {
-			c = Class.forName("com.mchange.v2.c3p0.ComboPooledDataSource");
+			c = Class.forName("com.alibaba.druid.pool.DruidDataSource");
 		} catch (ClassNotFoundException e) {
-			throw new RuntimeException(e);
+			// ignore
+		}
+
+		if (null == c) {
+			try {
+				c = Class.forName("com.mchange.v2.c3p0.ComboPooledDataSource");
+			} catch (ClassNotFoundException e) {
+				// ignore
+			}
+		}
+
+		if (null == c) {
+			throw new ExamCloudRuntimeException("no class about dataSource implementation.");
 		}
 
 		@SuppressWarnings("unchecked")