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


Java BasicDataSource.setDefaultAutoCommit方法代码示例

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


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

示例1: _get

import org.apache.commons.dbcp.BasicDataSource; //导入方法依赖的package包/类
private static BasicDataSource _get(String D, String username, String passwd, String url, int N) {
  BasicDataSource external = new BasicDataSource();
  external.setDriverClassName(D.trim());

  if (!X.isEmpty(username)) {
    external.setUsername(username.trim());
  }
  if (!X.isEmpty(passwd)) {
    external.setPassword(passwd.trim());
  }

  external.setUrl(url.trim());

  external.setMaxActive(N);
  external.setDefaultAutoCommit(true);
  external.setMaxIdle(N);
  external.setMaxWait(MAX_WAIT_TIME);
  external.setDefaultAutoCommit(true);
  external.setDefaultReadOnly(false);
  external.setDefaultTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
  external.setValidationQuery(null);// VALIDATION_SQL);
  external.setPoolPreparedStatements(true);

  return external;
}
 
开发者ID:giiwa,项目名称:giiwa,代码行数:26,代码来源:RDB.java

示例2: getBaseDataSource

import org.apache.commons.dbcp.BasicDataSource; //导入方法依赖的package包/类
private BasicDataSource getBaseDataSource() {
    BasicDataSource ds = new BasicDataSource();
    ds.setUsername(dbUser);
    ds.setPassword(dbPass);
    ds.setDriverClassName(DRIVER);
    ds.setTestOnBorrow(true);
    ds.setValidationQuery("select 1");
    ds.setDefaultAutoCommit(false);
    return ds;
}
 
开发者ID:oneops,项目名称:oneops,代码行数:11,代码来源:DataSourceConfig.java

示例3: setupDataSource

import org.apache.commons.dbcp.BasicDataSource; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private static void setupDataSource(Isolation isolation) {
  ds = new BasicDataSource();
  Endpoint locatorEndPoint = (Endpoint) (NetworkServerHelper.getNetworkLocatorEndpoints()).get(0);
  String hostname = getHostNameFromEndpoint(locatorEndPoint);
  int port = getPortFromEndpoint(locatorEndPoint); 
  
  connProp.putAll(getExtraConnProp());
  
  try {
    ds.setDriverClassName(driver);
    ds.setUrl(protocol + hostname+ ":" + port);
    
    ds.setMaxActive(100);
    
    if (isolation == Isolation.NONE) {
    } else if (isolation == Isolation.READ_COMMITTED) {
      ds.setDefaultTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);
      ds.setDefaultAutoCommit(false);
    } else {
      ds.setDefaultTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ);
      ds.setDefaultAutoCommit(false);
    }
    
    StringBuilder sb = new StringBuilder();
    
    for (Iterator<?> iter = connProp.entrySet().iterator(); iter.hasNext(); ) {
      Map.Entry<String, String> entry = (Map.Entry<String, String>) iter.next();
      ds.addConnectionProperty(entry.getKey(), entry.getValue()); //add additional conn prop
      
      sb.append(entry.getKey() + " is set to " + entry.getValue() +"\n");
    }
         
    dsSet = true;
    Log.getLogWriter().info("basic source url is set as " + ds.getUrl());
    Log.getLogWriter().info("basic data source setting the following connection prop: " + sb.toString());
    
  } catch (Exception e) {
    throw new TestException("could not set data source" + TestHelper.getStackTrace(e));
  }
}
 
开发者ID:gemxd,项目名称:gemfirexd-oss,代码行数:42,代码来源:PooledConnectionDBCP.java


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