This commit is contained in:
xiusiyan
2012-03-18 22:57:34 +08:00
1153 changed files with 145776 additions and 145758 deletions
@@ -1,46 +1,46 @@
package com.alibaba.druid.proxy;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.TreeMap;
import javax.management.openmbean.TabularData;
import junit.framework.TestCase;
import com.alibaba.druid.stat.JdbcStatManager;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
public class TestOracle extends TestCase {
private String jdbcUrl;
private String user;
private String password;
public void setUp() throws Exception {
jdbcUrl = "jdbc:wrap-jdbc:filters=default:name=oracleTest:jdbc:oracle:thin:@10.20.149.85:1521:ocnauto";
// jdbcUrl = "jdbc:wrap-jdbc:filters=default:name=oracleTest:jdbc:mock:xx";
user = "alibaba";
password = "ccbuauto";
}
public void test_0() throws Exception {
Connection conn = DriverManager.getConnection(jdbcUrl, user, password);
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT 1 FROM DUAL");
rs.next();
rs.close();
stmt.close();
conn.close();
TabularData dataSourcesList = JdbcStatManager.getInstance().getDataSourceList();
for (Object item : dataSourcesList.values()) {
String text = JSON.toJSONString(item, SerializerFeature.UseISO8601DateFormat);
System.out.println(JSON.toJSONString(JSON.parseObject(text, TreeMap.class), true));
}
}
}
package com.alibaba.druid.proxy;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.TreeMap;
import javax.management.openmbean.TabularData;
import junit.framework.TestCase;
import com.alibaba.druid.stat.JdbcStatManager;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
public class TestOracle extends TestCase {
private String jdbcUrl;
private String user;
private String password;
public void setUp() throws Exception {
jdbcUrl = "jdbc:wrap-jdbc:filters=default:name=oracleTest:jdbc:oracle:thin:@10.20.149.85:1521:ocnauto";
// jdbcUrl = "jdbc:wrap-jdbc:filters=default:name=oracleTest:jdbc:mock:xx";
user = "alibaba";
password = "ccbuauto";
}
public void test_0() throws Exception {
Connection conn = DriverManager.getConnection(jdbcUrl, user, password);
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT 1 FROM DUAL");
rs.next();
rs.close();
stmt.close();
conn.close();
TabularData dataSourcesList = JdbcStatManager.getInstance().getDataSourceList();
for (Object item : dataSourcesList.values()) {
String text = JSON.toJSONString(item, SerializerFeature.UseISO8601DateFormat);
System.out.println(JSON.toJSONString(JSON.parseObject(text, TreeMap.class), true));
}
}
}
@@ -1,45 +1,45 @@
/*
* Copyright 1999-2011 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.druid.proxy.demo;
import java.sql.Connection;
import java.sql.DriverManager;
import com.alibaba.druid.stat.JdbcStatManager;
import junit.framework.Assert;
import junit.framework.TestCase;
public class Demo1 extends TestCase {
public void test_0() throws Exception {
JdbcStatManager.getInstance().reset(); // 重置计数器
Assert.assertEquals(0, JdbcStatManager.getInstance().getConnectionstat().getConnectCount());
Assert.assertEquals(0, JdbcStatManager.getInstance().getConnectionstat().getCloseCount());
String url = "jdbc:wrap-jdbc:filters=default:name=preCallTest:jdbc:derby:memory:Demo1;create=true";
Connection conn = DriverManager.getConnection(url);
Assert.assertEquals(1, JdbcStatManager.getInstance().getConnectionstat().getConnectCount());
Assert.assertEquals(0, JdbcStatManager.getInstance().getConnectionstat().getCloseCount());
conn.close();
Assert.assertEquals(1, JdbcStatManager.getInstance().getConnectionstat().getConnectCount());
Assert.assertEquals(1, JdbcStatManager.getInstance().getConnectionstat().getCloseCount());
}
}
/*
* Copyright 1999-2011 Alibaba Group Holding Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.alibaba.druid.proxy.demo;
import java.sql.Connection;
import java.sql.DriverManager;
import com.alibaba.druid.stat.JdbcStatManager;
import junit.framework.Assert;
import junit.framework.TestCase;
public class Demo1 extends TestCase {
public void test_0() throws Exception {
JdbcStatManager.getInstance().reset(); // 重置计数器
Assert.assertEquals(0, JdbcStatManager.getInstance().getConnectionstat().getConnectCount());
Assert.assertEquals(0, JdbcStatManager.getInstance().getConnectionstat().getCloseCount());
String url = "jdbc:wrap-jdbc:filters=default:name=preCallTest:jdbc:derby:memory:Demo1;create=true";
Connection conn = DriverManager.getConnection(url);
Assert.assertEquals(1, JdbcStatManager.getInstance().getConnectionstat().getConnectCount());
Assert.assertEquals(0, JdbcStatManager.getInstance().getConnectionstat().getCloseCount());
conn.close();
Assert.assertEquals(1, JdbcStatManager.getInstance().getConnectionstat().getConnectCount());
Assert.assertEquals(1, JdbcStatManager.getInstance().getConnectionstat().getCloseCount());
}
}