title: Create folders from folder id and parent id in java
body: <p>I need to make a class that get the list of folders stored in a database and creates them on the local machine in the correct hierarchy.</p>
  
  <p>The folders are arranged on the database like so:</p>
  
  <pre>
  id name parent_id
  
  1 documents 0
  2 movies 0
  3 videos 0
  4 my files 1
  5 desktop 0
  6 other 4
  </pre>
  
  <p>So documents, movies, videos and desktop are in the root. 'my files' goes in the folder with the id of 1(documents) and 'other' goes in the folder with the id of 4(my files)</p>
  
  <p>I have been trying to do it by using a whyle loop but dont know how to get them to go into the correct folders.</p>
  
  <pre><code>try {
              con = DriverManager.getConnection(url, user, password);
          } catch (SQLException e) {
              e.printStackTrace();
          }
          while( i &lt; 50 )
          {   
              try {            
  
              Statement st = con.createStatement();
              ResultSet result = st.executeQuery("SELECT name, id, parent_id FROM categories WHERE parent_id = '"+PID+"' AND repository_id = '"+RepoID+"'");
  
  
  
              while (result.next ())
              {
                  String FolderName = result.getString ("name");
                  String FolderId = result.getString ("id");
                  String FolderId = result.getString ("parent_id");
  make the folder name here
                  System.out.println( FolderName+" "+FolderId );
              }
  
              System.out.println( " ");
                      i++ ;
              PID++;
              } catch (SQLException ex) {
                   System.out.println(ex.getMessage());
               }
              }
  </code></pre>