mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
format code
git-svn-id: http://code.alibabatech.com/svn/druid/trunk@527 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
@@ -40,7 +40,8 @@ public class TestReplaceLicense extends TestCase {
|
||||
reader.close();
|
||||
System.out.println(license);
|
||||
|
||||
lineSeparator = "\n"; //(String) java.security.AccessController.doPrivileged(new sun.security.action.GetPropertyAction("line.separator"));
|
||||
lineSeparator = "\n"; // (String) java.security.AccessController.doPrivileged(new
|
||||
// sun.security.action.GetPropertyAction("line.separator"));
|
||||
}
|
||||
|
||||
public void test_0() throws Exception {
|
||||
|
||||
@@ -16,9 +16,9 @@ public class TestTraceFilter extends TestCase {
|
||||
DruidDataSource dataSource = new DruidDataSource();
|
||||
dataSource.setFilters("stat,trace");
|
||||
dataSource.setUrl("jdbc:mock:");
|
||||
|
||||
|
||||
JMXUtils.register("com.alibaba.dragoon:type=JdbcTraceManager", JdbcTraceManager.getInstance());
|
||||
|
||||
|
||||
for (int i = 0; i < 1000; ++i) {
|
||||
Connection conn = dataSource.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
@@ -27,7 +27,7 @@ public class TestTraceFilter extends TestCase {
|
||||
rs.close();
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
||||
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,8 +98,8 @@ public class BenchmarkExecutor {
|
||||
}
|
||||
|
||||
NumberFormat format = NumberFormat.getInstance();
|
||||
System.out.println("SUM\t" + benchmarkCase.getName() + "\t" + sqlExec.getName() + "\t" + format.format(millis) + "\tYoungGC " + youngGC + "\tFullGC "
|
||||
+ fullGC);
|
||||
System.out.println("SUM\t" + benchmarkCase.getName() + "\t" + sqlExec.getName() + "\t" + format.format(millis)
|
||||
+ "\tYoungGC " + youngGC + "\tFullGC " + fullGC);
|
||||
}
|
||||
|
||||
public void handleResult(SQLExecutor sqlExec, Result result) {
|
||||
@@ -108,8 +108,8 @@ public class BenchmarkExecutor {
|
||||
return;
|
||||
}
|
||||
NumberFormat format = NumberFormat.getInstance();
|
||||
System.out.println(result.getName() + "\t" + sqlExec.getName() + "\t" + format.format(result.getMillis()) + "\tYoungGC " + result.getYoungGC()
|
||||
+ "\tFullGC " + result.getFullGC());
|
||||
System.out.println(result.getName() + "\t" + sqlExec.getName() + "\t" + format.format(result.getMillis())
|
||||
+ "\tYoungGC " + result.getYoungGC() + "\tFullGC " + result.getFullGC());
|
||||
}
|
||||
|
||||
private Result executeLoop(SQLExecutor sqlExec, BenchmarkCase benchmarkCase) {
|
||||
|
||||
@@ -39,7 +39,8 @@ public class SelectEmptyTable extends BenchmarkCase {
|
||||
|
||||
tableName = "T_" + System.currentTimeMillis();
|
||||
|
||||
createTableSql = "CREATE TABLE " + tableName + "(F1 INT, F2 INT, F3 INT, F4 INT, F5 INT, F6 INT, F7 INT, F8 INT, F9 INT)";
|
||||
createTableSql = "CREATE TABLE " + tableName
|
||||
+ "(F1 INT, F2 INT, F3 INT, F4 INT, F5 INT, F6 INT, F7 INT, F8 INT, F9 INT)";
|
||||
dropTableSql = "DROP TABLE " + tableName;
|
||||
sql = "SELECT * FROM T_" + tableName;
|
||||
}
|
||||
|
||||
@@ -51,57 +51,57 @@ public class MockExecuteTest extends TestCase {
|
||||
stmt.close();
|
||||
conn.close();
|
||||
}
|
||||
|
||||
|
||||
public void test_3() throws Exception {
|
||||
Connection conn = DriverManager.getConnection("jdbc:mock:");
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
|
||||
ResultSet rs = stmt.executeQuery("SELECT NOW() FROM DUAL");
|
||||
Assert.assertTrue(rs.next());
|
||||
Assert.assertTrue(rs.getObject(1) instanceof Timestamp);
|
||||
rs.close();
|
||||
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
}
|
||||
|
||||
|
||||
public void test_4() throws Exception {
|
||||
Connection conn = DriverManager.getConnection("jdbc:mock:");
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
|
||||
ResultSet rs = stmt.executeQuery("SELECT 'ABCDE' FROM DUAL");
|
||||
Assert.assertTrue(rs.next());
|
||||
Assert.assertEquals("ABCDE", rs.getString(1));
|
||||
rs.close();
|
||||
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
}
|
||||
|
||||
|
||||
public void test_5() throws Exception {
|
||||
Connection conn = DriverManager.getConnection("jdbc:mock:");
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
|
||||
ResultSet rs = stmt.executeQuery("SELECT true FROM DUAL");
|
||||
Assert.assertTrue(rs.next());
|
||||
Assert.assertEquals(true, rs.getBoolean(1));
|
||||
|
||||
|
||||
rs.close();
|
||||
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
}
|
||||
|
||||
|
||||
public void test_6() throws Exception {
|
||||
Connection conn = DriverManager.getConnection("jdbc:mock:");
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
|
||||
ResultSet rs = stmt.executeQuery("SELECT false FROM DUAL");
|
||||
Assert.assertTrue(rs.next());
|
||||
Assert.assertEquals(false, rs.getBoolean(1));
|
||||
|
||||
|
||||
rs.close();
|
||||
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
}
|
||||
|
||||
@@ -15,12 +15,12 @@ public class Case0 extends TestCase {
|
||||
|
||||
public void test_0() throws Exception {
|
||||
final DruidDataSource dataSource = new DruidDataSource();
|
||||
|
||||
|
||||
dataSource.setDriver(new MockDriver() {
|
||||
|
||||
|
||||
});
|
||||
dataSource.setUrl("jdbc:mock:");
|
||||
|
||||
|
||||
dataSource.setMinIdle(0);
|
||||
dataSource.setMaxActive(2);
|
||||
dataSource.setMaxIdle(2);
|
||||
@@ -32,6 +32,7 @@ public class Case0 extends TestCase {
|
||||
final CountDownLatch completeLatch = new CountDownLatch(1);
|
||||
final AtomicInteger waitCount = new AtomicInteger();
|
||||
Thread t = new Thread() {
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
startLatch.countDown();
|
||||
@@ -39,7 +40,7 @@ public class Case0 extends TestCase {
|
||||
Connection conn = dataSource.getConnection();
|
||||
waitCount.decrementAndGet();
|
||||
conn.close();
|
||||
|
||||
|
||||
completeLatch.countDown();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -47,14 +48,14 @@ public class Case0 extends TestCase {
|
||||
}
|
||||
};
|
||||
t.start();
|
||||
|
||||
|
||||
startLatch.await();
|
||||
Assert.assertFalse(completeLatch.await(1, TimeUnit.SECONDS));
|
||||
conn1.close();
|
||||
Assert.assertTrue(completeLatch.await(1, TimeUnit.SECONDS));
|
||||
conn2.close();
|
||||
Assert.assertTrue(completeLatch.await(1, TimeUnit.SECONDS));
|
||||
|
||||
|
||||
dataSource.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,14 +17,15 @@ public class Case1 extends TestCase {
|
||||
|
||||
final long startTime = System.currentTimeMillis();
|
||||
final long okTime = startTime + 1000 * 1;
|
||||
|
||||
|
||||
dataSource.setDriver(new MockDriver() {
|
||||
|
||||
@Override
|
||||
public Connection connect(String url, Properties info) throws SQLException {
|
||||
if (System.currentTimeMillis() < okTime) {
|
||||
throw new SQLException();
|
||||
throw new SQLException();
|
||||
}
|
||||
|
||||
|
||||
return super.connect(url, info);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -31,7 +31,6 @@ import com.alibaba.druid.util.JMXUtils;
|
||||
*/
|
||||
public class Case2 extends TestCase {
|
||||
|
||||
|
||||
public void test_singleThread() throws Exception {
|
||||
|
||||
Class.forName("com.alibaba.druid.mock.MockDriver");
|
||||
@@ -56,7 +55,7 @@ public class Case2 extends TestCase {
|
||||
for (int i = 0; i < COUNT; ++i) {
|
||||
connections[i] = dataSource.getConnection();
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < COUNT; ++i) {
|
||||
connections[i].close();
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public class Case3 extends TestCase {
|
||||
error = ex;
|
||||
}
|
||||
Assert.assertNotNull(error);
|
||||
|
||||
|
||||
dataSource.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,16 +21,17 @@ public class PasswordCallbackTest extends TestCase {
|
||||
|
||||
Connection conn = dataSource.getConnection();
|
||||
conn.close();
|
||||
|
||||
|
||||
Assert.assertEquals(dataSource.getUrl(), passwordCallback.getUrl());
|
||||
Assert.assertEquals(dataSource.getConnectProperties(), passwordCallback.getProperties());
|
||||
}
|
||||
|
||||
public static class TestPasswordCallback extends PasswordCallback {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String url;
|
||||
private Properties properties;
|
||||
|
||||
private String url;
|
||||
private Properties properties;
|
||||
|
||||
public TestPasswordCallback(){
|
||||
super("test", false);
|
||||
|
||||
@@ -23,15 +23,15 @@ public class TestClose_1 extends TestCase {
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
Assert.assertEquals(false, rs.isClosed());
|
||||
|
||||
|
||||
Assert.assertEquals(false, stmt.isClosed());
|
||||
stmt.close();
|
||||
Assert.assertEquals(true, stmt.isClosed());
|
||||
Assert.assertEquals(true, rs.isClosed());
|
||||
|
||||
|
||||
PreparedStatement stmt2 = conn.prepareStatement(sql);
|
||||
Assert.assertEquals(false, stmt.isClosed());
|
||||
|
||||
|
||||
Assert.assertEquals(stmt, stmt2);
|
||||
|
||||
conn.close();
|
||||
@@ -41,7 +41,7 @@ public class TestClose_1 extends TestCase {
|
||||
|
||||
rs.close();
|
||||
stmt.close();
|
||||
|
||||
|
||||
dataSource.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,15 +23,15 @@ public class TestClose_2 extends TestCase {
|
||||
ResultSet rs = stmt.executeQuery();
|
||||
rs.next();
|
||||
Assert.assertEquals(false, rs.isClosed());
|
||||
|
||||
|
||||
Assert.assertEquals(false, stmt.isClosed());
|
||||
stmt.close();
|
||||
Assert.assertEquals(true, stmt.isClosed());
|
||||
Assert.assertEquals(true, rs.isClosed());
|
||||
|
||||
|
||||
CallableStatement stmt2 = conn.prepareCall(sql);
|
||||
Assert.assertEquals(false, stmt.isClosed());
|
||||
|
||||
|
||||
Assert.assertEquals(stmt, stmt2);
|
||||
|
||||
conn.close();
|
||||
@@ -41,7 +41,7 @@ public class TestClose_2 extends TestCase {
|
||||
|
||||
rs.close();
|
||||
stmt.close();
|
||||
|
||||
|
||||
dataSource.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,9 @@ public class BasicTypeTest extends TestCase {
|
||||
Statement stmt = conn.createStatement();
|
||||
stmt.execute("CREATE TABLE T_BASIC_TYPE (F1 FLOAT, F2 DOUBLE, F3 REAL, F4 DATE, F5 TIME, F6 SMALLINT, F7 SMALLINT, F8 INTEGER, F9 BIGINT, F10 DECIMAL(9,2), F11 TIMESTAMP, F12 BLOB, F13 VARCHAR(256), F14 VARCHAR(256), F15 VARCHAR(256), F16 VARCHAR(256), F17 SMALLINT)");
|
||||
stmt.execute("CREATE PROCEDURE BASIC_CALL_0(INOUT F1 FLOAT, INOUT F2 DOUBLE, INOUT F3 REAL, INOUT F4 DATE, INOUT F5 TIME, INOUT F6 SMALLINT, INOUT F7 SMALLINT, INOUT F8 INTEGER, INOUT F9 BIGINT, INOUT F10 DECIMAL(9,2), INOUT F11 TIMESTAMP, INOUT F12 VARCHAR(128) FOR BIT DATA, INOUT F13 VARCHAR(256), INOUT F14 VARCHAR(256), INOUT F15 VARCHAR(256), INOUT F16 VARCHAR(256), INOUT F17 SMALLINT) "
|
||||
+ "LANGUAGE JAVA PARAMETER STYLE JAVA EXTERNAL NAME '" + BasicTypeTest.class.getName() + ".basic_process_0' " + "DYNAMIC RESULT SETS 1");
|
||||
+ "LANGUAGE JAVA PARAMETER STYLE JAVA EXTERNAL NAME '"
|
||||
+ BasicTypeTest.class.getName()
|
||||
+ ".basic_process_0' " + "DYNAMIC RESULT SETS 1");
|
||||
stmt.close();
|
||||
conn.close();
|
||||
}
|
||||
@@ -123,7 +125,8 @@ public class BasicTypeTest extends TestCase {
|
||||
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
|
||||
stmt.close();
|
||||
|
||||
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE, ResultSet.CLOSE_CURSORS_AT_COMMIT);
|
||||
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE,
|
||||
ResultSet.CLOSE_CURSORS_AT_COMMIT);
|
||||
stmt.setQueryTimeout(stmt.getQueryTimeout());
|
||||
stmt.setEscapeProcessing(true);
|
||||
stmt.clearBatch();
|
||||
@@ -249,11 +252,12 @@ public class BasicTypeTest extends TestCase {
|
||||
pstmt = conn.prepareStatement("SELECT F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16 FROM T_BASIC_TYPE");
|
||||
JdbcUtils.close(pstmt);
|
||||
|
||||
pstmt = conn.prepareStatement("SELECT F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16 FROM T_BASIC_TYPE", new int[] { 1, 2 });
|
||||
pstmt = conn.prepareStatement("SELECT F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16 FROM T_BASIC_TYPE",
|
||||
new int[] { 1, 2 });
|
||||
JdbcUtils.close(pstmt);
|
||||
|
||||
pstmt = conn.prepareStatement("SELECT F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16 FROM T_BASIC_TYPE", new String[] {
|
||||
"F1", "F2" });
|
||||
pstmt = conn.prepareStatement("SELECT F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16 FROM T_BASIC_TYPE",
|
||||
new String[] { "F1", "F2" });
|
||||
JdbcUtils.close(pstmt);
|
||||
|
||||
pstmt = conn.prepareStatement("SELECT F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16 FROM T_BASIC_TYPE",
|
||||
@@ -266,7 +270,8 @@ public class BasicTypeTest extends TestCase {
|
||||
JdbcUtils.close(pstmt);
|
||||
|
||||
pstmt = conn.prepareStatement("SELECT F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16 FROM T_BASIC_TYPE",
|
||||
ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE, ResultSet.CLOSE_CURSORS_AT_COMMIT);
|
||||
ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE,
|
||||
ResultSet.CLOSE_CURSORS_AT_COMMIT);
|
||||
JdbcUtils.close(pstmt);
|
||||
|
||||
cstmt = conn.prepareCall("CALL BASIC_CALL_0(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,?, ?, ?, ?)");
|
||||
@@ -686,9 +691,10 @@ public class BasicTypeTest extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public static void basic_process_0(double[] p1, double[] p2, float[] p3, java.sql.Date[] p4, java.sql.Time[] p5, short[] p6, short[] p7, int[] p8,
|
||||
long[] p9, BigDecimal[] p10, java.sql.Timestamp[] p11, byte[][] p12, String[] p13, String[] p14, String[] p15,
|
||||
String[] p16, short[] P17, ResultSet[] p18) {
|
||||
public static void basic_process_0(double[] p1, double[] p2, float[] p3, java.sql.Date[] p4, java.sql.Time[] p5,
|
||||
short[] p6, short[] p7, int[] p8, long[] p9, BigDecimal[] p10,
|
||||
java.sql.Timestamp[] p11, byte[][] p12, String[] p13, String[] p14,
|
||||
String[] p15, String[] p16, short[] P17, ResultSet[] p18) {
|
||||
// stmt.execute("CREATE TABLE T_BASIC_TYPE (F1 FLOAT, F2 DOUBLE, F3
|
||||
// REAL, F4 DATE,
|
||||
// F5 TIME, F6 SMALLINT, F7 SMALLINT, F8 INTEGER, F9 BIGINT, F10
|
||||
|
||||
@@ -102,7 +102,8 @@ public class BlobTest extends TestCase {
|
||||
updateCount = pstmt.executeUpdate();
|
||||
Assert.assertEquals(1, updateCount);
|
||||
|
||||
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE, ResultSet.CLOSE_CURSORS_AT_COMMIT);
|
||||
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE,
|
||||
ResultSet.CLOSE_CURSORS_AT_COMMIT);
|
||||
|
||||
conn.nativeSQL("SELECT ID, DATA FROM T_BLOB");
|
||||
// //////
|
||||
|
||||
@@ -34,20 +34,24 @@ public class CallStatementTest extends TestCase {
|
||||
*/
|
||||
private static final String[] PROCEDURES = {
|
||||
|
||||
"CREATE PROCEDURE RETRIEVE_DYNAMIC_RESULTS(number INT) " + "LANGUAGE JAVA PARAMETER STYLE JAVA EXTERNAL NAME '" + CallStatementTest.class.getName()
|
||||
"CREATE PROCEDURE RETRIEVE_DYNAMIC_RESULTS(number INT) "
|
||||
+ "LANGUAGE JAVA PARAMETER STYLE JAVA EXTERNAL NAME '" + CallStatementTest.class.getName()
|
||||
+ ".retrieveDynamicResults' " + "DYNAMIC RESULT SETS 4",
|
||||
|
||||
"CREATE PROCEDURE RETRIEVE_CLOSED_RESULT() LANGUAGE JAVA " + "PARAMETER STYLE JAVA EXTERNAL NAME '" + CallStatementTest.class.getName()
|
||||
+ ".retrieveClosedResult' " + "DYNAMIC RESULT SETS 1",
|
||||
"CREATE PROCEDURE RETRIEVE_CLOSED_RESULT() LANGUAGE JAVA " + "PARAMETER STYLE JAVA EXTERNAL NAME '"
|
||||
+ CallStatementTest.class.getName() + ".retrieveClosedResult' " + "DYNAMIC RESULT SETS 1",
|
||||
|
||||
"CREATE PROCEDURE RETRIEVE_EXTERNAL_RESULT(" + "DBNAME VARCHAR(128), DBUSER VARCHAR(128), DBPWD VARCHAR(128)) LANGUAGE JAVA "
|
||||
+ "PARAMETER STYLE JAVA EXTERNAL NAME '" + CallStatementTest.class.getName() + ".retrieveExternalResult' " + "DYNAMIC RESULT SETS 1",
|
||||
"CREATE PROCEDURE RETRIEVE_EXTERNAL_RESULT("
|
||||
+ "DBNAME VARCHAR(128), DBUSER VARCHAR(128), DBPWD VARCHAR(128)) LANGUAGE JAVA "
|
||||
+ "PARAMETER STYLE JAVA EXTERNAL NAME '" + CallStatementTest.class.getName()
|
||||
+ ".retrieveExternalResult' " + "DYNAMIC RESULT SETS 1",
|
||||
|
||||
"CREATE PROCEDURE PROC_WITH_SIDE_EFFECTS(ret INT) LANGUAGE JAVA " + "PARAMETER STYLE JAVA EXTERNAL NAME '" + CallStatementTest.class.getName()
|
||||
+ ".procWithSideEffects' " + "DYNAMIC RESULT SETS 2",
|
||||
"CREATE PROCEDURE PROC_WITH_SIDE_EFFECTS(ret INT) LANGUAGE JAVA " + "PARAMETER STYLE JAVA EXTERNAL NAME '"
|
||||
+ CallStatementTest.class.getName() + ".procWithSideEffects' " + "DYNAMIC RESULT SETS 2",
|
||||
|
||||
"CREATE PROCEDURE NESTED_RESULT_SETS(proctext VARCHAR(128)) LANGUAGE JAVA " + "PARAMETER STYLE JAVA EXTERNAL NAME '"
|
||||
+ CallStatementTest.class.getName() + ".nestedDynamicResultSets' " + "DYNAMIC RESULT SETS 6"
|
||||
"CREATE PROCEDURE NESTED_RESULT_SETS(proctext VARCHAR(128)) LANGUAGE JAVA "
|
||||
+ "PARAMETER STYLE JAVA EXTERNAL NAME '" + CallStatementTest.class.getName()
|
||||
+ ".nestedDynamicResultSets' " + "DYNAMIC RESULT SETS 6"
|
||||
|
||||
};
|
||||
|
||||
@@ -131,7 +135,8 @@ public class CallStatementTest extends TestCase {
|
||||
connect.close();
|
||||
}
|
||||
|
||||
public static void retrieveExternalResult(String dbName, String user, String password, ResultSet[] external) throws SQLException {
|
||||
public static void retrieveExternalResult(String dbName, String user, String password, ResultSet[] external)
|
||||
throws SQLException {
|
||||
|
||||
Connection conn = DriverManager.getConnection(create_url);
|
||||
|
||||
@@ -190,7 +195,8 @@ public class CallStatementTest extends TestCase {
|
||||
conn.close();
|
||||
}
|
||||
|
||||
public static void fivejp(ResultSet[] data1, ResultSet[] data2, ResultSet[] data3, ResultSet[] data4, ResultSet[] data5) throws SQLException {
|
||||
public static void fivejp(ResultSet[] data1, ResultSet[] data2, ResultSet[] data3, ResultSet[] data4,
|
||||
ResultSet[] data5) throws SQLException {
|
||||
|
||||
Connection conn = DriverManager.getConnection("jdbc:default:connection");
|
||||
|
||||
@@ -240,7 +246,8 @@ public class CallStatementTest extends TestCase {
|
||||
conn.close();
|
||||
}
|
||||
|
||||
public static void parameter2(int a, java.math.BigDecimal b, java.math.BigDecimal c, java.sql.ResultSet[] rs) throws SQLException {
|
||||
public static void parameter2(int a, java.math.BigDecimal b, java.math.BigDecimal c, java.sql.ResultSet[] rs)
|
||||
throws SQLException {
|
||||
Connection conn = DriverManager.getConnection("jdbc:default:connection");
|
||||
PreparedStatement ps = conn.prepareStatement("insert into PT1 values (?, ?, ?)");
|
||||
ps.setInt(1, a);
|
||||
@@ -254,7 +261,8 @@ public class CallStatementTest extends TestCase {
|
||||
conn.close();
|
||||
}
|
||||
|
||||
public static void retrieveDynamicResults(int number, ResultSet[] rs1, ResultSet[] rs2, ResultSet[] rs3, ResultSet[] rs4) throws SQLException {
|
||||
public static void retrieveDynamicResults(int number, ResultSet[] rs1, ResultSet[] rs2, ResultSet[] rs3,
|
||||
ResultSet[] rs4) throws SQLException {
|
||||
Connection c = DriverManager.getConnection("jdbc:default:connection");
|
||||
if (number > 0) {
|
||||
rs1[0] = c.createStatement().executeQuery("VALUES(1)");
|
||||
|
||||
@@ -102,7 +102,8 @@ public class ClobTest extends TestCase {
|
||||
updateCount = pstmt.executeUpdate();
|
||||
Assert.assertEquals(1, updateCount);
|
||||
|
||||
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE, ResultSet.CLOSE_CURSORS_AT_COMMIT);
|
||||
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE,
|
||||
ResultSet.CLOSE_CURSORS_AT_COMMIT);
|
||||
|
||||
// //////
|
||||
rs = stmt.executeQuery("SELECT ID, DATA FROM T_CLOB");
|
||||
|
||||
@@ -85,7 +85,8 @@ public class DruidDriverTest extends TestCase {
|
||||
public void test_getRawDriverClassName() throws Exception {
|
||||
Assert.assertEquals("com.mysql.jdbc.Driver", JdbcUtils.getDriverClassName("jdbc:mysql:"));
|
||||
Assert.assertEquals("oracle.jdbc.driver.OracleDriver", JdbcUtils.getDriverClassName("jdbc:oracle:"));
|
||||
Assert.assertEquals("com.microsoft.jdbc.sqlserver.SQLServerDriver", JdbcUtils.getDriverClassName("jdbc:microsoft:"));
|
||||
Assert.assertEquals("com.microsoft.jdbc.sqlserver.SQLServerDriver",
|
||||
JdbcUtils.getDriverClassName("jdbc:microsoft:"));
|
||||
Assert.assertEquals("org.postgresql.Driver", JdbcUtils.getDriverClassName("jdbc:postgresql:xx"));
|
||||
Assert.assertEquals("net.sourceforge.jtds.jdbc.Driver", JdbcUtils.getDriverClassName("jdbc:jtds:"));
|
||||
{
|
||||
@@ -185,7 +186,8 @@ public class DruidDriverTest extends TestCase {
|
||||
Exception error = null;
|
||||
try {
|
||||
driver.connect("jdbc:wrap-jdbc:filters=" + PrivateJdbcFilterAdapter.class.getName()
|
||||
+ ":name=driverWrapperTest:jdbc:derby:memory:driverWrapperTestDB;create=true", new Properties()).close();
|
||||
+ ":name=driverWrapperTest:jdbc:derby:memory:driverWrapperTestDB;create=true",
|
||||
new Properties()).close();
|
||||
} catch (Exception ex) {
|
||||
error = ex;
|
||||
}
|
||||
@@ -195,7 +197,8 @@ public class DruidDriverTest extends TestCase {
|
||||
Exception error = null;
|
||||
try {
|
||||
driver.connect("jdbc:wrap-jdbc:filters=" + InitErrorJdbcFilterAdapter.class.getName()
|
||||
+ ":name=driverWrapperTest:jdbc:derby:memory:driverWrapperTestDB;create=true", new Properties()).close();
|
||||
+ ":name=driverWrapperTest:jdbc:derby:memory:driverWrapperTestDB;create=true",
|
||||
new Properties()).close();
|
||||
} catch (Exception ex) {
|
||||
error = ex;
|
||||
}
|
||||
|
||||
@@ -105,7 +105,8 @@ public class JdbcFilterEventAdapterTest extends TestCase {
|
||||
{
|
||||
FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {
|
||||
|
||||
public boolean statement_execute(StatementProxy statement, String sql, int autoGeneratedKeys) throws SQLException {
|
||||
public boolean statement_execute(StatementProxy statement, String sql, int autoGeneratedKeys)
|
||||
throws SQLException {
|
||||
throw new SQLException();
|
||||
}
|
||||
};
|
||||
@@ -122,7 +123,8 @@ public class JdbcFilterEventAdapterTest extends TestCase {
|
||||
{
|
||||
FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {
|
||||
|
||||
public boolean statement_execute(StatementProxy statement, String sql, int autoGeneratedKeys) throws SQLException {
|
||||
public boolean statement_execute(StatementProxy statement, String sql, int autoGeneratedKeys)
|
||||
throws SQLException {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
};
|
||||
@@ -139,7 +141,8 @@ public class JdbcFilterEventAdapterTest extends TestCase {
|
||||
{
|
||||
FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {
|
||||
|
||||
public boolean statement_execute(StatementProxy statement, String sql, int autoGeneratedKeys) throws SQLException {
|
||||
public boolean statement_execute(StatementProxy statement, String sql, int autoGeneratedKeys)
|
||||
throws SQLException {
|
||||
throw new Error();
|
||||
}
|
||||
};
|
||||
@@ -158,7 +161,8 @@ public class JdbcFilterEventAdapterTest extends TestCase {
|
||||
{
|
||||
FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {
|
||||
|
||||
public boolean statement_execute(StatementProxy statement, String sql, int columnIndexes[]) throws SQLException {
|
||||
public boolean statement_execute(StatementProxy statement, String sql, int columnIndexes[])
|
||||
throws SQLException {
|
||||
throw new SQLException();
|
||||
}
|
||||
};
|
||||
@@ -175,7 +179,8 @@ public class JdbcFilterEventAdapterTest extends TestCase {
|
||||
{
|
||||
FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {
|
||||
|
||||
public boolean statement_execute(StatementProxy statement, String sql, int columnIndexes[]) throws SQLException {
|
||||
public boolean statement_execute(StatementProxy statement, String sql, int columnIndexes[])
|
||||
throws SQLException {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
};
|
||||
@@ -192,7 +197,8 @@ public class JdbcFilterEventAdapterTest extends TestCase {
|
||||
{
|
||||
FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {
|
||||
|
||||
public boolean statement_execute(StatementProxy statement, String sql, int columnIndexes[]) throws SQLException {
|
||||
public boolean statement_execute(StatementProxy statement, String sql, int columnIndexes[])
|
||||
throws SQLException {
|
||||
throw new Error();
|
||||
}
|
||||
};
|
||||
@@ -211,7 +217,8 @@ public class JdbcFilterEventAdapterTest extends TestCase {
|
||||
{
|
||||
FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {
|
||||
|
||||
public boolean statement_execute(StatementProxy statement, String sql, String columnNames[]) throws SQLException {
|
||||
public boolean statement_execute(StatementProxy statement, String sql, String columnNames[])
|
||||
throws SQLException {
|
||||
throw new SQLException();
|
||||
}
|
||||
};
|
||||
@@ -228,7 +235,8 @@ public class JdbcFilterEventAdapterTest extends TestCase {
|
||||
{
|
||||
FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {
|
||||
|
||||
public boolean statement_execute(StatementProxy statement, String sql, String columnNames[]) throws SQLException {
|
||||
public boolean statement_execute(StatementProxy statement, String sql, String columnNames[])
|
||||
throws SQLException {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
};
|
||||
@@ -245,7 +253,8 @@ public class JdbcFilterEventAdapterTest extends TestCase {
|
||||
{
|
||||
FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {
|
||||
|
||||
public boolean statement_execute(StatementProxy statement, String sql, String columnNames[]) throws SQLException {
|
||||
public boolean statement_execute(StatementProxy statement, String sql, String columnNames[])
|
||||
throws SQLException {
|
||||
throw new Error();
|
||||
}
|
||||
};
|
||||
@@ -478,7 +487,8 @@ public class JdbcFilterEventAdapterTest extends TestCase {
|
||||
{
|
||||
FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {
|
||||
|
||||
public int statement_executeUpdate(StatementProxy statement, String sql, int autoGeneratedKeys) throws SQLException {
|
||||
public int statement_executeUpdate(StatementProxy statement, String sql, int autoGeneratedKeys)
|
||||
throws SQLException {
|
||||
throw new SQLException();
|
||||
}
|
||||
};
|
||||
@@ -495,7 +505,8 @@ public class JdbcFilterEventAdapterTest extends TestCase {
|
||||
{
|
||||
FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {
|
||||
|
||||
public int statement_executeUpdate(StatementProxy statement, String sql, int autoGeneratedKeys) throws SQLException {
|
||||
public int statement_executeUpdate(StatementProxy statement, String sql, int autoGeneratedKeys)
|
||||
throws SQLException {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
};
|
||||
@@ -512,7 +523,8 @@ public class JdbcFilterEventAdapterTest extends TestCase {
|
||||
{
|
||||
FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {
|
||||
|
||||
public int statement_executeUpdate(StatementProxy statement, String sql, int autoGeneratedKeys) throws SQLException {
|
||||
public int statement_executeUpdate(StatementProxy statement, String sql, int autoGeneratedKeys)
|
||||
throws SQLException {
|
||||
throw new Error();
|
||||
}
|
||||
};
|
||||
@@ -531,7 +543,8 @@ public class JdbcFilterEventAdapterTest extends TestCase {
|
||||
{
|
||||
FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {
|
||||
|
||||
public int statement_executeUpdate(StatementProxy statement, String sql, int columnIndexes[]) throws SQLException {
|
||||
public int statement_executeUpdate(StatementProxy statement, String sql, int columnIndexes[])
|
||||
throws SQLException {
|
||||
throw new SQLException();
|
||||
}
|
||||
};
|
||||
@@ -548,7 +561,8 @@ public class JdbcFilterEventAdapterTest extends TestCase {
|
||||
{
|
||||
FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {
|
||||
|
||||
public int statement_executeUpdate(StatementProxy statement, String sql, int columnIndexes[]) throws SQLException {
|
||||
public int statement_executeUpdate(StatementProxy statement, String sql, int columnIndexes[])
|
||||
throws SQLException {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
};
|
||||
@@ -565,7 +579,8 @@ public class JdbcFilterEventAdapterTest extends TestCase {
|
||||
{
|
||||
FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {
|
||||
|
||||
public int statement_executeUpdate(StatementProxy statement, String sql, int columnIndexes[]) throws SQLException {
|
||||
public int statement_executeUpdate(StatementProxy statement, String sql, int columnIndexes[])
|
||||
throws SQLException {
|
||||
throw new Error();
|
||||
}
|
||||
};
|
||||
@@ -584,7 +599,8 @@ public class JdbcFilterEventAdapterTest extends TestCase {
|
||||
{
|
||||
FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {
|
||||
|
||||
public int statement_executeUpdate(StatementProxy statement, String sql, String columnNames[]) throws SQLException {
|
||||
public int statement_executeUpdate(StatementProxy statement, String sql, String columnNames[])
|
||||
throws SQLException {
|
||||
throw new SQLException();
|
||||
}
|
||||
};
|
||||
@@ -601,7 +617,8 @@ public class JdbcFilterEventAdapterTest extends TestCase {
|
||||
{
|
||||
FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {
|
||||
|
||||
public int statement_executeUpdate(StatementProxy statement, String sql, String columnNames[]) throws SQLException {
|
||||
public int statement_executeUpdate(StatementProxy statement, String sql, String columnNames[])
|
||||
throws SQLException {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
};
|
||||
@@ -618,7 +635,8 @@ public class JdbcFilterEventAdapterTest extends TestCase {
|
||||
{
|
||||
FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {
|
||||
|
||||
public int statement_executeUpdate(StatementProxy statement, String sql, String columnNames[]) throws SQLException {
|
||||
public int statement_executeUpdate(StatementProxy statement, String sql, String columnNames[])
|
||||
throws SQLException {
|
||||
throw new Error();
|
||||
}
|
||||
};
|
||||
@@ -715,7 +733,8 @@ public class JdbcFilterEventAdapterTest extends TestCase {
|
||||
{
|
||||
FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {
|
||||
|
||||
public ResultSetProxy preparedStatement_executeQuery(PreparedStatementProxy statement) throws SQLException {
|
||||
public ResultSetProxy preparedStatement_executeQuery(PreparedStatementProxy statement)
|
||||
throws SQLException {
|
||||
throw new SQLException();
|
||||
}
|
||||
};
|
||||
@@ -732,7 +751,8 @@ public class JdbcFilterEventAdapterTest extends TestCase {
|
||||
{
|
||||
FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {
|
||||
|
||||
public ResultSetProxy preparedStatement_executeQuery(PreparedStatementProxy statement) throws SQLException {
|
||||
public ResultSetProxy preparedStatement_executeQuery(PreparedStatementProxy statement)
|
||||
throws SQLException {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
};
|
||||
@@ -749,7 +769,8 @@ public class JdbcFilterEventAdapterTest extends TestCase {
|
||||
{
|
||||
FilterChain chain = new FilterChainImpl(new DataSourceProxyImpl(null, config)) {
|
||||
|
||||
public ResultSetProxy preparedStatement_executeQuery(PreparedStatementProxy statement) throws SQLException {
|
||||
public ResultSetProxy preparedStatement_executeQuery(PreparedStatementProxy statement)
|
||||
throws SQLException {
|
||||
throw new Error();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -77,11 +77,12 @@ public class PrecallTest extends TestCase {
|
||||
try {
|
||||
conn = DriverManager.getConnection(create_url);
|
||||
|
||||
cstmt = conn.prepareCall("CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY(?, ?)", ResultSet.FETCH_FORWARD, ResultSet.CONCUR_READ_ONLY);
|
||||
cstmt = conn.prepareCall("CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY(?, ?)", ResultSet.FETCH_FORWARD,
|
||||
ResultSet.CONCUR_READ_ONLY);
|
||||
cstmt.close();
|
||||
|
||||
cstmt = conn.prepareCall("CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY(?, ?)", ResultSet.FETCH_FORWARD, ResultSet.CONCUR_READ_ONLY,
|
||||
ResultSet.CLOSE_CURSORS_AT_COMMIT);
|
||||
cstmt = conn.prepareCall("CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY(?, ?)", ResultSet.FETCH_FORWARD,
|
||||
ResultSet.CONCUR_READ_ONLY, ResultSet.CLOSE_CURSORS_AT_COMMIT);
|
||||
cstmt.close();
|
||||
|
||||
cstmt = conn.prepareCall("CALL SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY(?, ?)");
|
||||
|
||||
@@ -77,7 +77,8 @@ public class PreparedStatementTest extends TestCase {
|
||||
try {
|
||||
conn = DriverManager.getConnection(create_url);
|
||||
|
||||
pstmt = conn.prepareStatement("INSERT INTO T_PRE_STMT_TEST (ID, NAME, BIRTHDATE) VALUES (?, ?, ?)", Statement.RETURN_GENERATED_KEYS);
|
||||
pstmt = conn.prepareStatement("INSERT INTO T_PRE_STMT_TEST (ID, NAME, BIRTHDATE) VALUES (?, ?, ?)",
|
||||
Statement.RETURN_GENERATED_KEYS);
|
||||
|
||||
pstmt.setShort(1, (short) 1);
|
||||
pstmt.setString(2, "A");
|
||||
@@ -164,7 +165,8 @@ public class PreparedStatementTest extends TestCase {
|
||||
}
|
||||
pstmt.execute();
|
||||
|
||||
pstmt2 = conn.prepareStatement("SELECT * FROM T_PRE_STMT_TEST ORDER BY 2", ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
|
||||
pstmt2 = conn.prepareStatement("SELECT * FROM T_PRE_STMT_TEST ORDER BY 2", ResultSet.TYPE_SCROLL_SENSITIVE,
|
||||
ResultSet.CONCUR_UPDATABLE);
|
||||
rs = pstmt2.executeQuery();
|
||||
rs.getCursorName();
|
||||
rs.clearWarnings();
|
||||
@@ -194,14 +196,15 @@ public class PreparedStatementTest extends TestCase {
|
||||
rs.last();
|
||||
rs.close();
|
||||
|
||||
pstmt2 = conn.prepareStatement("SELECT * FROM T_PRE_STMT_TEST ORDER BY 2", ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
|
||||
pstmt2 = conn.prepareStatement("SELECT * FROM T_PRE_STMT_TEST ORDER BY 2", ResultSet.TYPE_SCROLL_SENSITIVE,
|
||||
ResultSet.CONCUR_UPDATABLE);
|
||||
rs = pstmt2.executeQuery();
|
||||
rs.first();
|
||||
rs.last();
|
||||
rs.close();
|
||||
|
||||
pstmt2 = conn.prepareStatement("SELECT * FROM T_PRE_STMT_TEST ORDER BY 2", ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE,
|
||||
ResultSet.CLOSE_CURSORS_AT_COMMIT);
|
||||
pstmt2 = conn.prepareStatement("SELECT * FROM T_PRE_STMT_TEST ORDER BY 2", ResultSet.TYPE_SCROLL_SENSITIVE,
|
||||
ResultSet.CONCUR_UPDATABLE, ResultSet.CLOSE_CURSORS_AT_COMMIT);
|
||||
rs = pstmt2.executeQuery();
|
||||
rs.first();
|
||||
rs.last();
|
||||
@@ -282,7 +285,8 @@ public class PreparedStatementTest extends TestCase {
|
||||
JdbcUtils.printResultSet(rs, System.out);
|
||||
rs.close();
|
||||
|
||||
pstmt2 = conn.prepareStatement("SELECT * FROM T_PRE_STMT_TEST ORDER BY 2", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
|
||||
pstmt2 = conn.prepareStatement("SELECT * FROM T_PRE_STMT_TEST ORDER BY 2",
|
||||
ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
|
||||
rs = pstmt2.executeQuery();
|
||||
rs.next();
|
||||
try {
|
||||
|
||||
@@ -72,13 +72,18 @@ public class StatementTest extends TestCase {
|
||||
|
||||
stmt = conn.createStatement();
|
||||
stmt.execute("INSERT INTO T_PRE_STMT_TEST (ID, NAME, BIRTHDATE) VALUES (1, 'A', NULL)");
|
||||
stmt.execute("INSERT INTO T_PRE_STMT_TEST (ID, NAME, BIRTHDATE) VALUES (11, 'A1', NULL)", Statement.NO_GENERATED_KEYS);
|
||||
stmt.execute("INSERT INTO T_PRE_STMT_TEST (ID, NAME, BIRTHDATE) VALUES (11, 'A1', NULL)",
|
||||
Statement.NO_GENERATED_KEYS);
|
||||
stmt.execute("INSERT INTO T_PRE_STMT_TEST (ID, NAME, BIRTHDATE) VALUES (12, 'A2', NULL)", new int[] { 1 });
|
||||
stmt.execute("INSERT INTO T_PRE_STMT_TEST (ID, NAME, BIRTHDATE) VALUES (12, 'A3', NULL)", new String[] { "ID" });
|
||||
stmt.execute("INSERT INTO T_PRE_STMT_TEST (ID, NAME, BIRTHDATE) VALUES (12, 'A3', NULL)",
|
||||
new String[] { "ID" });
|
||||
stmt.executeUpdate("INSERT INTO T_PRE_STMT_TEST (ID, NAME, BIRTHDATE) VALUES (2, 'B', NULL)");
|
||||
stmt.executeUpdate("INSERT INTO T_PRE_STMT_TEST (ID, NAME, BIRTHDATE) VALUES (3, 'C', NULL)", Statement.NO_GENERATED_KEYS);
|
||||
stmt.executeUpdate("INSERT INTO T_PRE_STMT_TEST (ID, NAME, BIRTHDATE) VALUES (4, 'D', NULL)", new int[] { 1 });
|
||||
stmt.executeUpdate("INSERT INTO T_PRE_STMT_TEST (ID, NAME, BIRTHDATE) VALUES (5, 'E', NULL)", new String[] { "ID" });
|
||||
stmt.executeUpdate("INSERT INTO T_PRE_STMT_TEST (ID, NAME, BIRTHDATE) VALUES (3, 'C', NULL)",
|
||||
Statement.NO_GENERATED_KEYS);
|
||||
stmt.executeUpdate("INSERT INTO T_PRE_STMT_TEST (ID, NAME, BIRTHDATE) VALUES (4, 'D', NULL)",
|
||||
new int[] { 1 });
|
||||
stmt.executeUpdate("INSERT INTO T_PRE_STMT_TEST (ID, NAME, BIRTHDATE) VALUES (5, 'E', NULL)",
|
||||
new String[] { "ID" });
|
||||
try {
|
||||
stmt.cancel();
|
||||
} catch (SQLFeatureNotSupportedException ex) {
|
||||
|
||||
@@ -45,7 +45,8 @@ public class DruidConfigLoaderTest extends TestCase {
|
||||
Assert.assertEquals("gbk", druidConfig.getClientEncoding());
|
||||
Assert.assertEquals("utf8", druidConfig.getServerEncoding());
|
||||
} else if ("stat".equalsIgnoreCase(abstractDruidFilterConfig.getName())) {
|
||||
Assert.assertEquals("com.alibaba.druid.proxy.filter.stat.StatFilter", abstractDruidFilterConfig.getClazz());
|
||||
Assert.assertEquals("com.alibaba.druid.proxy.filter.stat.StatFilter",
|
||||
abstractDruidFilterConfig.getClazz());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +79,8 @@ public class DruidLoaderUtilsTest extends TestCase {
|
||||
DruidLoaderUtils.loadFilter(filters, filterItem);
|
||||
filterConfig = filters.get(0);
|
||||
Assert.assertNotNull(filterConfig);
|
||||
Assert.assertEquals("com.alibaba.druid.filter.encoding.EncodingConvertFilter", filterConfig.getClass().getName());
|
||||
Assert.assertEquals("com.alibaba.druid.filter.encoding.EncodingConvertFilter",
|
||||
filterConfig.getClass().getName());
|
||||
// 判定重复
|
||||
filterItem = "stat";
|
||||
filters.clear();
|
||||
@@ -114,8 +115,10 @@ public class DruidLoaderUtilsTest extends TestCase {
|
||||
Assert.assertEquals(null, DruidLoaderUtils.loadClass2(null));
|
||||
Assert.assertEquals(null, DruidLoaderUtils.loadClass("xxx"));
|
||||
Assert.assertEquals(null, DruidLoaderUtils.loadClass2("xxx"));
|
||||
Assert.assertEquals(PublicJdbcFilterAdapter.class, DruidLoaderUtils.loadClass(PublicJdbcFilterAdapter.class.getName()));
|
||||
Assert.assertEquals(PublicJdbcFilterAdapter.class, DruidLoaderUtils.loadClass2(PublicJdbcFilterAdapter.class.getName()));
|
||||
Assert.assertEquals(PublicJdbcFilterAdapter.class,
|
||||
DruidLoaderUtils.loadClass(PublicJdbcFilterAdapter.class.getName()));
|
||||
Assert.assertEquals(PublicJdbcFilterAdapter.class,
|
||||
DruidLoaderUtils.loadClass2(PublicJdbcFilterAdapter.class.getName()));
|
||||
Assert.assertNull(DruidLoaderUtils.loadClass(null));
|
||||
Assert.assertNull(DruidLoaderUtils.loadClass(""));
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import com.alibaba.druid.pool.DruidDataSource;
|
||||
|
||||
public class Case3 extends TestCase {
|
||||
|
||||
|
||||
public void test_1() throws Exception {
|
||||
DruidDataSource dataSource = new DruidDataSource();
|
||||
dataSource.setUrl("jdbc:mysql://10.20.153.104:3306/druid2");
|
||||
@@ -24,10 +23,10 @@ public class Case3 extends TestCase {
|
||||
rs.next();
|
||||
|
||||
conn.close();
|
||||
|
||||
|
||||
Assert.assertEquals(true, stmt.isClosed());
|
||||
Assert.assertEquals(true, rs.isClosed());
|
||||
|
||||
|
||||
rs.close();
|
||||
stmt.close();
|
||||
|
||||
|
||||
@@ -12,98 +12,91 @@ import com.alibaba.druid.pool.DruidDataSource;
|
||||
|
||||
public class DruidTest {
|
||||
|
||||
private static DruidDataSource DS;
|
||||
private static DruidDataSource DS;
|
||||
|
||||
public DruidTest(String connectURI) {
|
||||
initDS(connectURI);
|
||||
}
|
||||
public DruidTest(String connectURI){
|
||||
initDS(connectURI);
|
||||
}
|
||||
|
||||
public DruidTest(String connectURI, String username, String pswd,
|
||||
String driverClass, int initialSize, int maxActive, int maxIdle,
|
||||
int minIdle, int maxWait) {
|
||||
initDS(connectURI, username, pswd, driverClass, initialSize, maxActive,
|
||||
minIdle, maxIdle, maxWait);
|
||||
}
|
||||
public DruidTest(String connectURI, String username, String pswd, String driverClass, int initialSize,
|
||||
int maxActive, int maxIdle, int minIdle, int maxWait){
|
||||
initDS(connectURI, username, pswd, driverClass, initialSize, maxActive, minIdle, maxIdle, maxWait);
|
||||
}
|
||||
|
||||
public Connection getConn() {
|
||||
Connection con = null;
|
||||
if (DS != null) {
|
||||
try {
|
||||
con = DS.getConnection();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace(System.err);
|
||||
}
|
||||
public Connection getConn() {
|
||||
Connection con = null;
|
||||
if (DS != null) {
|
||||
try {
|
||||
con = DS.getConnection();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace(System.err);
|
||||
}
|
||||
|
||||
try {
|
||||
con.setAutoCommit(false);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return con;
|
||||
}
|
||||
return con;
|
||||
}
|
||||
try {
|
||||
con.setAutoCommit(false);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return con;
|
||||
}
|
||||
return con;
|
||||
}
|
||||
|
||||
public static void initDS(String connectURI, String username, String pswd,
|
||||
String driverClass, int initialSize, int maxActive, int maxIdle,
|
||||
int minIdle, int maxWait) {
|
||||
DruidDataSource ds = new DruidDataSource();
|
||||
ds.setDriverClassName(driverClass);
|
||||
ds.setUsername(username);
|
||||
ds.setPassword(pswd);
|
||||
ds.setUrl(connectURI);
|
||||
ds.setInitialSize(initialSize); // 初始的连接数;
|
||||
ds.setMaxActive(maxActive);
|
||||
ds.setMaxIdle(maxIdle);
|
||||
ds.setMinIdle(minIdle);
|
||||
ds.setMaxWait(maxWait);
|
||||
DS = ds;
|
||||
}
|
||||
public static void initDS(String connectURI, String username, String pswd, String driverClass, int initialSize,
|
||||
int maxActive, int maxIdle, int minIdle, int maxWait) {
|
||||
DruidDataSource ds = new DruidDataSource();
|
||||
ds.setDriverClassName(driverClass);
|
||||
ds.setUsername(username);
|
||||
ds.setPassword(pswd);
|
||||
ds.setUrl(connectURI);
|
||||
ds.setInitialSize(initialSize); // 初始的连接数;
|
||||
ds.setMaxActive(maxActive);
|
||||
ds.setMaxIdle(maxIdle);
|
||||
ds.setMinIdle(minIdle);
|
||||
ds.setMaxWait(maxWait);
|
||||
DS = ds;
|
||||
}
|
||||
|
||||
public static void initDS(String connectURI) {
|
||||
initDS(connectURI, "root", "12345", "com.mysql.jdbc.Driver", 40, 40,
|
||||
40, 10, 5);
|
||||
}
|
||||
public static void initDS(String connectURI) {
|
||||
initDS(connectURI, "root", "12345", "com.mysql.jdbc.Driver", 40, 40, 40, 10, 5);
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException, SQLException {
|
||||
public static void main(String[] args) throws IOException, SQLException {
|
||||
|
||||
DruidTest db = new DruidTest("jdbc:mysql://10.20.141.150:8066/amoeba");
|
||||
Connection conn = null;
|
||||
Statement stmt = null;
|
||||
ResultSet rs = null;
|
||||
DruidTest db = new DruidTest("jdbc:mysql://10.20.141.150:8066/amoeba");
|
||||
Connection conn = null;
|
||||
Statement stmt = null;
|
||||
ResultSet rs = null;
|
||||
|
||||
FileWriter fileWriter = new FileWriter("D:\\data.txt");
|
||||
try{
|
||||
conn = db.getConn();
|
||||
}catch(Exception e){
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
|
||||
long sum = 0;
|
||||
for (int i = 1; i < 10; i++) {
|
||||
try {
|
||||
stmt = conn.createStatement();
|
||||
Date start = new Date();
|
||||
rs = stmt
|
||||
.executeQuery("select * from offer where member_id = 'forwd251'");
|
||||
Date end = new Date();
|
||||
sum = sum + (end.getTime() - start.getTime());
|
||||
fileWriter.write(String.valueOf((end.getTime() - start
|
||||
.getTime())));
|
||||
fileWriter.write("/\n");
|
||||
FileWriter fileWriter = new FileWriter("D:\\data.txt");
|
||||
try {
|
||||
conn = db.getConn();
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
System.out.println((float) sum / 10);
|
||||
|
||||
|
||||
conn.close();
|
||||
stmt.close();
|
||||
rs.close();
|
||||
fileWriter.flush();
|
||||
fileWriter.close();
|
||||
}
|
||||
long sum = 0;
|
||||
for (int i = 1; i < 10; i++) {
|
||||
try {
|
||||
stmt = conn.createStatement();
|
||||
Date start = new Date();
|
||||
rs = stmt.executeQuery("select * from offer where member_id = 'forwd251'");
|
||||
Date end = new Date();
|
||||
sum = sum + (end.getTime() - start.getTime());
|
||||
fileWriter.write(String.valueOf((end.getTime() - start.getTime())));
|
||||
fileWriter.write("/\n");
|
||||
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
System.out.println((float) sum / 10);
|
||||
|
||||
conn.close();
|
||||
stmt.close();
|
||||
rs.close();
|
||||
fileWriter.flush();
|
||||
fileWriter.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,18 +7,20 @@ import junit.framework.TestCase;
|
||||
import com.alibaba.druid.pool.vendor.MySqlExceptionSorter;
|
||||
|
||||
public class MySqlValdConnectionTest extends TestCase {
|
||||
|
||||
private String jdbcUrl;
|
||||
private String user;
|
||||
private String password;
|
||||
private String driverClass;
|
||||
|
||||
public void setUp () throws Exception {
|
||||
|
||||
public void setUp() throws Exception {
|
||||
jdbcUrl = "jdbc:mysql://10.20.129.146/dragoon_v25masterdb?useUnicode=true&characterEncoding=UTF-8";
|
||||
user = "dragoon25";
|
||||
password = "dragoon25";
|
||||
driverClass = "com.mysql.jdbc.Driver";
|
||||
}
|
||||
public void test_0 () throws Exception {
|
||||
|
||||
public void test_0() throws Exception {
|
||||
DruidDataSource dataSource = new DruidDataSource();
|
||||
dataSource.setDriverClassName(driverClass);
|
||||
dataSource.setUrl(jdbcUrl);
|
||||
@@ -26,7 +28,7 @@ public class MySqlValdConnectionTest extends TestCase {
|
||||
dataSource.setPassword(password);
|
||||
dataSource.setFilters("stat");
|
||||
dataSource.setExceptionSoter(MySqlExceptionSorter.class.getName());
|
||||
|
||||
|
||||
Connection conn = dataSource.getConnection();
|
||||
conn.close();
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class TestOracle_DruidDataSource extends TestCase {
|
||||
final int THREAD_COUNT = 10;
|
||||
final CountDownLatch startLatch = new CountDownLatch(1);
|
||||
final CountDownLatch endLatch = new CountDownLatch(THREAD_COUNT);
|
||||
|
||||
|
||||
for (int i = 0; i < THREAD_COUNT; ++i) {
|
||||
Thread thread = new Thread() {
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ public class Test_kyline extends TestCase {
|
||||
private String url = "jdbc:mysql://10.20.141.150:8066/amoeba";
|
||||
private String user = "root";
|
||||
private String password = "12345";
|
||||
private String driver = "com.mysql.jdbc.Driver";
|
||||
private String driver = "com.mysql.jdbc.Driver";
|
||||
|
||||
public void test_0() throws Exception {
|
||||
DruidDataSource ds = new DruidDataSource();
|
||||
@@ -23,7 +23,7 @@ public class Test_kyline extends TestCase {
|
||||
|
||||
Connection conn = ds.getConnection();
|
||||
conn.close();
|
||||
|
||||
|
||||
ds.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,6 +144,7 @@ public class Case0 extends TestCase {
|
||||
long ygc = TestUtil.getYoungGC() - startYGC;
|
||||
long fullGC = TestUtil.getFullGC() - startFullGC;
|
||||
|
||||
System.out.println(name + " millis : " + NumberFormat.getInstance().format(millis) + ", YGC " + ygc + " FGC " + fullGC);
|
||||
System.out.println(name + " millis : " + NumberFormat.getInstance().format(millis) + ", YGC " + ygc + " FGC "
|
||||
+ fullGC);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,8 +30,8 @@ import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.jolbox.bonecp.BoneCPDataSource;
|
||||
|
||||
/**
|
||||
* TestOnBo
|
||||
* 类Case1.java的实现描述:TODO 类实现描述
|
||||
* TestOnBo 类Case1.java的实现描述:TODO 类实现描述
|
||||
*
|
||||
* @author admin 2011-5-28 下午03:47:40
|
||||
*/
|
||||
public class Case1 extends TestCase {
|
||||
@@ -113,7 +113,7 @@ public class Case1 extends TestCase {
|
||||
// dataSource.setMaxOpenPreparedStatements(100);
|
||||
dataSource.setUsername(user);
|
||||
dataSource.setPassword(password);
|
||||
//dataSource.setConnectionTestStatement("SELECT 1");
|
||||
// dataSource.setConnectionTestStatement("SELECT 1");
|
||||
dataSource.setPartitionCount(1);
|
||||
dataSource.setAcquireIncrement(5);
|
||||
dataSource.setIdleConnectionTestPeriod(0L);
|
||||
@@ -158,6 +158,7 @@ public class Case1 extends TestCase {
|
||||
long ygc = TestUtil.getYoungGC() - startYGC;
|
||||
long fullGC = TestUtil.getFullGC() - startFullGC;
|
||||
|
||||
System.out.println("thread " + threadCount + " " + name + " millis : " + NumberFormat.getInstance().format(millis) + ", YGC " + ygc + " FGC " + fullGC);
|
||||
System.out.println("thread " + threadCount + " " + name + " millis : "
|
||||
+ NumberFormat.getInstance().format(millis) + ", YGC " + ygc + " FGC " + fullGC);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,25 +30,25 @@ import com.alibaba.druid.pool.DruidDataSource;
|
||||
import com.jolbox.bonecp.BoneCPDataSource;
|
||||
|
||||
/**
|
||||
* TestOnBo
|
||||
* 类Case1.java的实现描述:TODO 类实现描述
|
||||
* TestOnBo 类Case1.java的实现描述:TODO 类实现描述
|
||||
*
|
||||
* @author admin 2011-5-28 下午03:47:40
|
||||
*/
|
||||
public class Case2 extends TestCase {
|
||||
|
||||
private String jdbcUrl;
|
||||
private String user;
|
||||
private String password;
|
||||
private String driverClass;
|
||||
private int initialSize = 10;
|
||||
private int minPoolSize = 10;
|
||||
private int maxPoolSize = 50;
|
||||
private int maxActive = 50;
|
||||
private String validationQuery = "SELECT 1";
|
||||
private int threadCount = 100;
|
||||
private int executeCount = 4;
|
||||
final int LOOP_COUNT = (1000 * 1000) / executeCount;
|
||||
private boolean testOnBorrow = true;
|
||||
private String jdbcUrl;
|
||||
private String user;
|
||||
private String password;
|
||||
private String driverClass;
|
||||
private int initialSize = 10;
|
||||
private int minPoolSize = 10;
|
||||
private int maxPoolSize = 50;
|
||||
private int maxActive = 50;
|
||||
private String validationQuery = "SELECT 1";
|
||||
private int threadCount = 100;
|
||||
private int executeCount = 4;
|
||||
final int LOOP_COUNT = (1000 * 1000) / executeCount;
|
||||
private boolean testOnBorrow = true;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
jdbcUrl = "jdbc:fake:dragoon_v25masterdb";
|
||||
@@ -160,6 +160,7 @@ public class Case2 extends TestCase {
|
||||
long ygc = TestUtil.getYoungGC() - startYGC;
|
||||
long fullGC = TestUtil.getFullGC() - startFullGC;
|
||||
|
||||
System.out.println("thread " + threadCount + " " + name + " millis : " + NumberFormat.getInstance().format(millis) + ", YGC " + ygc + " FGC " + fullGC);
|
||||
System.out.println("thread " + threadCount + " " + name + " millis : "
|
||||
+ NumberFormat.getInstance().format(millis) + ", YGC " + ygc + " FGC " + fullGC);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,12 +45,12 @@ public class Case3 extends TestCase {
|
||||
user = "dragoon25";
|
||||
password = "dragoon25";
|
||||
driverClass = "com.alibaba.druid.mock.MockDriver";
|
||||
// connectionProperties = "connectSleep=3;executeSleep=1";
|
||||
// connectionProperties = "connectSleep=3;executeSleep=1";
|
||||
|
||||
// jdbcUrl = "jdbc:mysql://10.20.153.104:3306/druid2";
|
||||
// user = "root";
|
||||
// password = "root";
|
||||
// driverClass = "com.mysql.jdbc.Driver";
|
||||
// jdbcUrl = "jdbc:mysql://10.20.153.104:3306/druid2";
|
||||
// user = "root";
|
||||
// password = "root";
|
||||
// driverClass = "com.mysql.jdbc.Driver";
|
||||
}
|
||||
|
||||
public void test_perf() throws Exception {
|
||||
@@ -187,10 +187,11 @@ public class Case3 extends TestCase {
|
||||
long millis = System.currentTimeMillis() - startMillis;
|
||||
long ygc = TestUtil.getYoungGC() - startYGC;
|
||||
long fullGC = TestUtil.getFullGC() - startFullGC;
|
||||
|
||||
|
||||
Assert.assertEquals(LOOP_COUNT * threadCount, count.get());
|
||||
Thread.sleep(1);
|
||||
|
||||
System.out.println("thread " + threadCount + " " + name + " millis : " + NumberFormat.getInstance().format(millis) + ", YGC " + ygc + " FGC " + fullGC);
|
||||
System.out.println("thread " + threadCount + " " + name + " millis : "
|
||||
+ NumberFormat.getInstance().format(millis) + ", YGC " + ygc + " FGC " + fullGC);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,6 +169,7 @@ public class CaseKylin_Oracle extends TestCase {
|
||||
long ygc = TestUtil.getYoungGC() - startYGC;
|
||||
long fullGC = TestUtil.getFullGC() - startFullGC;
|
||||
|
||||
System.out.println("thread " + threadCount + " " + name + " millis : " + NumberFormat.getInstance().format(millis) + ", YGC " + ygc + " FGC " + fullGC);
|
||||
System.out.println("thread " + threadCount + " " + name + " millis : "
|
||||
+ NumberFormat.getInstance().format(millis) + ", YGC " + ygc + " FGC " + fullGC);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,20 +41,20 @@ public class CaseKylin_mysql extends TestCase {
|
||||
private int numTestsPerEvictionRun = 20;
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
// jdbcUrl = "jdbc:fake:dragoon_v25masterdb";
|
||||
// user = "dragoon25";
|
||||
// password = "dragoon25";
|
||||
// driverClass = "com.alibaba.druid.mock.MockDriver";
|
||||
// jdbcUrl = "jdbc:fake:dragoon_v25masterdb";
|
||||
// user = "dragoon25";
|
||||
// password = "dragoon25";
|
||||
// driverClass = "com.alibaba.druid.mock.MockDriver";
|
||||
|
||||
jdbcUrl = "jdbc:mysql://10.20.153.104:3306/druid2";
|
||||
user = "root";
|
||||
password = "root";
|
||||
driverClass = "com.mysql.jdbc.Driver";
|
||||
|
||||
// jdbcUrl = "jdbc:oracle:thin:@10.20.149.85:1521:ocnauto";
|
||||
// user = "alibaba";
|
||||
// password = "ccbuauto";
|
||||
// driverClass = "oracle.jdbc.driver.OracleDriver";
|
||||
|
||||
// jdbcUrl = "jdbc:oracle:thin:@10.20.149.85:1521:ocnauto";
|
||||
// user = "alibaba";
|
||||
// password = "ccbuauto";
|
||||
// driverClass = "oracle.jdbc.driver.OracleDriver";
|
||||
}
|
||||
|
||||
public void test_perf() throws Exception {
|
||||
@@ -163,6 +163,7 @@ public class CaseKylin_mysql extends TestCase {
|
||||
long ygc = TestUtil.getYoungGC() - startYGC;
|
||||
long fullGC = TestUtil.getFullGC() - startFullGC;
|
||||
|
||||
System.out.println("thread " + threadCount + " " + name + " millis : " + NumberFormat.getInstance().format(millis) + ", YGC " + ygc + " FGC " + fullGC);
|
||||
System.out.println("thread " + threadCount + " " + name + " millis : "
|
||||
+ NumberFormat.getInstance().format(millis) + ", YGC " + ygc + " FGC " + fullGC);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public class CaseKylin_mysql_idle_1 extends TestCase {
|
||||
private int maxIdle = 20;
|
||||
private int maxActive = 20;
|
||||
private int maxWait = 60000;
|
||||
private String validationQuery = null; // "SELECT 1";
|
||||
private String validationQuery = null; // "SELECT 1";
|
||||
private int threadCount = 15;
|
||||
private int TEST_COUNT = 3;
|
||||
final int LOOP_COUNT = 1000 * 10;
|
||||
@@ -135,6 +135,7 @@ public class CaseKylin_mysql_idle_1 extends TestCase {
|
||||
long ygc = TestUtil.getYoungGC() - startYGC;
|
||||
long fullGC = TestUtil.getFullGC() - startFullGC;
|
||||
|
||||
System.out.println("thread " + threadCount + " " + name + " millis : " + NumberFormat.getInstance().format(millis) + ", YGC " + ygc + " FGC " + fullGC);
|
||||
System.out.println("thread " + threadCount + " " + name + " millis : "
|
||||
+ NumberFormat.getInstance().format(millis) + ", YGC " + ygc + " FGC " + fullGC);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public class CaseKylin_mysql_idle_2 extends TestCase {
|
||||
private int maxIdle = 20;
|
||||
private int maxActive = 20;
|
||||
private int maxWait = 60000;
|
||||
private String validationQuery = null; // "SELECT 1";
|
||||
private String validationQuery = null; // "SELECT 1";
|
||||
private int threadCount = 15;
|
||||
private int TEST_COUNT = 3;
|
||||
final int LOOP_COUNT = 10 * 1;
|
||||
@@ -44,13 +44,13 @@ public class CaseKylin_mysql_idle_2 extends TestCase {
|
||||
user = "dragoon25";
|
||||
password = "dragoon25";
|
||||
driverClass = "com.alibaba.druid.mock.MockDriver";
|
||||
|
||||
|
||||
MockDriver.instance.setIdleTimeCount(50 * 60 * 10);
|
||||
|
||||
// jdbcUrl = "jdbc:mysql://10.20.141.150:8066/amoeba";
|
||||
// user = "root";
|
||||
// password = "12345";
|
||||
// driverClass = "com.mysql.jdbc.Driver";
|
||||
// jdbcUrl = "jdbc:mysql://10.20.141.150:8066/amoeba";
|
||||
// user = "root";
|
||||
// password = "12345";
|
||||
// driverClass = "com.mysql.jdbc.Driver";
|
||||
|
||||
// jdbcUrl = "jdbc:oracle:thin:@10.20.149.85:1521:ocnauto";
|
||||
// user = "alibaba";
|
||||
@@ -138,6 +138,7 @@ public class CaseKylin_mysql_idle_2 extends TestCase {
|
||||
long ygc = TestUtil.getYoungGC() - startYGC;
|
||||
long fullGC = TestUtil.getFullGC() - startFullGC;
|
||||
|
||||
System.out.println("thread " + threadCount + " " + name + " millis : " + NumberFormat.getInstance().format(millis) + ", YGC " + ygc + " FGC " + fullGC);
|
||||
System.out.println("thread " + threadCount + " " + name + " millis : "
|
||||
+ NumberFormat.getInstance().format(millis) + ", YGC " + ygc + " FGC " + fullGC);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,6 +137,7 @@ public class Oracle_Case0 extends TestCase {
|
||||
long ygc = TestUtil.getYoungGC() - startYGC;
|
||||
long fullGC = TestUtil.getFullGC() - startFullGC;
|
||||
|
||||
System.out.println(name + " millis : " + NumberFormat.getInstance().format(millis) + ", YGC " + ygc + " FGC " + fullGC);
|
||||
System.out.println(name + " millis : " + NumberFormat.getInstance().format(millis) + ", YGC " + ygc + " FGC "
|
||||
+ fullGC);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,9 +96,9 @@ public class Oracle_Case3 extends TestCase {
|
||||
Statement stmt = conn.createStatement();
|
||||
ResultSet rs = stmt.executeQuery("SELECT 1 FROM DUAL");
|
||||
rs.next();
|
||||
//Assert.isTrue(!rs.isClosed());
|
||||
// Assert.isTrue(!rs.isClosed());
|
||||
rs.close();
|
||||
//Assert.isTrue(!stmt.isClosed());
|
||||
// Assert.isTrue(!stmt.isClosed());
|
||||
stmt.close();
|
||||
Assert.isTrue(stmt.isClosed());
|
||||
conn.close();
|
||||
@@ -121,6 +121,7 @@ public class Oracle_Case3 extends TestCase {
|
||||
long ygc = TestUtil.getYoungGC() - startYGC;
|
||||
long fullGC = TestUtil.getFullGC() - startFullGC;
|
||||
|
||||
System.out.println("thread " + threadCount + " " + name + " millis : " + NumberFormat.getInstance().format(millis) + ", YGC " + ygc + " FGC " + fullGC);
|
||||
System.out.println("thread " + threadCount + " " + name + " millis : "
|
||||
+ NumberFormat.getInstance().format(millis) + ", YGC " + ygc + " FGC " + fullGC);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ public class Test0 extends TestCase {
|
||||
conn.close();
|
||||
System.out.println("raw size : " + driver.getConnections().size());
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
Connection conn = dataSource.getConnection();
|
||||
|
||||
@@ -48,7 +48,6 @@ public class Test0 extends TestCase {
|
||||
System.out.println("raw size : " + driver.getConnections().size());
|
||||
}
|
||||
|
||||
|
||||
dataSource.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ public class TestIdleForKylin extends TestCase {
|
||||
public void test_idle() throws Exception {
|
||||
MockDriver driver = MockDriver.instance;
|
||||
|
||||
// BasicDataSource dataSource = new BasicDataSource();
|
||||
// BasicDataSource dataSource = new BasicDataSource();
|
||||
DruidDataSource dataSource = new DruidDataSource();
|
||||
dataSource.setUrl("jdbc:mock:xxx");
|
||||
dataSource.setDriverClassName("com.alibaba.druid.mock.MockDriver");
|
||||
|
||||
@@ -58,7 +58,8 @@ public class DruidDataSourceUIManager extends JFrame {
|
||||
private JLabel lbPassword = new JLabel("Password : ");
|
||||
private JTextField txtPassword = new JTextField();
|
||||
|
||||
private JLabel lbConnectionProperties = new JLabel("Connection Properties : ");
|
||||
private JLabel lbConnectionProperties = new JLabel(
|
||||
"Connection Properties : ");
|
||||
private JTextField txtConnectionProperties = new JTextField();
|
||||
|
||||
private JLabel lbInitialSize = new JLabel("InitialSize : ");
|
||||
@@ -76,7 +77,8 @@ public class DruidDataSourceUIManager extends JFrame {
|
||||
private JLabel lbMaxWait = new JLabel("MaxWait : ");
|
||||
private JTextField txtMaxWait = new JTextField("-1");
|
||||
|
||||
private JLabel lbMinEvictableIdleTimeMillis = new JLabel("MinEvictableIdleTimeMillis : ");
|
||||
private JLabel lbMinEvictableIdleTimeMillis = new JLabel(
|
||||
"MinEvictableIdleTimeMillis : ");
|
||||
private JTextField txtMinEvictableIdleTimeMillis = new JTextField("1800000");
|
||||
|
||||
private DruidDataStatusPanel statusPanel = new DruidDataStatusPanel();
|
||||
@@ -138,7 +140,8 @@ public class DruidDataSourceUIManager extends JFrame {
|
||||
layout.putConstraint(SpringLayout.EAST, lbDriverClass, 0, SpringLayout.EAST, lbUrl);
|
||||
|
||||
mainPanel.add(txtDriverClass);
|
||||
layout.putConstraint(SpringLayout.VERTICAL_CENTER, txtDriverClass, 0, SpringLayout.VERTICAL_CENTER, lbDriverClass);
|
||||
layout.putConstraint(SpringLayout.VERTICAL_CENTER, txtDriverClass, 0, SpringLayout.VERTICAL_CENTER,
|
||||
lbDriverClass);
|
||||
layout.putConstraint(SpringLayout.WEST, txtDriverClass, 0, SpringLayout.WEST, txtUrl);
|
||||
layout.putConstraint(SpringLayout.EAST, txtDriverClass, 0, SpringLayout.EAST, txtUrl);
|
||||
|
||||
@@ -174,7 +177,8 @@ public class DruidDataSourceUIManager extends JFrame {
|
||||
layout.putConstraint(SpringLayout.EAST, lbConnectionProperties, 0, SpringLayout.EAST, lbUrl);
|
||||
|
||||
mainPanel.add(txtConnectionProperties);
|
||||
layout.putConstraint(SpringLayout.VERTICAL_CENTER, txtConnectionProperties, 0, SpringLayout.VERTICAL_CENTER, lbConnectionProperties);
|
||||
layout.putConstraint(SpringLayout.VERTICAL_CENTER, txtConnectionProperties, 0, SpringLayout.VERTICAL_CENTER,
|
||||
lbConnectionProperties);
|
||||
layout.putConstraint(SpringLayout.WEST, txtConnectionProperties, 0, SpringLayout.WEST, txtUrl);
|
||||
layout.putConstraint(SpringLayout.EAST, txtConnectionProperties, 0, SpringLayout.EAST, txtUrl);
|
||||
|
||||
@@ -186,7 +190,8 @@ public class DruidDataSourceUIManager extends JFrame {
|
||||
layout.putConstraint(SpringLayout.EAST, lbInitialSize, 0, SpringLayout.EAST, lbUrl);
|
||||
|
||||
mainPanel.add(txtInitialSize);
|
||||
layout.putConstraint(SpringLayout.VERTICAL_CENTER, txtInitialSize, 0, SpringLayout.VERTICAL_CENTER, lbInitialSize);
|
||||
layout.putConstraint(SpringLayout.VERTICAL_CENTER, txtInitialSize, 0, SpringLayout.VERTICAL_CENTER,
|
||||
lbInitialSize);
|
||||
layout.putConstraint(SpringLayout.WEST, txtInitialSize, 0, SpringLayout.WEST, txtUrl);
|
||||
layout.putConstraint(SpringLayout.EAST, txtInitialSize, 0, SpringLayout.EAST, txtUrl);
|
||||
|
||||
@@ -246,19 +251,22 @@ public class DruidDataSourceUIManager extends JFrame {
|
||||
layout.putConstraint(SpringLayout.EAST, lbMinEvictableIdleTimeMillis, 0, SpringLayout.EAST, lbUrl);
|
||||
|
||||
mainPanel.add(txtMinEvictableIdleTimeMillis);
|
||||
layout.putConstraint(SpringLayout.VERTICAL_CENTER, txtMinEvictableIdleTimeMillis, 0, SpringLayout.VERTICAL_CENTER, lbMinEvictableIdleTimeMillis);
|
||||
layout.putConstraint(SpringLayout.VERTICAL_CENTER, txtMinEvictableIdleTimeMillis, 0,
|
||||
SpringLayout.VERTICAL_CENTER, lbMinEvictableIdleTimeMillis);
|
||||
layout.putConstraint(SpringLayout.WEST, txtMinEvictableIdleTimeMillis, 0, SpringLayout.WEST, txtUrl);
|
||||
layout.putConstraint(SpringLayout.EAST, txtMinEvictableIdleTimeMillis, 0, SpringLayout.EAST, txtUrl);
|
||||
|
||||
// ////
|
||||
|
||||
mainPanel.add(lbValidationQuery);
|
||||
layout.putConstraint(SpringLayout.NORTH, lbValidationQuery, 10, SpringLayout.SOUTH, lbMinEvictableIdleTimeMillis);
|
||||
layout.putConstraint(SpringLayout.NORTH, lbValidationQuery, 10, SpringLayout.SOUTH,
|
||||
lbMinEvictableIdleTimeMillis);
|
||||
layout.putConstraint(SpringLayout.WEST, lbValidationQuery, 0, SpringLayout.WEST, lbUrl);
|
||||
layout.putConstraint(SpringLayout.EAST, lbValidationQuery, 0, SpringLayout.EAST, lbUrl);
|
||||
|
||||
mainPanel.add(txtValidationQuery);
|
||||
layout.putConstraint(SpringLayout.VERTICAL_CENTER, txtValidationQuery, 0, SpringLayout.VERTICAL_CENTER, lbValidationQuery);
|
||||
layout.putConstraint(SpringLayout.VERTICAL_CENTER, txtValidationQuery, 0, SpringLayout.VERTICAL_CENTER,
|
||||
lbValidationQuery);
|
||||
layout.putConstraint(SpringLayout.WEST, txtValidationQuery, 0, SpringLayout.WEST, txtUrl);
|
||||
layout.putConstraint(SpringLayout.EAST, txtValidationQuery, 0, SpringLayout.EAST, txtUrl);
|
||||
// ////
|
||||
@@ -269,7 +277,8 @@ public class DruidDataSourceUIManager extends JFrame {
|
||||
layout.putConstraint(SpringLayout.EAST, lbTestWhileIdle, 0, SpringLayout.EAST, lbUrl);
|
||||
|
||||
mainPanel.add(txtTestWhileIdle);
|
||||
layout.putConstraint(SpringLayout.VERTICAL_CENTER, txtTestWhileIdle, 0, SpringLayout.VERTICAL_CENTER, lbTestWhileIdle);
|
||||
layout.putConstraint(SpringLayout.VERTICAL_CENTER, txtTestWhileIdle, 0, SpringLayout.VERTICAL_CENTER,
|
||||
lbTestWhileIdle);
|
||||
layout.putConstraint(SpringLayout.WEST, txtTestWhileIdle, 0, SpringLayout.WEST, txtUrl);
|
||||
layout.putConstraint(SpringLayout.EAST, txtTestWhileIdle, 0, SpringLayout.EAST, txtUrl);
|
||||
|
||||
@@ -279,7 +288,8 @@ public class DruidDataSourceUIManager extends JFrame {
|
||||
layout.putConstraint(SpringLayout.EAST, lbTestOnBorrow, 0, SpringLayout.EAST, lbUrl);
|
||||
|
||||
mainPanel.add(txtTestOnBorrow);
|
||||
layout.putConstraint(SpringLayout.VERTICAL_CENTER, txtTestOnBorrow, 0, SpringLayout.VERTICAL_CENTER, lbTestOnBorrow);
|
||||
layout.putConstraint(SpringLayout.VERTICAL_CENTER, txtTestOnBorrow, 0, SpringLayout.VERTICAL_CENTER,
|
||||
lbTestOnBorrow);
|
||||
layout.putConstraint(SpringLayout.WEST, txtTestOnBorrow, 0, SpringLayout.WEST, txtUrl);
|
||||
layout.putConstraint(SpringLayout.EAST, txtTestOnBorrow, 0, SpringLayout.EAST, txtUrl);
|
||||
|
||||
@@ -297,7 +307,8 @@ public class DruidDataSourceUIManager extends JFrame {
|
||||
});
|
||||
|
||||
mainPanel.add(btnCloseDataSource);
|
||||
layout.putConstraint(SpringLayout.VERTICAL_CENTER, btnCloseDataSource, 0, SpringLayout.VERTICAL_CENTER, btnInitDataSource);
|
||||
layout.putConstraint(SpringLayout.VERTICAL_CENTER, btnCloseDataSource, 0, SpringLayout.VERTICAL_CENTER,
|
||||
btnInitDataSource);
|
||||
layout.putConstraint(SpringLayout.WEST, btnCloseDataSource, 10, SpringLayout.EAST, btnInitDataSource);
|
||||
btnCloseDataSource.addActionListener(new ActionListener() {
|
||||
|
||||
@@ -312,7 +323,8 @@ public class DruidDataSourceUIManager extends JFrame {
|
||||
btnCase_0.setEnabled(false);
|
||||
|
||||
mainPanel.add(btnConnect);
|
||||
layout.putConstraint(SpringLayout.VERTICAL_CENTER, btnConnect, 0, SpringLayout.VERTICAL_CENTER, btnInitDataSource);
|
||||
layout.putConstraint(SpringLayout.VERTICAL_CENTER, btnConnect, 0, SpringLayout.VERTICAL_CENTER,
|
||||
btnInitDataSource);
|
||||
layout.putConstraint(SpringLayout.WEST, btnConnect, 10, SpringLayout.EAST, btnCloseDataSource);
|
||||
btnConnect.addActionListener(new ActionListener() {
|
||||
|
||||
@@ -323,7 +335,8 @@ public class DruidDataSourceUIManager extends JFrame {
|
||||
});
|
||||
|
||||
mainPanel.add(txtGetStep);
|
||||
layout.putConstraint(SpringLayout.VERTICAL_CENTER, txtGetStep, 0, SpringLayout.VERTICAL_CENTER, btnInitDataSource);
|
||||
layout.putConstraint(SpringLayout.VERTICAL_CENTER, txtGetStep, 0, SpringLayout.VERTICAL_CENTER,
|
||||
btnInitDataSource);
|
||||
layout.putConstraint(SpringLayout.WEST, txtGetStep, 10, SpringLayout.EAST, btnConnect);
|
||||
layout.putConstraint(SpringLayout.EAST, txtGetStep, 40, SpringLayout.WEST, txtGetStep);
|
||||
|
||||
@@ -354,7 +367,8 @@ public class DruidDataSourceUIManager extends JFrame {
|
||||
});
|
||||
|
||||
mainPanel.add(txtReleaseStep);
|
||||
layout.putConstraint(SpringLayout.VERTICAL_CENTER, txtReleaseStep, 0, SpringLayout.VERTICAL_CENTER, btnInitDataSource);
|
||||
layout.putConstraint(SpringLayout.VERTICAL_CENTER, txtReleaseStep, 0, SpringLayout.VERTICAL_CENTER,
|
||||
btnInitDataSource);
|
||||
layout.putConstraint(SpringLayout.WEST, txtReleaseStep, 10, SpringLayout.EAST, btnClose);
|
||||
layout.putConstraint(SpringLayout.EAST, txtReleaseStep, 40, SpringLayout.WEST, txtReleaseStep);
|
||||
|
||||
@@ -380,7 +394,7 @@ public class DruidDataSourceUIManager extends JFrame {
|
||||
layout.putConstraint(SpringLayout.NORTH, statusPanel, 10, SpringLayout.SOUTH, btnInitDataSource);
|
||||
layout.putConstraint(SpringLayout.SOUTH, statusPanel, 120, SpringLayout.NORTH, statusPanel);
|
||||
layout.putConstraint(SpringLayout.WEST, statusPanel, 0, SpringLayout.WEST, lbUrl);
|
||||
//layout.putConstraint(SpringLayout.EAST, txtMaxWait, 0, SpringLayout.EAST, mainPanel);
|
||||
// layout.putConstraint(SpringLayout.EAST, txtMaxWait, 0, SpringLayout.EAST, mainPanel);
|
||||
|
||||
// ////
|
||||
|
||||
@@ -479,7 +493,7 @@ public class DruidDataSourceUIManager extends JFrame {
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
executor = Executors.newCachedThreadPool();
|
||||
|
||||
txtDriverClass.setText(dataSource.getDriverClassName());
|
||||
@@ -591,7 +605,8 @@ public class DruidDataSourceUIManager extends JFrame {
|
||||
long ygc = TestUtil.getYoungGC() - startYGC;
|
||||
long fullGC = TestUtil.getFullGC() - startFullGC;
|
||||
|
||||
System.out.println("thread " + threadCount + " druid millis : " + NumberFormat.getInstance().format(millis) + ", YGC " + ygc + " FGC " + fullGC);
|
||||
System.out.println("thread " + threadCount + " druid millis : "
|
||||
+ NumberFormat.getInstance().format(millis) + ", YGC " + ygc + " FGC " + fullGC);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -15,7 +15,8 @@ public class DruidDataStatusPanel extends JPanel {
|
||||
private final Map<String, JTextField> fields = new HashMap<String, JTextField>();
|
||||
|
||||
private final String[] fieldNames = new String[] { //
|
||||
"CreateCount", "CreateErrorCount", "CreateTimespanMillis", "CreateTimespanNano", "DestroyCount", //
|
||||
"CreateCount", "CreateErrorCount", "CreateTimespanMillis",
|
||||
"CreateTimespanNano", "DestroyCount", //
|
||||
"ConnectCount", "ConnectErrorCount", "CloseCount", "RecycleCount", "ActiveCount", //
|
||||
"PoolingCount", "IdleCheckCount", "UI_GettingCount", "UI_GetCount", "UI_ReleaseCount" //
|
||||
, "UI_ExecutingCount" //
|
||||
|
||||
@@ -25,27 +25,27 @@ public class OnlineSQLTest extends TestCase {
|
||||
|
||||
public void test_list_sql() throws Exception {
|
||||
// reset();
|
||||
|
||||
|
||||
// 这些中文括号
|
||||
//update(7216, "", 4);
|
||||
//update(7223, "", 4);
|
||||
//update(8387, "", 4);
|
||||
|
||||
// update(7216, "", 4);
|
||||
// update(7223, "", 4);
|
||||
// update(8387, "", 4);
|
||||
|
||||
// 语法错误
|
||||
// update(17018, "", 4); //alarm_type&?
|
||||
// update(17841, "", 4); //alarm_type&?
|
||||
// update(17845, "", 4); //alarm_type&?
|
||||
// update(18247, "", 4); //alarm_type&?
|
||||
// update(19469, "", 4); //alarm_type&?
|
||||
update(19730, "", 4); //alarm_type&?
|
||||
update(20164, "", 4); //alarm_type&?
|
||||
update(20386, "", 4); //alarm_type&?
|
||||
update(20440, "", 4); //alarm_type&?
|
||||
update(21208, "", 4); //alarm_type&?
|
||||
|
||||
// IBATIS NAME
|
||||
update(18035, "", 4); //alarm_type&?
|
||||
|
||||
// update(17018, "", 4); //alarm_type&?
|
||||
// update(17841, "", 4); //alarm_type&?
|
||||
// update(17845, "", 4); //alarm_type&?
|
||||
// update(18247, "", 4); //alarm_type&?
|
||||
// update(19469, "", 4); //alarm_type&?
|
||||
update(19730, "", 4); // alarm_type&?
|
||||
update(20164, "", 4); // alarm_type&?
|
||||
update(20386, "", 4); // alarm_type&?
|
||||
update(20440, "", 4); // alarm_type&?
|
||||
update(21208, "", 4); // alarm_type&?
|
||||
|
||||
// IBATIS NAME
|
||||
update(18035, "", 4); // alarm_type&?
|
||||
|
||||
Connection conn = DriverManager.getConnection(url, user, password);
|
||||
|
||||
int count = 0;
|
||||
@@ -55,12 +55,12 @@ public class OnlineSQLTest extends TestCase {
|
||||
while (rs.next()) {
|
||||
int id = rs.getInt(1);
|
||||
String value = rs.getString(2);
|
||||
|
||||
|
||||
if (value.indexOf('(') != -1) {
|
||||
update(id, "", 4);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
System.out.println(value);
|
||||
System.out.println();
|
||||
try {
|
||||
@@ -109,8 +109,8 @@ public class OnlineSQLTest extends TestCase {
|
||||
sql = sql.trim();
|
||||
boolean sqlFlag = false;
|
||||
String lowerSql = sql.toLowerCase();
|
||||
if (lowerSql.startsWith("insert") || lowerSql.startsWith("select") || lowerSql.startsWith("upate") || lowerSql.startsWith("delete")
|
||||
|| lowerSql.startsWith("create") || lowerSql.startsWith("drop")) {
|
||||
if (lowerSql.startsWith("insert") || lowerSql.startsWith("select") || lowerSql.startsWith("upate")
|
||||
|| lowerSql.startsWith("delete") || lowerSql.startsWith("create") || lowerSql.startsWith("drop")) {
|
||||
sqlFlag = true;
|
||||
}
|
||||
|
||||
@@ -138,8 +138,8 @@ public class OnlineSQLTest extends TestCase {
|
||||
sql = sql.trim();
|
||||
boolean sqlFlag = false;
|
||||
String lowerSql = sql.toLowerCase();
|
||||
if (lowerSql.startsWith("insert") || lowerSql.startsWith("select") || lowerSql.startsWith("upate") || lowerSql.startsWith("delete")
|
||||
|| lowerSql.startsWith("create") || lowerSql.startsWith("drop")) {
|
||||
if (lowerSql.startsWith("insert") || lowerSql.startsWith("select") || lowerSql.startsWith("upate")
|
||||
|| lowerSql.startsWith("delete") || lowerSql.startsWith("create") || lowerSql.startsWith("drop")) {
|
||||
sqlFlag = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -63,8 +63,8 @@ public class OnlineSQLTest2 extends TestCase {
|
||||
sql = sql.trim();
|
||||
boolean sqlFlag = false;
|
||||
String lowerSql = sql.toLowerCase();
|
||||
if (lowerSql.startsWith("insert") || lowerSql.startsWith("select") || lowerSql.startsWith("upate") || lowerSql.startsWith("delete")
|
||||
|| lowerSql.startsWith("create") || lowerSql.startsWith("drop")) {
|
||||
if (lowerSql.startsWith("insert") || lowerSql.startsWith("select") || lowerSql.startsWith("upate")
|
||||
|| lowerSql.startsWith("delete") || lowerSql.startsWith("create") || lowerSql.startsWith("drop")) {
|
||||
sqlFlag = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,11 +25,11 @@ public class TestOnlineSQLTest3 extends TestCase {
|
||||
conn = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void test_0 () throws Exception {
|
||||
|
||||
public void test_0() throws Exception {
|
||||
String sql = "SELECT * FROM m_sql_const";
|
||||
Statement stmt = conn.createStatement();
|
||||
|
||||
|
||||
ResultSet rs = stmt.executeQuery(sql);
|
||||
while (rs.next()) {
|
||||
long id = rs.getLong(1);
|
||||
@@ -37,15 +37,13 @@ public class TestOnlineSQLTest3 extends TestCase {
|
||||
handle(id, value);
|
||||
}
|
||||
rs.close();
|
||||
|
||||
|
||||
stmt.close();
|
||||
}
|
||||
|
||||
|
||||
void handle(long id, String value) {
|
||||
String sql = value.toString();
|
||||
|
||||
|
||||
|
||||
|
||||
System.out.println(sql);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ public class ArithmeticOperatorsTest extends TestCase {
|
||||
|
||||
Assert.assertEquals("SELECT N % M;", text);
|
||||
}
|
||||
|
||||
|
||||
public void test_12() throws Exception {
|
||||
String sql = "SELECT 1 = 0 OR A > ?;";
|
||||
|
||||
@@ -169,15 +169,15 @@ public class ArithmeticOperatorsTest extends TestCase {
|
||||
|
||||
Assert.assertEquals("SELECT 1 = 0 OR A > ?;", text);
|
||||
}
|
||||
|
||||
|
||||
public void test_13() throws Exception {
|
||||
String sql = "SELECT 1 = 0 AND ID = ?;";
|
||||
|
||||
|
||||
SQLStatementParser parser = new MySqlStatementParser(sql);
|
||||
List<SQLStatement> stmtList = parser.parseStatementList();
|
||||
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
|
||||
Assert.assertEquals("SELECT 1 = 0 AND ID = ?;", text);
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +79,8 @@ public class CastFunctionsAndOperatorsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT 'A' LIKE CONVERT(blob_col USING latin1) COLLATE latin1_german1_ci\nFROM tbl_name;", text);
|
||||
Assert.assertEquals("SELECT 'A' LIKE CONVERT(blob_col USING latin1) COLLATE latin1_german1_ci\nFROM tbl_name;",
|
||||
text);
|
||||
}
|
||||
|
||||
public void test_5() throws Exception {
|
||||
|
||||
@@ -35,7 +35,8 @@ public class DateAndTimeFunctionsTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT something\nFROM tbl_name\nWHERE DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date_col;", text);
|
||||
Assert.assertEquals("SELECT something\nFROM tbl_name\nWHERE DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date_col;",
|
||||
text);
|
||||
}
|
||||
|
||||
public void test_1() throws Exception {
|
||||
|
||||
+2
-1
@@ -35,7 +35,8 @@ public class FullTextSearchesWithQueryExpansionTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("SELECT *\nFROM articles\nWHERE MATCH (title, body) AGAINST ('database' IN NATURAL LANGUAGE MODE);", text);
|
||||
Assert.assertEquals("SELECT *\nFROM articles\nWHERE MATCH (title, body) AGAINST ('database' IN NATURAL LANGUAGE MODE);",
|
||||
text);
|
||||
}
|
||||
|
||||
private String output(List<SQLStatement> stmtList) {
|
||||
|
||||
@@ -90,7 +90,8 @@ public class InsertSyntaxTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("INSERT LOW_PRIORITY DELAYED HIGH_PRIORITY IGNORE INTO tbl_name\n\t(a, b, c)\nVALUES\n(1, 2, 3);", text);
|
||||
Assert.assertEquals("INSERT LOW_PRIORITY DELAYED HIGH_PRIORITY IGNORE INTO tbl_name\n\t(a, b, c)\nVALUES\n(1, 2, 3);",
|
||||
text);
|
||||
}
|
||||
|
||||
public void test_6() throws Exception {
|
||||
@@ -101,7 +102,8 @@ public class InsertSyntaxTest extends TestCase {
|
||||
|
||||
String text = output(stmtList);
|
||||
|
||||
Assert.assertEquals("INSERT INTO tbl_name\n\t(a, b, c)\nVALUES\n(1, 2, 3) ON DUPLICATE KEY UPDATE c = c + 1;", text);
|
||||
Assert.assertEquals("INSERT INTO tbl_name\n\t(a, b, c)\nVALUES\n(1, 2, 3) ON DUPLICATE KEY UPDATE c = c + 1;",
|
||||
text);
|
||||
}
|
||||
|
||||
private String output(List<SQLStatement> stmtList) {
|
||||
|
||||
+7
-5
@@ -19,12 +19,14 @@ public class MySqlParameterizedOutputVisitorTest extends TestCase {
|
||||
validate("SELECT * FROM T WHERE 1 = 0 AND ID = 5", "SELECT * FROM T WHERE 1 = 0 AND ID = ?");
|
||||
validate("SELECT * FROM T WHERE ID = ? OR ID = ?", "SELECT * FROM T WHERE ID = ?");
|
||||
validate("SELECT * FROM T WHERE A.ID = ? OR A.ID = ?", "SELECT * FROM T WHERE A.ID = ?");
|
||||
validate("SELECT * FROM T WHERE 1 = 0 OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ?", "SELECT * FROM T WHERE 1 = 0 OR a.id = ?");
|
||||
validateOracle("SELECT * FROM T WHERE 1 = 0 OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ?", "SELECT * FROM T WHERE 1 = 0 OR a.id = ?; ");
|
||||
validate("SELECT * FROM T WHERE 1 = 0 OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ?",
|
||||
"SELECT * FROM T WHERE 1 = 0 OR a.id = ?");
|
||||
validateOracle("SELECT * FROM T WHERE 1 = 0 OR a.id = ? OR a.id = ? OR a.id = ? OR a.id = ?",
|
||||
"SELECT * FROM T WHERE 1 = 0 OR a.id = ?; ");
|
||||
validateOracle("SELECT * FROM T WHERE A.ID = ? OR A.ID = ?", "SELECT * FROM T WHERE A.ID = ?; ");
|
||||
validate("INSERT INTO T (F1, F2) VALUES(?, ?), (?, ?), (?, ?)", "INSERT INTO T (F1, F2) VALUES (?, ?)");
|
||||
|
||||
//System.out.println("SELECT * FORM A WHERE ID = (##)".replaceAll("##", "?"));
|
||||
|
||||
// System.out.println("SELECT * FORM A WHERE ID = (##)".replaceAll("##", "?"));
|
||||
}
|
||||
|
||||
void validate(String sql, String expect) {
|
||||
@@ -41,7 +43,7 @@ public class MySqlParameterizedOutputVisitorTest extends TestCase {
|
||||
|
||||
Assert.assertEquals(expect, out.toString());
|
||||
}
|
||||
|
||||
|
||||
void validateOracle(String sql, String expect) {
|
||||
|
||||
OracleStatementParser parser = new OracleStatementParser(sql);
|
||||
|
||||
@@ -42,7 +42,7 @@ public class MySqlResourceTest extends TestCase {
|
||||
String[] items = input.split("---------------------------");
|
||||
String sql = items[0].trim();
|
||||
String expect = items[1].trim();
|
||||
|
||||
|
||||
MySqlStatementParser parser = new MySqlStatementParser(sql);
|
||||
List<SQLStatement> statementList = parser.parseStatementList();
|
||||
SQLStatement statemen = statementList.get(0);
|
||||
@@ -55,7 +55,7 @@ public class MySqlResourceTest extends TestCase {
|
||||
System.out.println(sql);
|
||||
System.out.println("Tables : " + visitor.getTables());
|
||||
System.out.println("fields : " + visitor.getFields());
|
||||
|
||||
|
||||
System.out.println();
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ public class MySqlSchemaStatVisitorTest1 extends TestCase {
|
||||
Assert.assertEquals(true, visitor.getFields().contains(new Column("usergroups", "name")));
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void test_1() throws Exception {
|
||||
String sql = "select a.name, b.name FROM users a, usergroups b on a.groupId = b.id where a.groupID = ?";
|
||||
|
||||
|
||||
+2
-2
@@ -36,7 +36,7 @@ public class MySqlSchemaStatVisitorTest2 extends TestCase {
|
||||
Assert.assertEquals(true, visitor.getFields().contains(new Column("users", "name")));
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void test_2() throws Exception {
|
||||
String sql = "select id, name FROM users a";
|
||||
|
||||
@@ -61,7 +61,7 @@ public class MySqlSchemaStatVisitorTest2 extends TestCase {
|
||||
Assert.assertEquals(true, visitor.getFields().contains(new Column("users", "name")));
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void test_3() throws Exception {
|
||||
String sql = "select id, a.name FROM users a";
|
||||
|
||||
|
||||
+1
-2
@@ -40,6 +40,5 @@ public class MySqlSchemaStatVisitorTest3 extends TestCase {
|
||||
Assert.assertEquals(true, visitor.getFields().contains(new Column("users2", "id2")));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -33,8 +33,6 @@ public class CallTest extends TestCase {
|
||||
|
||||
output(statementList);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void output(List<SQLStatement> stmtList) {
|
||||
StringBuilder out = new StringBuilder();
|
||||
@@ -44,7 +42,7 @@ public class CallTest extends TestCase {
|
||||
stmt.accept(visitor);
|
||||
visitor.println();
|
||||
}
|
||||
|
||||
|
||||
System.out.println(out.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,10 +16,10 @@ import com.alibaba.druid.util.JdbcUtils;
|
||||
public class OracleSQLParserResourceTest extends TestCase {
|
||||
|
||||
public void test_0() throws Exception {
|
||||
// for (int i = 0; i <= 53; ++i) {
|
||||
// String resource = "bvt/parser/oracle-" + i + ".txt";
|
||||
// exec_test(resource);
|
||||
// }
|
||||
// for (int i = 0; i <= 53; ++i) {
|
||||
// String resource = "bvt/parser/oracle-" + i + ".txt";
|
||||
// exec_test(resource);
|
||||
// }
|
||||
exec_test("bvt/parser/oracle-54.txt");
|
||||
}
|
||||
|
||||
|
||||
@@ -33,13 +33,13 @@ public class OracleSelectParserTest extends TestCase {
|
||||
|
||||
output(statementList);
|
||||
}
|
||||
|
||||
|
||||
public void test_hinits() throws Exception {
|
||||
String sql = "SELECT /*+FIRST_ROWS*/ * FROM T";
|
||||
|
||||
|
||||
OracleStatementParser parser = new OracleStatementParser(sql);
|
||||
List<SQLStatement> statementList = parser.parseStatementList();
|
||||
|
||||
|
||||
output(statementList);
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class OracleSelectParserTest extends TestCase {
|
||||
stmt.accept(visitor);
|
||||
visitor.println();
|
||||
}
|
||||
|
||||
|
||||
System.out.println(out.toString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@ public class OracleResourceTest extends TestCase {
|
||||
public void test_0() throws Exception {
|
||||
// 13
|
||||
exec_test("bvt/parser/oracle-53.txt");
|
||||
// for (int i = 0; i <= 53; ++i) {
|
||||
// exec_test("bvt/parser/oracle-" + i + ".txt");
|
||||
// }
|
||||
// for (int i = 0; i <= 53; ++i) {
|
||||
// exec_test("bvt/parser/oracle-" + i + ".txt");
|
||||
// }
|
||||
}
|
||||
|
||||
public void exec_test(String resource) throws Exception {
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ public class OracleSchemaStatVisitorTest1 extends TestCase {
|
||||
Assert.assertEquals(true, visitor.getFields().contains(new Column("usergroups", "name")));
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void test_1() throws Exception {
|
||||
String sql = "select a.name, b.name FROM users a, usergroups b on a.groupId = b.id where a.groupID = ?";
|
||||
|
||||
|
||||
+2
-2
@@ -36,7 +36,7 @@ public class OracleSchemaStatVisitorTest2 extends TestCase {
|
||||
Assert.assertEquals(true, visitor.getFields().contains(new Column("users", "name")));
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void test_2() throws Exception {
|
||||
String sql = "select id, name FROM users a";
|
||||
|
||||
@@ -61,7 +61,7 @@ public class OracleSchemaStatVisitorTest2 extends TestCase {
|
||||
Assert.assertEquals(true, visitor.getFields().contains(new Column("users", "name")));
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void test_3() throws Exception {
|
||||
String sql = "select id, a.name FROM users a";
|
||||
|
||||
|
||||
+1
-2
@@ -40,6 +40,5 @@ public class OracleSchemaStatVisitorTest3 extends TestCase {
|
||||
Assert.assertEquals(true, visitor.getFields().contains(new Column("users2", "id2")));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -9,7 +9,8 @@ import com.alibaba.druid.sql.dialect.oracle.parser.OracleStatementParser;
|
||||
import com.alibaba.druid.sql.dialect.oracle.visitor.OracleOutputVisitor;
|
||||
|
||||
public class CommentTest extends TestCase {
|
||||
public void test_0 () throws Exception {
|
||||
|
||||
public void test_0() throws Exception {
|
||||
String sql = "SELECT /*mark for picman*/ * FROM WP_ALBUM WHERE MEMBER_ID = ? AND ID IN (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
||||
|
||||
Lexer lexer = new Lexer(sql);
|
||||
@@ -20,7 +21,7 @@ public class CommentTest extends TestCase {
|
||||
if (tok == Token.IDENTIFIER) {
|
||||
System.out.println(tok.name() + "\t\t" + lexer.stringVal());
|
||||
} else if (tok == Token.MULTI_LINE_COMMENT) {
|
||||
System.out.println(tok.name() + "\t\t" + lexer.stringVal());
|
||||
System.out.println(tok.name() + "\t\t" + lexer.stringVal());
|
||||
} else {
|
||||
System.out.println(tok.name() + "\t\t\t" + tok.name);
|
||||
}
|
||||
@@ -30,8 +31,8 @@ public class CommentTest extends TestCase {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void test_1 () throws Exception {
|
||||
|
||||
public void test_1() throws Exception {
|
||||
String sql = "SELECT /*mark for picman*/ * FROM WP_ALBUM WHERE MEMBER_ID = ? AND ID IN (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
||||
|
||||
StringBuilder out = new StringBuilder();
|
||||
|
||||
@@ -21,7 +21,7 @@ public class PerfTest extends TestCase {
|
||||
// perf("SELECT * FROM my_table WHERE TRUNC(SYSDATE) = DATE '2002-10-03';");
|
||||
perfOracle("SELECT * FROM T");
|
||||
perfMySql("SELECT * FROM T");
|
||||
//perf(loadSql("bvt/parser/oracle-23.txt"));
|
||||
// perf(loadSql("bvt/parser/oracle-23.txt"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ public class PerfTest extends TestCase {
|
||||
long millis = System.currentTimeMillis() - startMillis;
|
||||
System.out.println("Oracle\t" + millis);
|
||||
}
|
||||
|
||||
|
||||
void perfMySql(String sql) {
|
||||
long startMillis = System.currentTimeMillis();
|
||||
for (int i = 0; i < 1000 * 1000; ++i) {
|
||||
|
||||
@@ -51,6 +51,7 @@ public class SQLMergeTest extends TestCase {
|
||||
private String merge() {
|
||||
StringBuilder out = new StringBuilder();
|
||||
OracleOutputVisitor visitor = new OracleOutputVisitor(out) {
|
||||
|
||||
public boolean visit(SQLInListExpr x) {
|
||||
x.getExpr().accept(this);
|
||||
|
||||
|
||||
@@ -30,10 +30,10 @@ public class TestBeidou extends TestCase {
|
||||
|
||||
PreparedStatement stmt = conn.prepareStatement("select sysdate");
|
||||
stmt.executeBatch();
|
||||
|
||||
|
||||
String catalog = conn.getCatalog();
|
||||
System.out.println(catalog);
|
||||
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
}
|
||||
|
||||
@@ -30,10 +30,10 @@ public class TestOracle extends TestCase {
|
||||
|
||||
PreparedStatement stmt = conn.prepareStatement("select sysdate");
|
||||
stmt.executeBatch();
|
||||
|
||||
|
||||
String catalog = conn.getCatalog();
|
||||
System.out.println(catalog);
|
||||
|
||||
|
||||
stmt.close();
|
||||
conn.close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user