mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
数据连接建立时,执行validateConnection操作
git-svn-id: http://code.alibabatech.com/svn/druid/trunk@207 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
@@ -17,7 +17,6 @@ package com.alibaba.druid.pool;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.Driver;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
@@ -181,30 +180,6 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
|
||||
return this.activeConnections.keySet();
|
||||
}
|
||||
|
||||
private boolean testConnection(Connection conn) {
|
||||
String query = getValidationQuery();
|
||||
if (query == null || query.length() == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Statement stmt = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
stmt = conn.createStatement();
|
||||
rs = stmt.executeQuery(query);
|
||||
if (rs.next()) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
return false;
|
||||
} finally {
|
||||
JdbcUtils.close(rs);
|
||||
JdbcUtils.close(stmt);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Connection getConnection() throws SQLException {
|
||||
init();
|
||||
|
||||
Reference in New Issue
Block a user