use of com.mysql.jdbc.Driver in project druid by alibaba.
the class DruidConnectionHolderTest method setUp.
protected void setUp() throws Exception {
driver = new Driver();
if (driver.getMajorVersion() == 5) {
exceptionClass = Class.forName("com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException");
dataSource = new DruidDataSource();
dataSource.setUrl("jdbc:mock:xxx");
dataSource.setTestOnBorrow(false);
dataSource.setInitialSize(1);
dataSource.getProxyFilters().add(new FilterAdapter() {
public int connection_getTransactionIsolation(FilterChain chain, ConnectionProxy connection) throws SQLException {
throw createSyntaxException();
}
});
}
}
use of com.mysql.jdbc.Driver in project druid by alibaba.
the class MySqlUtilsTest method test_.
public void test_() throws Exception {
Driver driver = new Driver();
int majorVersion = driver.getMajorVersion();
if (majorVersion == 5) {
Class<?> clazz_ConnectionImpl = Class.forName("com.mysql.jdbc.ConnectionImpl");
Constructor<?> constructor = clazz_ConnectionImpl.getDeclaredConstructor();
constructor.setAccessible(true);
Connection conn = (Connection) constructor.newInstance();
MySqlUtils.createXAConnection(driver, conn);
} else if (majorVersion == 6) {
}
}
use of com.mysql.jdbc.Driver in project zoj by licheng.
the class DatabaseHelper method createConnection.
/**
* Gets a connection.
* @return a connection
* @throws Exception to JUnit
*/
public static Connection createConnection() throws Exception {
Properties properties = new Properties();
properties.load(new FileInputStream(CONFIG_FILE));
Driver driver = (Driver) Class.forName(properties.getProperty("driver")).newInstance();
String url = properties.getProperty("url");
return driver.connect(url, properties);
}
Aggregations