|
@@ -9,6 +9,7 @@ import javax.sql.DataSource;
|
|
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
+import com.alibaba.druid.pool.DruidDataSource;
|
|
|
import com.mchange.v2.c3p0.ComboPooledDataSource;
|
|
|
|
|
|
import cn.com.qmth.examcloud.commons.util.DBUtil;
|
|
@@ -18,6 +19,7 @@ public class Tester {
|
|
|
|
|
|
public void test() {
|
|
|
testJdbc(ComboPooledDataSource.class, "ds1");
|
|
|
+ testJdbc(DruidDataSource.class, "ds1");
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -29,9 +31,9 @@ public class Tester {
|
|
|
*/
|
|
|
private void testJdbc(Class<? extends DataSource> implementation, final String dataSourceName) {
|
|
|
try {
|
|
|
- DataSource ds1 = DBUtil.initDataSource("ds1");
|
|
|
+ DataSource ds1 = DBUtil.initDataSource(implementation, "ds1");
|
|
|
Connection conn = ds1.getConnection();
|
|
|
- PreparedStatement ps = conn.prepareStatement("select 10 from dual");
|
|
|
+ PreparedStatement ps = conn.prepareStatement("select 'jdbc test' from dual");
|
|
|
ResultSet rs = ps.executeQuery();
|
|
|
|
|
|
while (rs.next()) {
|