Commit 0d1c6605 0d1c66055d1cf3604d8fb7b61fb7b435229b2fcb by Christian Gerdes

getDataFromCDB() now successfully creates a CDB object in the Registry

- Calls getData with the PDB age limit on the CDB object
- Verifies that the CDB objects name matches the databasename from the
PDB object
1 parent b18f52d6
......@@ -248,6 +248,7 @@ public class OraMon {
return false;
}
// We do have the lock. Do the rest in a try catch everything and if we catch anything, re throw the catch but always release the lock.
Statement stmt = null;
try {
long startTSns = System.nanoTime();
getDataCalls++;
......@@ -264,7 +265,7 @@ public class OraMon {
if(stale) {
open();
}
Statement stmt = conn.createStatement();
stmt = conn.createStatement();
ResultSet rset = null;
//Get the database name once // Currently always gets the CDB name
......@@ -304,7 +305,7 @@ public class OraMon {
// If we have containers, but we are not the CDB, then we are a PDB.
// We should ask the CDB object for our data
if(isPDB) {
getDataFromCDB();
getDataFromCDB(ageTs);
} else {
// All other cases (CDB or an instance without containers) get the data from the database
......@@ -340,6 +341,13 @@ public class OraMon {
Throwable thisCause = e;
while(lastCause != null) { thisCause = lastCause; lastCause = thisCause.getCause(); }
lastEx = thisCause;
// Close the connection and statement to prevent memory leaks
try {
stmt.close();
conn.close();
} catch (Exception e2) {
// Dont care
}
throw (e);
} finally {
lock.unlock();
......@@ -347,10 +355,19 @@ public class OraMon {
// End thread safe
}
public void getDataFromCDB() {
public void getDataFromCDB(long ageTs) throws Throwable {
//Generate a con string for the CDB using the PDB con string and replace the service name
String cdbConString = getConString().replaceAll(getServiceName(), getDBName());
System.out.println("CDB seems to be: " + cdbConString);
//Find the CDB in the registry
OraMon myCDB = Registry.findOrCreate(cdbConString, conUser, conPass);
myCDB.getData(ageTs);
// Verify the CDB
if (getDBName().equals(myCDB.getDBName())) {
System.out.println("myCDB name equals DBName");
} else {
System.out.println("myCDB name does not equal DBName");
}
}
public Throwable getLastEx() {
......