mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improve unpooled statement's performance
This commit is contained in:
@@ -22,9 +22,10 @@ import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.mock.MockDriver;
|
||||
import com.alibaba.druid.mock.MockPreparedStatement;
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
@@ -264,7 +265,7 @@ public class ConnectionTest4 extends TestCase {
|
||||
PreparedStatement stmt = conn.prepareStatement("SELECT 1", ResultSet.TYPE_FORWARD_ONLY,
|
||||
ResultSet.CONCUR_READ_ONLY,
|
||||
ResultSet.HOLD_CURSORS_OVER_COMMIT);
|
||||
Assert.assertEquals(raw, stmt.unwrap(MockPreparedStatement.class));
|
||||
Assert.assertSame(raw, stmt.unwrap(MockPreparedStatement.class));
|
||||
stmt.close();
|
||||
}
|
||||
|
||||
|
||||
@@ -32,19 +32,29 @@ import junit.framework.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import com.alibaba.druid.mock.MockCallableStatement;
|
||||
import com.alibaba.druid.mock.MockConnection;
|
||||
import com.alibaba.druid.pool.DruidConnectionHolder;
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.alibaba.druid.pool.DruidPooledCallableStatement;
|
||||
import com.alibaba.druid.pool.DruidPooledConnection;
|
||||
import com.alibaba.druid.pool.DruidPooledPreparedStatement.PreparedStatementKey;
|
||||
import com.alibaba.druid.pool.PreparedStatementHolder;
|
||||
|
||||
public class PoolableCallableStatementTest extends TestCase {
|
||||
|
||||
protected MockCallableStatement raw;
|
||||
private DruidDataSource dataSource = new DruidDataSource();
|
||||
protected DruidPooledConnection conn;
|
||||
protected MockCallableStatement raw;
|
||||
protected DruidPooledCallableStatement stmt;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
MockConnection mockConn = new MockConnection();
|
||||
DruidConnectionHolder connHolder = new DruidConnectionHolder(dataSource, mockConn);
|
||||
conn = new DruidPooledConnection(connHolder);
|
||||
raw = new MockCallableStatement(null, null);
|
||||
stmt = new DruidPooledCallableStatement(null,
|
||||
new PreparedStatementHolder(new PreparedStatementKey("", null, null, 0, 0, 0), raw)) {
|
||||
stmt = new DruidPooledCallableStatement(conn, new PreparedStatementHolder(new PreparedStatementKey("", null,
|
||||
null, 0, 0,
|
||||
0), raw)) {
|
||||
|
||||
protected SQLException checkException(Throwable error) throws SQLException {
|
||||
if (error instanceof SQLException) {
|
||||
|
||||
@@ -24,23 +24,34 @@ import java.sql.Timestamp;
|
||||
import java.sql.Types;
|
||||
import java.util.Arrays;
|
||||
|
||||
import junit.framework.Assert;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
||||
import com.alibaba.druid.mock.MockConnection;
|
||||
import com.alibaba.druid.mock.MockPreparedStatement;
|
||||
import com.alibaba.druid.pool.DruidConnectionHolder;
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.alibaba.druid.pool.DruidPooledConnection;
|
||||
import com.alibaba.druid.pool.DruidPooledPreparedStatement;
|
||||
import com.alibaba.druid.pool.DruidPooledPreparedStatement.PreparedStatementKey;
|
||||
import com.alibaba.druid.pool.PreparedStatementHolder;
|
||||
|
||||
public class PoolablePreparedStatementTest extends TestCase {
|
||||
|
||||
protected MockPreparedStatement raw;
|
||||
protected MockPreparedStatement raw;
|
||||
protected DruidPooledPreparedStatement stmt;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
DruidDataSource dataSource = new DruidDataSource();
|
||||
MockConnection mockConn = new MockConnection();
|
||||
DruidConnectionHolder connHolder = new DruidConnectionHolder(dataSource, mockConn);
|
||||
DruidPooledConnection conn = new DruidPooledConnection(connHolder);
|
||||
|
||||
raw = new MockPreparedStatement(null, null);
|
||||
stmt = new DruidPooledPreparedStatement(null,
|
||||
new PreparedStatementHolder(new PreparedStatementKey("", null, null, 0, 0, 0), raw)) {
|
||||
stmt = new DruidPooledPreparedStatement(conn, new PreparedStatementHolder(new PreparedStatementKey("", null,
|
||||
null, 0, 0,
|
||||
0), raw)) {
|
||||
|
||||
protected SQLException checkException(Throwable error) throws SQLException {
|
||||
if (error instanceof SQLException) {
|
||||
|
||||
Reference in New Issue
Block a user