Just wanted the correct interpretation of my requirement :-
the program must allow the user to specify the location of the database
I have interpreted this as providing the user with the facility to specify the path to the database BUT not the database file name and the database file name to use, is as per the file provided by Sun. In my case, "db-2x2".
Or should it be interpreted as the user should be able to specify the path to the database file AND also the name of the database file. "C:\suncertify\database\db_another"
Partner, this is for the network approach, right? Here's what I did: when my application starts in server mode, I display a dialog, where the user inserts the database location and the port number in which the server will run. Both are JTextFields, and the port number allows only numbers. Now, in the database location, the user provides the entire path to the database file. So, for instance, if the database file is in C:\Pete\SCJD\db-2x2.db, then I expect the user to enter C:\Pete\SCJD\db-2x2.db. And before using the Data class, I verify if the path provided is valid (if (!new File(dbPath).exists())); if it isn't, I throw InvalidDatabaseException.
Cheers, Roberto Perillo
SCJP, SCWCD, SCJD, SCBCD
posted 11 years ago
Thanks for the clarification and detail of how to handle the scenario.
JTextField vs JFileChooser? Depends JFileChooser will not need to file existence, wrong magic cookie value etc and the only real disadvantage is the file must on the same machine that you are running the app.
The JTextField would indeed need to check file existence, cookie value etc and the major advantage is the database file can practically be on another computer.
For example: CompA is your server, you can specify a file on CompB if you really like (within the LAN of course).
For me I used a JTextField and did all those checking BEFORE saving the configuration.