[SOLVED] Traverse database analogous to preorder traversal of graph
I have a database table with 2 columns, say child and parent, depicting the parent-child relationship in a k-ary graph. Hence a tuple in child is "is-a-child-of" of the corresponding parent tuple.
Initially, I supply a parent tuple "p" to my algorithm which needs to trace out all the child of "p" and the chid of its child and so on in the hierarchy of "p".
I have tried to do it recursively (sth like preorder traversal of binary tree) but it doesn't work.
Any idea would be highly appreciated.
With the following code, I get the exception: "Resultset is closed"
public void recurseChild(String id, java.sql.Connection conn)
Statement stmt = conn.createStatement();
String cmd="select conceptid1 from Relationship where conceptid2=" + id;
} //end if
} //end try