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

The following examples show how to use javax.sql.DataSource#toString() . These examples are extracted from open source projects. 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
@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
@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
/**
 * 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;
}