package com.NeedEvaluate; import java.io.IOException; import java.io.InputStream; import java.io.ObjectInputStream; import java.sql.Blob; import java.sql.Connection; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.text.SimpleDateFormat; public class ReadJobHistroyDataDB { private static Connection connectionObject = null; private static Connection makeConnection() { try { Class.forName("oracle.jdbc.OracleDriver"); connectionObject = DriverManager.getConnection("jdbc:oracle:thin:@host:5521:oimdb", "SCHEMA", "PASSWORD"); } catch (SQLException se) { se.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } return connectionObject; } public static synchronized Connection getConnection() { if (connectionObject == null) { connectionObject = makeConnection(); } return connectionObject; } public static void closeConnection() { System.out.println("Closing to database connection ..."); try { if (connectionObject != null) connectionObject.close(); } catch (SQLException se) { se.printStackTrace(); } } public void execute() throws Exception { String mname = "execute()"; String jname = "Issue Audit Messages Task";//Job Name which is having issue. jname=jname.replaceAll("\\*", "%"); if (null == jname) throw new NullPointerException("JobName is null."); jname = jname.replace('*', '%'); String query = "select ERROR_DATA,job_name from JOB_HISTORY where id=7747"; try { PreparedStatement prepStmt = getConnection().prepareStatement(query); ResultSet rs = prepStmt.executeQuery(query); boolean found = false; while(rs.next()) { System.out.println(""); System.out.println("*****************"+rs.getString("job_name")+"*****************"); found = true; Blob b = rs.getBlob("ERROR_DATA"); if(b==null) continue; InputStream bis = b.getBinaryStream(); ObjectInputStream ois = new ObjectInputStream(bis); Object obj = ois.readObject(); if(obj instanceof Exception) { print((Exception) obj); } ois.close(); bis.close(); System.out.println("**********************************"); System.out.println(""); } rs.close(); prepStmt.close(); if(!found) { System.out.println("Job Not found : " + jname); } } catch (SQLException ex) { ex.printStackTrace(); } catch (IOException ex) { ex.printStackTrace(); } finally { closeConnection(); } } private void print(Exception jdm) { if(jdm != null) System.out.println("Exception Message :"+jdm.getMessage()); } public SimpleDateFormat dateFormat(){ SimpleDateFormat simpleDate = new SimpleDateFormat("DDMMYY"); return simpleDate; } public static void main(String[] args) throws Exception{ new ReadJobHistroyDataDB().execute(); } }
Oracle Identity Manager (OIM R2PS2/PS3/12C) is a highly flexible and scalable enterprise identity administration system that provides operational and business efficiency by providing centralized administration & complete automation of identity and user provisioning events across enterprise as well as extranet applications.
Java Code to Read History Data of Job Using Database
Subscribe to:
Posts (Atom)
About OIM
Oracle Identity Management enables organizations to effectively manage the end - to - end life - cycle of user ide...
Popular Posts
-
OIM API's Sample Code : Videos: Massive Gaze Videos Connection Related API's : OIM DB Connection/ Data Source connection ...
-
Videos: Massive Gaze Videos 1. Basic OIM Information 2. MDS Export/Import 3. Steps For R2PS2 / R2PS3 Custom Pre-processor Ev...
-
Videos: Massive Gaze Videos 1. Query to get OIM Provsioned/provisioning Account details 2. Query to get usr keys For Rejected / ...
No comments:
Post a Comment