|
@@ -5,34 +5,26 @@ import java.sql.PreparedStatement;
|
|
|
import java.sql.ResultSet;
|
|
|
import java.sql.SQLException;
|
|
|
|
|
|
-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;
|
|
|
+import cn.com.qmth.examcloud.bridge.commons.BridgeDataSource;
|
|
|
+import cn.com.qmth.examcloud.bridge.commons.BridgeDatabaseUtil;
|
|
|
|
|
|
@Component
|
|
|
public class Tester {
|
|
|
|
|
|
public void test() {
|
|
|
- testJdbc(ComboPooledDataSource.class, "ds1");
|
|
|
- testJdbc(DruidDataSource.class, "ds1");
|
|
|
+ testJdbc();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 测试JDBC
|
|
|
*
|
|
|
* @author WANGWEI
|
|
|
- * @param implementation
|
|
|
- * @param dataSourceName
|
|
|
*/
|
|
|
- private void testJdbc(Class<? extends DataSource> implementation, final String dataSourceName) {
|
|
|
+ private void testJdbc() {
|
|
|
try {
|
|
|
- DataSource ds1 = DBUtil.initDataSource(implementation, "ds1");
|
|
|
- Connection conn = ds1.getConnection();
|
|
|
+ Connection conn = BridgeDatabaseUtil.getConnection(BridgeDataSource.EXAM_CLOUD);
|
|
|
PreparedStatement ps = conn.prepareStatement("select 'jdbc test' from dual");
|
|
|
ResultSet rs = ps.executeQuery();
|
|
|
|