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.
The folders are arranged on the database like so:
id name parent_id 1 documents 0 2 movies 0 3 videos 0 4 my files 1 5 desktop 0 6 other 4
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)
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.
try {
con = DriverManager.getConnection(url, user, password);
} catch (SQLException e) {
e.printStackTrace();
}
while( i < 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());
}
}