user1654236
user1654236

Reputation: 11

Jtree node addition

JTree created by me populates from databases. I want to add new node which I am able to create insertNodeInto() function. Now how do I change the underlying database?

  1. Add node first via treemodel and then do the insert in database
  2. Insert into database and then recreate the tree.

I would like to know the steps involved in case (1) above as the tree I created has large number of nodes.

Upvotes: 1

Views: 161

Answers (1)

lbalazscs
lbalazscs

Reputation: 17784

I would add it first to the database. The reason is that if the DB insert fails for some reason (constraints for example) and you get an SQLException, the user should not get the impression that the insert was successful.

Of course, you don't need to recreate the tree, you can just add another node at any time.

Upvotes: 3

Related Questions