Java Code Examples for org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection()

The following are Jave code examples for showing how to use doGetConnection() of the org.springframework.jdbc.datasource.DataSourceUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: cobarclient   File: DefaultConcurrentRequestProcessor.java   View Source Code Vote up 6 votes
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;
}
 
Example 2
Project: holon-datastore-jdbc   File: DefaultSpringJdbcDatastore.java   View Source Code Vote up 4 votes
@Override
protected Connection getConnection(DataSource dataSource) throws SQLException {
	Connection connection = DataSourceUtils.doGetConnection(dataSource);
	LOGGER.debug(() -> "Obtained a DataSource connection: [" + connection + "]");
	return connection;
}
 
Example 3
Project: artifactory   File: JdbcHelper.java   View Source Code Vote up 4 votes
/**
 * @return A transaction aware connection
 */
private Connection getConnection() throws SQLException {
    return DataSourceUtils.doGetConnection(dataSource);
}
 
Example 4
Project: feilong-spring   File: MemberManagerTest.java   View Source Code Vote up 2 votes
/**
 * 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);
}