Java 如何使用单个数据库表在adf中创建树结构?

Java 如何使用单个数据库表在adf中创建树结构?,java,collections,oracle-adf,Java,Collections,Oracle Adf,请告诉我这些改变。有没有其他简单的方法可以达到同样的效果 提前谢谢。你在这里做错了,因为这不是ADF的做事方式。 了解如何使用模型和应用程序模块 在adf中有很多如何使用树模型的示例: This is the constructor code: public TreeExample() throws SQLException { TreeItem node1 = null; String url = "jdbc:oracle:thin:@xy

请告诉我这些改变。有没有其他简单的方法可以达到同样的效果


提前谢谢。

你在这里做错了,因为这不是ADF的做事方式。
了解如何使用模型和应用程序模块

在adf中有很多如何使用树模型的示例:

This is the constructor code:

    public TreeExample() throws SQLException {
        TreeItem node1 = null;

        String url = "jdbc:oracle:thin:@xyz";
        String user = "dummy";
        String password = "dummy";

        root = new ArrayList<TreeItem>();

        Connection connection = DriverManager.getConnection(url, user, password);
        Statement statement = connection.createStatement();
        String sql = "SELECT * FROM HEALTH_CHECK_QUERIES ORDER BY HEADER_TYPE ASC";

        ResultSet result = statement.executeQuery(sql);
        String previousheadernode = "First";
        while (result.next()) {

            String headernode = result.getString("Header_Type");
            String childnode = result.getString("Detail_Type");

            if (!headernode.equals(previousheadernode))

            {
                node1 = new TreeItem(headernode, headernode);
                root.add(node1);
                previousheadernode = headernode;


            }

            ArrayList<TreeItem> node1Children = new ArrayList<TreeItem>();
            TreeItem node1Child1 = new TreeItem(childnode, childnode);
            node1Children.add(node1Child1);
            node1.setChildren(node1Children);

        }


        setListInstance(root);
    }
    header_details    detail_type   query
    --------------------------------------------------
    H1            D1            SELECT * FROM xyz;
    H1            D2            SELECT * FROM xyz;
    H2            D21           SELECT * FROM xyz;
    H2            D22           SELECT * FROM xyz;
    H3            D3            SELECT * FROM xyz;
    H3            D32           SELECT * FROM xyz;

    This is how I am creating tree.But the child nodes are not getting added to     the parent as required(D1 and D2 must be added to parent node H1).