mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
dup close log configuable
This commit is contained in:
@@ -192,6 +192,18 @@ public abstract class DruidAbstractDataSource extends WrapperAdapter implements
|
||||
10 * 1000,
|
||||
100 * 1000);
|
||||
|
||||
private boolean dupCloseLogEnable = true;
|
||||
|
||||
|
||||
public boolean isDupCloseLogEnable() {
|
||||
return dupCloseLogEnable;
|
||||
}
|
||||
|
||||
public void setDupCloseLogEnable(boolean dupCloseLogEnable) {
|
||||
this.dupCloseLogEnable = dupCloseLogEnable;
|
||||
}
|
||||
|
||||
|
||||
public Histogram getTransactionHistogram() {
|
||||
return transactionHistogram;
|
||||
}
|
||||
|
||||
@@ -56,10 +56,12 @@ public class PoolableConnection implements PooledConnection, Connection {
|
||||
protected Connection conn;
|
||||
protected ConnectionHolder holder;
|
||||
protected TransactionInfo transactionInfo;
|
||||
private final boolean dupCloseLogEnable;
|
||||
|
||||
public PoolableConnection(ConnectionHolder holder){
|
||||
this.conn = holder.getConnection();
|
||||
this.holder = holder;
|
||||
dupCloseLogEnable = holder.getDataSource().isDupCloseLogEnable();
|
||||
}
|
||||
|
||||
public SQLException handleException(Throwable t) throws SQLException {
|
||||
@@ -115,7 +117,7 @@ public class PoolableConnection implements PooledConnection, Connection {
|
||||
public void close() throws SQLException {
|
||||
ConnectionHolder holder = this.holder;
|
||||
|
||||
if (holder == null) {
|
||||
if (holder == null && dupCloseLogEnable) {
|
||||
LOG.error("dup close");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -16,9 +16,9 @@
|
||||
package com.alibaba.druid.pool.benckmark;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.text.NumberFormat;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
@@ -37,7 +37,7 @@ public class Oracle_Case0 extends TestCase {
|
||||
private String user;
|
||||
private String password;
|
||||
private String driverClass;
|
||||
private int initialSize = 10;
|
||||
private int initialSize = 1;
|
||||
private int minPoolSize = 1;
|
||||
private int maxPoolSize = 2;
|
||||
private int maxActive = 2;
|
||||
@@ -126,8 +126,8 @@ public class Oracle_Case0 extends TestCase {
|
||||
final int COUNT = 1000 * 1;
|
||||
for (int i = 0; i < COUNT; ++i) {
|
||||
Connection conn = dataSource.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
ResultSet rs = stmt.executeQuery("SELECT 1 FROM DUAL");
|
||||
PreparedStatement stmt = conn.prepareStatement("SELECT 1 FROM DUAL");
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
rs.close();
|
||||
stmt.close();
|
||||
|
||||
Reference in New Issue
Block a user