use of com.alibaba.druid.pool.vendor.MySqlValidConnectionChecker in project druid by alibaba.
the class DataSourceTest3 method test_error_validateConnection_3.
public void test_error_validateConnection_3() throws Exception {
dataSource.setValidationQuery(null);
dataSource.setValidConnectionChecker(new MySqlValidConnectionChecker());
DruidPooledConnection conn = dataSource.getConnection().unwrap(DruidPooledConnection.class);
dataSource.validateConnection(conn);
}
use of com.alibaba.druid.pool.vendor.MySqlValidConnectionChecker in project druid by alibaba.
the class DataSourceTest3 method test_ValidConnectionChecker.
public void test_ValidConnectionChecker() throws Exception {
dataSource.getValidConnectionCheckerClassName();
dataSource.setValidConnectionChecker(new MySqlValidConnectionChecker());
Assert.assertEquals(MySqlValidConnectionChecker.class.getName(), dataSource.getValidConnectionCheckerClassName());
}
use of com.alibaba.druid.pool.vendor.MySqlValidConnectionChecker in project druid by alibaba.
the class MySQLValidConnectionCheckerTest method setUp.
protected void setUp() throws Exception {
System.setProperty("druid.mysql.usePingMethod", "false");
dataSource = new DruidDataSource();
dataSource.setUrl("jdbc:mock:xxx");
dataSource.setDbType("mysql");
dataSource.setValidationQuery("select 1");
dataSource.setValidConnectionChecker(new MySqlValidConnectionChecker());
dataSource.setInitialSize(1);
dataSource.setTestOnBorrow(true);
}
use of com.alibaba.druid.pool.vendor.MySqlValidConnectionChecker in project druid by alibaba.
the class MySQLValidConnectionCheckerTest method test_connect.
public void test_connect() throws Exception {
{
Connection conn = dataSource.getConnection();
conn.close();
}
MySqlValidConnectionChecker checker = (MySqlValidConnectionChecker) dataSource.getValidConnectionChecker();
Assert.assertFalse(checker.isUsePingMethod());
dataSource.setConnectionProperties("druid.mysql.usePingMethod=true");
Assert.assertTrue(checker.isUsePingMethod());
Connection conn = dataSource.getConnection();
conn.close();
}
Aggregations