我创建了一个Jtree,其中从用户获取值并将其存储在linkedHashMap中,然后将LinkedHashMap值存储在数据库表中(使用列id,name,parent,level
)。现在我从数据库中检索表格,并打印所有行。
但是我无法理解如何从表数据中检索Jtree。
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url="jdbc:oracle:thin:@localhost:1521:XE";
conn = DriverManager.getConnection(url, "Hr", "Hr");
System.out.println("Connection Established");
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM contacts");
System.out.println("id name job"+ rs);
while (rs.next()) {
int id = rs.getInt("node_Id");
String name = rs.getString("node_Name");
String job = rs.getString("node_Parent");
String lvl = rs.getString("node_Level");
System.out.println(id+" "+name+" "+job+" "+lvl );
System.out.println("lalalala "+ id);
System.out.println("nasjdnasj");
}}
catch(Exception e){
System.out.println("connection error "+ e);
}
这是从数据库中检索表列并打印所有值的代码