forked from LogBlock/LogBlock
Removed timeout
This commit is contained in:
@@ -21,8 +21,6 @@ import java.util.Enumeration;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.concurrent.TimeoutException;
|
|
||||||
import java.util.concurrent.locks.Lock;
|
import java.util.concurrent.locks.Lock;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
@@ -57,13 +55,12 @@ public class MySQLConnectionPool implements Closeable
|
|||||||
lock.unlock();
|
lock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Connection getConnection() throws SQLException, InterruptedException, TimeoutException {
|
public Connection getConnection() throws SQLException {
|
||||||
if (!lock.tryLock(3000, TimeUnit.MILLISECONDS))
|
lock.lock();
|
||||||
throw new TimeoutException();
|
|
||||||
try {
|
try {
|
||||||
JDCConnection conn;
|
final Enumeration<JDCConnection> conns = connections.elements();
|
||||||
for (int i = 0; i < connections.size(); i++) {
|
while (conns.hasMoreElements()) {
|
||||||
conn = connections.get(i);
|
final JDCConnection conn = conns.nextElement();
|
||||||
if (conn.lease()) {
|
if (conn.lease()) {
|
||||||
if (conn.isValid())
|
if (conn.isValid())
|
||||||
return conn;
|
return conn;
|
||||||
@@ -71,7 +68,7 @@ public class MySQLConnectionPool implements Closeable
|
|||||||
conn.terminate();
|
conn.terminate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
conn = new JDCConnection(DriverManager.getConnection(url, user, password));
|
final JDCConnection conn = new JDCConnection(DriverManager.getConnection(url, user, password));
|
||||||
conn.lease();
|
conn.lease();
|
||||||
if (!conn.isValid()) {
|
if (!conn.isValid()) {
|
||||||
conn.terminate();
|
conn.terminate();
|
||||||
|
Reference in New Issue
Block a user