Maximo Open Forum

 View Only

 How to read recordsets from remote Oracle DB using Automation script?

  • Customizations
  • Integrations
  • IoT
Yaroslav Galata's profile image
Yaroslav Galata posted 02-21-2023 09:47

Hello!

Is it possible to connect to remote third-party DB (Oracle) from Automation script directly and read some records?

Prashant Sharma's profile image
Prashant Sharma

You will require to do something similar after changing Drive to Oracle and in between call PreparedStatement to execute SQL. 

You need to be careful when calling external DB and firing direct SQL with Maximo Framework.

import java.sql.DriverManager as DriverManager
import java.sql.SQLException as SQLException

# Replace these values with your Maximo database credentials or change 
db_url = "jdbc:db2://localhost:50000/MAXDB76"
db_user = "maximo"
db_password = "maximo"

try:
    # Load the DB2 JDBC driver
    Class.forName("com.ibm.db2.jcc.DB2Driver")
    
    # Connect to the Maximo database
    conn = DriverManager.getConnection(db_url, db_user, db_password)
    
    # Do something with the database connection here
    
    # Close the database connection
    conn.close()
    
except SQLException as e:
    print("SQL Exception: ", e.getMessage())
    
except Exception as e:
    print("Exception: ", e.getMessage())