Java Code Examples for javax.sql.DataSource#toString()

The following examples show how to use javax.sql.DataSource#toString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractAutoCpsMethod.java    From EasyTransaction with Apache License 2.0 6 votes vote down vote up
@Override
public final void doAutoCpsCommit(P param) {

    Integer callSeq = MetaDataFilter.getMetaData(EasytransConstant.CallHeadKeys.CALL_SEQ);
    TransactionId transactionId = MetaDataFilter.getMetaData(EasytransConstant.CallHeadKeys.PARENT_TRX_ID_KEY);
    DataSource ds = MetaDataFilter.getMetaData(EasytransConstant.DataSourceRelative.DATA_SOURCE);

    if (ds instanceof Resource) {
        Resource rs = (Resource) ds;
        try {
            DefaultResourceManager.get().branchCommit(BranchType.AT,getFescarXid(transactionId), callSeq, rs.getResourceId(), null);
        } catch (TransactionException e) {
            LOGGER.error("transaction commit exception occour , code:" + e.getCode(), e);
            throw new RuntimeException("transaction exception", e);
        }
    } else {
        throw new RuntimeException(ds.toString() + " is not DataSourceProxy, please correct the config!");
    }

}
 
Example 2
Source File: AbstractAutoCpsMethod.java    From EasyTransaction with Apache License 2.0 6 votes vote down vote up
@Override
public final void doAutoCpsRollback(P param) {

    Integer callSeq = MetaDataFilter.getMetaData(EasytransConstant.CallHeadKeys.CALL_SEQ);
    TransactionId transactionId = MetaDataFilter.getMetaData(EasytransConstant.CallHeadKeys.PARENT_TRX_ID_KEY);
    DataSource ds = MetaDataFilter.getMetaData(EasytransConstant.DataSourceRelative.DATA_SOURCE);

    if (ds instanceof Resource) {
        Resource rs = (Resource) ds;
        try {
            DefaultResourceManager.get().branchRollback(BranchType.AT,getFescarXid(transactionId), callSeq, rs.getResourceId(), null);
        } catch (TransactionException e) {
            LOGGER.error("transaction roll back exception occour , code:" + e.getCode(), e);
            throw new RuntimeException("transaction exception", e);
        }
    } else {
        throw new RuntimeException(ds.toString() + " is not DataSourceProxy, please correct the config!");
    }

}
 
Example 3
Source File: HealthDAO.java    From entando-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Restituisce una connessione SQL relativa al datasource.
 * @return La connessione richiesta.
 * @throws ApsSystemException In caso di errore in apertura di connessione.
 */
private Connection getConnection(DataSource dataSource) throws ApsSystemException {
    Connection conn = null;
    try {
        conn = dataSource.getConnection();
    } catch (SQLException e) {
        logger.error("Error getting connection to the datasource {}", dataSource, e);
        throw new ApsSystemException("Error getting connection to the datasource " + dataSource.toString(), e);
    }
    return conn;
}