本文整理匯總了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);
}