Can't obtain DBConnection object: "dbConnection"

Hi,
Iam getting this error …

Reason: Can’t obtain DBConnection object: “dbConnection”
at org.jetel.graph.Phase.init(Phase.java:161)
at org.jetel.graph.runtime.WatchDog.executePhase(WatchDog.java:564)
at org.jetel.graph.runtime.WatchDog.call(WatchDog.java:155)
at org.jetel.graph.runtime.WatchDog.call(WatchDog.java:70)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: Can’t obtain DBConnection object: “dbConnection”
at org.jetel.component.DBInputTable.init(DBInputTable.java:171)
at org.jetel.graph.Phase.init(Phase.java:158)
… 8 more

Hi My code is this…

DBConnection dbCon;
Phase PHASE_0 = new Phase(1);
// initialization; must be present
EngineInitializer.initEngine(null, null, null);
System.out
.println(“*******************************************************************************************”);
// create connection object. Get driver and connect string from cfg file
// specified as a first argument
dbCon = new DBConnection(“dbConnection”, “src/mysql.cfg”);

System.out.println(“…Db connections…”+dbCon);
try {
System.out.println(“Id of the DB Connection:::”+dbCon.getId());
dbCon.init();

} catch (Exception ex) {
ex.printStackTrace();
}

DataRecordMetadata metadata = new DataRecordMetadata(
“metadaat”, DataRecordMetadata.DELIMITED_RECORD);

metadata.addField(new
DataFieldMetadata(“Field1”,DataFieldMetadata.STRING_FIELD, null));

metadata.setFieldDelimiter(“,”);
metadata.setRecordDelimiters(“\n”);

TransformationGraph institutionOrphanCheckGraph = new TransformationGraph();

String outputFile1 = “C:/hanu/feeds/A.xls”;

String outputFile2 = “C:/hanu/feeds/A_B.xls”;
String outputFile3 = “C:/hanu/feeds/B.xls”;
String parentQuery=“select code from feed_institution”;
String childQuery=“select pub_code from ip_institutions”;
// Nodes…
DBInputTable parentDBReader = new DBInputTable(“parentReader”,dbCon.getId(),parentQuery);

Node parentDBReaderNode = parentDBReader;

DBInputTable childDBReader = new DBInputTable(“childReader”,dbCon.getId(),childQuery);

but this giingh error that : Can’t obtain DBConnection object: “dbConnection”

Hi,
you need to call TransformationGraph.addConnection() to add the connection to the graph.

Jaro

Hi,
Thanks for reply…it is now working…but i am facing another problem…

When i run code which builds a graph… it is running in the infinity loop.

GraphRuntimeContext runtimeContext = new GraphRuntimeContext();
runtimeContext.setUseJMX(false);

GraphExecutor executor = new GraphExecutor();

System.out.println(“Grapgh Executer…” + executor);
System.out.println(“…Graph…” + institutionOrphanCheckGraph);
try {
GraphExecutor.initGraph(institutionOrphanCheckGraph);
} catch (ComponentNotReadyException e) {
System.out.println(“::::::::::::::::::::::::::File Not Found in Compontnt not ready:::::::::::::::::::::::::::::::::::::::::::::::::::::::”);
System.out.println(“Failed graph initialization!\n”
+ e.getMessage());
return false;
}

Future result;
try {
result = executor.runGraph(institutionOrphanCheckGraph, runtimeContext);
Result rs = result.get()
//institutionOrphanCheckGraph.free();
//executor.free();

//System.out.println(result.isDone() + “>>>>>>>>>>>>>>>>>>>>>>>”);
if (result.isDone()) {
System.out.println(“Done”);
isDone = true;
}
if (!result.get().equals(Result.FINISHED_OK)) {
//System.out.println(result.get().message());
System.out.println(“Failed graph execution!”);
// return false;
}
} catch (Exception e) {
System.out.println(“Failed graph execution!\n” + e.getMessage());
// return false;
}

I don’t see any cycle in your code, where does it run in an infinite circle?

Jaro

Hi Jaro,
I Actually it was running in infinite loop in my custom Reformat…I resolved that.

Thanks,