当前位置: 首页>>代码示例>>Java>>正文


Java PooledDataSource.setDriver方法代码示例

本文整理汇总了Java中org.apache.ibatis.datasource.pooled.PooledDataSource.setDriver方法的典型用法代码示例。如果您正苦于以下问题:Java PooledDataSource.setDriver方法的具体用法?Java PooledDataSource.setDriver怎么用?Java PooledDataSource.setDriver使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.ibatis.datasource.pooled.PooledDataSource的用法示例。


在下文中一共展示了PooledDataSource.setDriver方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getMySQLDataSource

import org.apache.ibatis.datasource.pooled.PooledDataSource; //导入方法依赖的package包/类
private DataSource getMySQLDataSource() {
    PooledDataSource ds = new PooledDataSource();

    ds.setDriver("com.mysql.cj.jdbc.Driver");
    ds.setUrl("jdbc:mysql://localhost:3306/db_example");
    ds.setUsername("tully");
    ds.setPassword("tully");

    return ds;
}
 
开发者ID:vitaly-chibrikov,项目名称:otus_java_2017_06,代码行数:11,代码来源:MainAnnotationsExample.java

示例2: getH2DataSource

import org.apache.ibatis.datasource.pooled.PooledDataSource; //导入方法依赖的package包/类
private DataSource getH2DataSource() {
    PooledDataSource ds = new PooledDataSource();

    ds.setDriver("org.h2.Driver");
    ds.setUrl("jdbc:h2:mem:test");

    return ds;
}
 
开发者ID:vitaly-chibrikov,项目名称:otus_java_2017_06,代码行数:9,代码来源:MainAnnotationsExample.java

示例3: getH2DataSource

import org.apache.ibatis.datasource.pooled.PooledDataSource; //导入方法依赖的package包/类
private DataSource getH2DataSource() {
    PooledDataSource ds = new PooledDataSource();

    ds.setDriver("org.h2.Driver");
    ds.setUrl("jdbc:h2:mem:test");
    ds.setUsername("sa");

    return ds;
}
 
开发者ID:vitaly-chibrikov,项目名称:otus_java_2017_10,代码行数:10,代码来源:MainAnnotationsExample.java

示例4: createPooledDataSource

import org.apache.ibatis.datasource.pooled.PooledDataSource; //导入方法依赖的package包/类
public static PooledDataSource createPooledDataSource(String resource) throws IOException {
  Properties props = Resources.getResourceAsProperties(resource);
  PooledDataSource ds = new PooledDataSource();
  ds.setDriver(props.getProperty("driver"));
  ds.setUrl(props.getProperty("url"));
  ds.setUsername(props.getProperty("username"));
  ds.setPassword(props.getProperty("password"));
  return ds;
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:10,代码来源:BaseDataTest.java

示例5: createDataSource

import org.apache.ibatis.datasource.pooled.PooledDataSource; //导入方法依赖的package包/类
public static PooledDataSource createDataSource(Props p) {
	
	String url = p.findVal(db_url);
	
	PooledDataSource ds = new PooledDataSource();
	ds.setDriver(p.findVal(db_driver));         
	ds.setUrl(url);
	ds.setUsername(p.findVal(db_user));                                  
	ds.setPassword(p.findVal(db_psw));
	ds.setPoolMaximumActiveConnections(p.getIntVal(db_maxConnections));
	ds.setPoolMaximumIdleConnections(p.getIntVal(db_idleConnections));
	
	return ds;
}
 
开发者ID:edolganov,项目名称:live-chat-engine,代码行数:15,代码来源:BaseDb.java

示例6: shouldReconnectWhenServerKilledLeakedConnection

import org.apache.ibatis.datasource.pooled.PooledDataSource; //导入方法依赖的package包/类
@Ignore("See the comments")
@Test
public void shouldReconnectWhenServerKilledLeakedConnection() throws Exception {
  // See #748
  // Requirements:
  // 1. MySQL JDBC driver dependency.
  // 2. MySQL server instance with the following.
  //  - CREATE DATABASE `test`;
  //  - SET GLOBAL wait_timeout=3;
  // 3. Tweak the connection info below.
  final String URL = "jdbc:mysql://localhost:3306/test";
  final String USERNAME = "admin";
  final String PASSWORD = "";

  Connection con;
  PooledDataSource ds = new PooledDataSource();
  ds.setDriver("com.mysql.jdbc.Driver");
  ds.setUrl(URL);
  ds.setUsername(USERNAME);
  ds.setPassword(PASSWORD);
  ds.setPoolMaximumActiveConnections(1);
  ds.setPoolMaximumIdleConnections(1);
  ds.setPoolTimeToWait(1000);
  ds.setPoolMaximumCheckoutTime(2000);
  ds.setPoolPingEnabled(true);
  ds.setPoolPingQuery("select 1");
  ds.setDefaultAutoCommit(true);
  // MySQL wait_timeout * 1000 or less. (unit:ms)
  ds.setPoolPingConnectionsNotUsedFor(1000);

  con = ds.getConnection();
  exexuteQuery(con);
  // Simulate connection leak by not closing.
  // con.close();

  // Wait for disconnected from mysql...
  Thread.sleep(TimeUnit.SECONDS.toMillis(3));

  // Should return usable connection.
  con = ds.getConnection();
  exexuteQuery(con);
  con.close();
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:44,代码来源:PooledDataSourceTest.java

示例7: shouldReconnectWhenServerKilledLeakedConnection

import org.apache.ibatis.datasource.pooled.PooledDataSource; //导入方法依赖的package包/类
@Ignore("See the comments")
@Test
public void shouldReconnectWhenServerKilledLeakedConnection() throws Exception {
  // See #748
  // Requirements:
  // 1. MySQL JDBC driver dependency.
  // 2. MySQL server instance with the following.
  //  - CREATE DATABASE `test`;
  //  - SET GLOBAL wait_timeout=3;
  // 3. Tweak the connection info below.
  final String URL = "jdbc:mysql://localhost:3306/test";
  final String USERNAME = "admin";
  final String PASSWORD = "";

  PooledDataSource ds = new PooledDataSource();
  ds.setDriver("com.mysql.jdbc.Driver");
  ds.setUrl(URL);
  ds.setUsername(USERNAME);
  ds.setPassword(PASSWORD);
  ds.setPoolMaximumActiveConnections(1);
  ds.setPoolMaximumIdleConnections(1);
  ds.setPoolTimeToWait(1000);
  ds.setPoolMaximumCheckoutTime(2000);
  ds.setPoolPingEnabled(true);
  ds.setPoolPingQuery("select 1");
  ds.setDefaultAutoCommit(true);
  // MySQL wait_timeout * 1000 or less. (unit:ms)
  ds.setPoolPingConnectionsNotUsedFor(1000);

  Connection con = ds.getConnection();
  exexuteQuery(con);
  // Simulate connection leak by not closing.
  // con.close();

  // Wait for disconnected from mysql...
  Thread.sleep(TimeUnit.SECONDS.toMillis(3));

  con.close();

  // Should return usable connection.
  con = ds.getConnection();
  exexuteQuery(con);
  con.close();
}
 
开发者ID:mybatis,项目名称:mybatis-3,代码行数:45,代码来源:PooledDataSourceTest.java


注:本文中的org.apache.ibatis.datasource.pooled.PooledDataSource.setDriver方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。