I am designing a java email client. I have used a JTree to display my folders (i.e. Inbox, Outbox, Sent Items etc.). The actual JTree comes up fine as i have created it with static strings. I now want to update the tree using values from a table in my mysql database which contains attributes - username, foldername. If I get the foldernames using db.getfoldername where username = n, then how do I update the Jtree with these results? Pls help...deadline on the 7th of sept!. Thanks!
I don't have experience with mySQL-databases but I presume your working with the JDBC-classes. If that's the case you should get a ResultSet returned for any Statement (SELECT * FROM...) you throw at the database. Construct a method that build a treemodel according to a resultset you pass it and call this method either when you know something has changed (when the database notifies you) or at predefined times (polling). Simply run throught each record in the resultset and construct nodes as necessary. Then pass this model to the JTree via its setModel() method. Hope this helps... ------------------
Or you could use an ASP to query the database & get the result in string format separated by delimiters, which you can remove using tokenizer. Then with the updated treemodel u can regenerate the tree.