本文整理汇总了Java中org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection方法的典型用法代码示例。如果您正苦于以下问题:Java DataSourceUtils.doGetConnection方法的具体用法?Java DataSourceUtils.doGetConnection怎么用?Java DataSourceUtils.doGetConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.jdbc.datasource.DataSourceUtils
的用法示例。
在下文中一共展示了DataSourceUtils.doGetConnection方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fetchConnectionsAndDepositForLaterUse
import org.springframework.jdbc.datasource.DataSourceUtils; //导入方法依赖的package包/类
private List<RequestDepository> fetchConnectionsAndDepositForLaterUse(
List<ConcurrentRequest> requests) {
List<RequestDepository> depos = new ArrayList<RequestDepository>();
for (ConcurrentRequest request : requests) {
DataSource dataSource = request.getDataSource();
Connection springCon = null;
boolean transactionAware = (dataSource instanceof TransactionAwareDataSourceProxy);
try {
springCon = (transactionAware ? dataSource.getConnection() : DataSourceUtils
.doGetConnection(dataSource));
} catch (SQLException ex) {
throw new CannotGetJdbcConnectionException("Could not get JDBC Connection", ex);
}
RequestDepository depo = new RequestDepository();
depo.setOriginalRequest(request);
depo.setConnectionToUse(springCon);
depo.setTransactionAware(transactionAware);
depos.add(depo);
}
return depos;
}
示例2: getConnection
import org.springframework.jdbc.datasource.DataSourceUtils; //导入方法依赖的package包/类
@Override
protected Connection getConnection(DataSource dataSource) throws SQLException {
Connection connection = DataSourceUtils.doGetConnection(dataSource);
LOGGER.debug(() -> "Obtained a DataSource connection: [" + connection + "]");
return connection;
}
示例3: getConnection
import org.springframework.jdbc.datasource.DataSourceUtils; //导入方法依赖的package包/类
/**
* @return A transaction aware connection
*/
private Connection getConnection() throws SQLException {
return DataSourceUtils.doGetConnection(dataSource);
}
示例4: testGetUserExcludeJsonException
import org.springframework.jdbc.datasource.DataSourceUtils; //导入方法依赖的package包/类
/**
* Test get user exclude json exception.
*
* @throws SQLException
* the SQL exception
*/
@Test
public void testGetUserExcludeJsonException() throws SQLException{
Connection object = DataSourceUtils.doGetConnection(dataSource);
memberManager.getUserExcludeJsonException(object);
}