- package com.oimacademy.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) is the Provisioning Solution from oracle. This page contains an index with references to all OIM related posts in the oracle identity manager Academy blog. The posts included herein are intended to provide oracle identity management customers and developers with technical information about best practices for implementing OIM based solutions.
Java Code to Read History Data of Job Using Database
Subscribe to:
Post Comments (Atom)
-
Connection Related API's : OIM DB Connection/ Data Source connection OIMClient API / OIMConnection API OIM Platform API to getSer...
-
Error : Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory at org.springframewor...
-
In this post, we set the middle name as “MiddleName” if user does not provide middle name during user create operation. Below are high...
No comments:
Post a Comment