mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
36 lines
1.1 KiB
Java
36 lines
1.1 KiB
Java
package com.alibaba.druid.pool;
|
|
|
|
import java.sql.Connection;
|
|
|
|
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 {
|
|
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 {
|
|
DruidDataSource dataSource = new DruidDataSource();
|
|
dataSource.setDriverClassName(driverClass);
|
|
dataSource.setUrl(jdbcUrl);
|
|
dataSource.setUsername(user);
|
|
dataSource.setPassword(password);
|
|
dataSource.setFilters("stat");
|
|
dataSource.setExceptionSorter(MySqlExceptionSorter.class.getName());
|
|
|
|
Connection conn = dataSource.getConnection();
|
|
conn.close();
|
|
}
|
|
}
|