Search in sources :

Example 1 with JndiJdbc

use of org.apache.ofbiz.entity.config.model.JndiJdbc in project ofbiz-framework by apache.

the class JNDITransactionFactory method getConnection.

public Connection getConnection(GenericHelperInfo helperInfo) throws SQLException, GenericEntityException {
    Datasource datasourceInfo = EntityConfig.getDatasource(helperInfo.getHelperBaseName());
    if (datasourceInfo.getJndiJdbc() != null) {
        JndiJdbc jndiJdbcElement = datasourceInfo.getJndiJdbc();
        String jndiName = jndiJdbcElement.getJndiName();
        String jndiServerName = jndiJdbcElement.getJndiServerName();
        Connection con = getJndiConnection(jndiName, jndiServerName);
        if (con != null) {
            return TransactionUtil.getCursorConnection(helperInfo, con);
        }
    } else {
    }
    if (datasourceInfo.getInlineJdbc() != null) {
        Connection otherCon = ConnectionFactoryLoader.getInstance().getConnection(helperInfo, datasourceInfo.getInlineJdbc());
        return TransactionUtil.getCursorConnection(helperInfo, otherCon);
    }
    // no real need to print an error here
    return null;
}
Also used : Datasource(org.apache.ofbiz.entity.config.model.Datasource) JndiJdbc(org.apache.ofbiz.entity.config.model.JndiJdbc) Connection(java.sql.Connection) XAConnection(javax.sql.XAConnection)

Aggregations

Connection (java.sql.Connection)1 XAConnection (javax.sql.XAConnection)1 Datasource (org.apache.ofbiz.entity.config.model.Datasource)1 JndiJdbc (org.apache.ofbiz.entity.config.model.JndiJdbc)1