Creating JDBC connection to Oracle Database using Java code

Below is the java code to create connection to database

External Jar required: ojdbc6-11.2.0.3.jar

 public Connection getJDBConnection(){
        String methodName = "getJDBConnection";
        logger.setMethodStartLog(className, methodName);
     
        String jdbcDriver = "oracle.jdbc.OracleDriver";
        String dbUrl = "jdbc:oracle:thin:@HOSTNAME:1521:IDMDEV1";
        String username = "USERNAME";
        String password = "PASSWORD";
        try {
Class.forName(jdbcDriver);
jdbcConnection = DriverManager.getConnection(dbUrl,username,password);
} catch (ClassNotFoundException | SQLException e) {
e.printStackTrace();
}
         
        logger.setMethodFinishLog(className, methodName);
        return jdbcConnection;
    }


You can use  Platform.getOperationalDS().getConnection() method to establish oim connection using OIM API


Prepared Statements

Declaration:
PreparedStatement psActiveUsers = null;

Initialization:
psActiveUsers = conn.prepareStatement(queryInString);

Updating query parameters:
psActiveUsers.setString(1, lastRunTime);

Executing:
psActiveUsers.executeUpdate();







Comments

Popular posts from this blog

Rules in Sailpoint

Sailpoint Installation Steps (IdentityIQ 7.3 Installation in Windows Machine)

How to create provisioning plan in Sailpoint