OIM ADF UI - Code Snippet to get Database Connection.

public Connection getOIMDBConnection() {
        final String logp = CN + ":: getOIMDataSource - ";
        LOGGER.debug(logp + "START");       
        Connection conn = null;       
        try {
            String oimDatasourceName = "jdbc/operationsDB";
            LOGGER.debug(logp + "OIM Datasource Name = " + oimDatasourceName);
            
            Context context = new InitialContext();
            DataSource ds = (DataSource) context.lookup(oimDatasourceName);
            LOGGER.info(logp + "Successfully looked up OIM datasource");
            
            if (null != ds) {
                    conn = ds.getConnection();
                    LOGGER.debug(logp + "Successfully obtained OIM database connection");
            }
        } catch (Exception e) {
                LOGGER.error(logp + "Exception while getting DB connection - " + e, e);
        }
        
        LOGGER.debug(logp + "END");
        return conn;
    }

No comments:

Post a Comment