mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
improved performance for large parameters.
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
package com.alibaba.druid.bvt.proxy;
|
||||
|
||||
import com.alibaba.druid.proxy.jdbc.JdbcParameter;
|
||||
import com.alibaba.druid.proxy.jdbc.PreparedStatementProxyImpl;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
/**
|
||||
* Created by wenshao on 12/07/2017.
|
||||
*/
|
||||
public class InsertValues extends TestCase {
|
||||
public void test_insert_values() throws Exception {
|
||||
String sql = "insert into t (f0, f1, f2, f3, f4) values ";
|
||||
for (int i = 0; i < 1000; ++i) {
|
||||
if (i != 0) {
|
||||
sql += ", (?, ?, ?, ?, ?)";
|
||||
} else {
|
||||
sql += "(?, ?, ?, ?, ?)";
|
||||
}
|
||||
}
|
||||
|
||||
PreparedStatementProxyImpl proxy = new PreparedStatementProxyImpl(null, null, sql, 0);
|
||||
|
||||
Field field = PreparedStatementProxyImpl.class.getDeclaredField("parameters");
|
||||
field.setAccessible(true);
|
||||
JdbcParameter[] params = (JdbcParameter[]) field.get(proxy);
|
||||
assertEquals(5000, params.length);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.alibaba.druid.bvt.proxy;
|
||||
|
||||
import com.alibaba.druid.proxy.jdbc.JdbcParameter;
|
||||
import com.alibaba.druid.proxy.jdbc.PreparedStatementProxyImpl;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
/**
|
||||
* Created by wenshao on 12/07/2017.
|
||||
*/
|
||||
public class InsertValues_1 extends TestCase {
|
||||
public void test_insert_values() throws Exception {
|
||||
String sql = "insert into t (f0, f1, f2, f3, f4) values ('????????????????????????', '????????????????????????', '????????????????????????', '????????????????????????', '????????????????????????')";
|
||||
|
||||
|
||||
PreparedStatementProxyImpl proxy = new PreparedStatementProxyImpl(null, null, sql, 0);
|
||||
|
||||
Field field = PreparedStatementProxyImpl.class.getDeclaredField("parameters");
|
||||
field.setAccessible(true);
|
||||
JdbcParameter[] params = (JdbcParameter[]) field.get(proxy);
|
||||
assertEquals(0, params.length);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.alibaba.druid.bvt.proxy;
|
||||
|
||||
import com.alibaba.druid.proxy.jdbc.JdbcParameter;
|
||||
import com.alibaba.druid.proxy.jdbc.PreparedStatementProxyImpl;
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
/**
|
||||
* Created by wenshao on 12/07/2017.
|
||||
*/
|
||||
public class InsertValues_2 extends TestCase {
|
||||
public void test_insert_values() throws Exception {
|
||||
String sql = "insert into t (f0, f1, f2, f3, f4) values (\"????????????????????????\", \"????????????????????????\", \"????????????????????????\", \"????????????????????????\", \"????????????????????????\")";
|
||||
|
||||
|
||||
PreparedStatementProxyImpl proxy = new PreparedStatementProxyImpl(null, null, sql, 0);
|
||||
|
||||
Field field = PreparedStatementProxyImpl.class.getDeclaredField("parameters");
|
||||
field.setAccessible(true);
|
||||
JdbcParameter[] params = (JdbcParameter[]) field.get(proxy);
|
||||
assertEquals(0, params.length);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user