mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
enhance spring support
This commit is contained in:
@@ -118,7 +118,7 @@ public class DruidDataSourceFactory implements ObjectFactory {
|
||||
* @param properties the datasource configuration properties
|
||||
* @throws Exception if an error occurs creating the data source
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@SuppressWarnings({ "deprecation", "rawtypes" })
|
||||
public static DataSource createDataSource(Map properties) throws Exception {
|
||||
DruidDataSource dataSource = new DruidDataSource();
|
||||
String value = null;
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.alibaba.druid.support.spring;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
|
||||
import javax.management.MBeanServer;
|
||||
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
|
||||
public class MBeanServerFactoryBean implements FactoryBean {
|
||||
|
||||
public MBeanServer getObject() throws Exception {
|
||||
return ManagementFactory.getPlatformMBeanServer();
|
||||
}
|
||||
|
||||
public Class<?> getObjectType() {
|
||||
return ManagementFactory.getPlatformMBeanServer().getClass();
|
||||
}
|
||||
|
||||
public boolean isSingleton() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -46,17 +46,17 @@ public class Case0 extends TestCase {
|
||||
|
||||
private long minEvictableIdleTimeMillis = 3000;
|
||||
public final int LOOP_COUNT = 5;
|
||||
public final int COUNT = 1000 * 1000;
|
||||
public final int COUNT = 1000 * 1000 * 1;
|
||||
|
||||
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";
|
||||
jdbcUrl = "jdbc:mysql://10.20.159.104:3306/masterdb";
|
||||
user = "dragoon";
|
||||
password = "dragoon";
|
||||
}
|
||||
|
||||
public void test_0() throws Exception {
|
||||
@@ -135,8 +135,8 @@ public class Case0 extends TestCase {
|
||||
for (int i = 0; i < COUNT; ++i) {
|
||||
Connection conn = dataSource.getConnection();
|
||||
Statement stmt = conn.createStatement();
|
||||
ResultSet rs = stmt.executeQuery("SELECT 1");
|
||||
rs.close();
|
||||
// ResultSet rs = stmt.executeQuery("SELECT 1");
|
||||
// rs.close();
|
||||
stmt.close();
|
||||
conn.close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user