title: Displaying data from the database on Java JTree
body: <p>I have a database with two columns named
   colNode,colLeaf</p>
  
  <p>When I read data from the database and display it on the JTree</p>
  
  <pre><code>while (resultSet.next()) {
              DefaultMutableTreeNode url = new DefaultMutableTreeNode(resultSet.getString("colNode"));
              mutableTreeNode.add(url);
              url.add(new DefaultMutableTreeNode(resultSet.getString("colLeaf")));
          }
  </code></pre>
  
  <p>I would like if the value already exists on JTree colNode then colLeaf will be appended to the.I want to get the results in Figure 2
  Please help me</p>
  
  <p>Current output:</p>
  
  <p><a href="https://i.stack.imgur.com/Cvr2V.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Cvr2V.png" alt="Current output"></a></p>
  
  <p>Desired output:</p>
  
  <p><a href="https://i.stack.imgur.com/L3MDY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/L3MDY.png" alt="Desired output"></a></p>