Sunday 17 June 2018

OIM API - How to Get OIM Database Connection in Plugins?

public void getDatabaseConnectionExample() {
    Connection connection = null;
    try {
        connection = Platform.getOperationalDS().getConnection();

        String sql = "select usr_login from usr";
        PreparedStatement preparedStatement = null;

        preparedStatement = connection.prepareStatement(sql);
        ResultSet rs = preparedStatement.executeQuery();
        while(rs.next()){
            System.out.println("User Login :: " + rs.getString(1));
        }
    } catch (Exception e) {
        System.out.println("Exception occured while reading user details " + e);
    } finally {
        try {
            connection.close();
        } catch (Exception e) {
            System.out.println("Exception while closing connection : " + e);
        }
    }
}


Happy Learning!!!

1 comment:

  1. I just want to thank you for sharing your information and your site or blog this is simple but nice Information I’ve ever seen i like it i learn something today. Email Marketing Jobs

    ReplyDelete