本文整理汇总了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;
}
示例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;
}
示例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));
}
}