aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes location of DB.DB file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "location of DB.DB file" Watch "location of DB.DB file" New topic
Author

location of DB.DB file

ravi janap
Ranch Hand

Joined: Nov 04, 2000
Posts: 389
Hi
I have hard coded the location of db.db file in my RemoteDataClient and LocalDataClient class.
private static final String dbname = "\\submission\\scjd\\starting\\suncertify\\db\\db.db"
Is it okay if I am following this approach ?. I feel my approach is fine because when the application starts up the client must totally be transparent to which database he is getting connected to.
If answer to the above question is 'No' then should I save the db.db file in some location say <INSTALL>/database/db.db and then specify the path to db.db file as a parameter in the command line instruction so that I am not hard coding it in my code ?
Which is the better way ?

Thanks
Ravi


SCJP, SCJD, SCWCD, SCBCD, SCEA
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Ravi,

Is it okay if I am following this approach ?. I feel my approach is fine because when the application starts up the client must totally be transparent to which database he is getting connected to.

No because of the following requirement in the instructions:
Note: your program must run correctly no matter what directory it is installed in.

If answer to the above question is 'No' then should I save the db.db file in some location say <INSTALL>/database/db.db and then specify the path to db.db file as a parameter in the command line instruction so that I am not hard coding it in my code ?

That's what you need to do. You can just put db.db in the same directory as your executable jar and document that fact. You don't have to allow selection on the command line if you don't want to but many, including myself, have done that.
Hope this helps,
Michael Morris
[ September 21, 2002: Message edited by: Michael Morris ]

Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
ravi janap
Ranch Hand

Joined: Nov 04, 2000
Posts: 389
Hi Michael
I have placed db.db file in <INSTALL>/submission/database directory and I ahve hardcoded the path to db.db file in my RemoteDataClient and LocalDataClient class as follows :

and I have mentioned the path to db.db file in the policy file as follows :

I hope that now I have got it right.
Thanks
Ravi
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Ravi,

private static final String dbname = "\\submission\\database\\db.db";

This is not a relative path. How can you be sure that there will be a \submission\database\ directory on the current root? Besides that, doing it that way makes it platform dependent. If you want to hard code it do it something like this:

Hope this helps,
Michael Morris
Ashik Uzzaman
Ranch Hand

Joined: Jul 05, 2001
Posts: 2370

Some late questionsby me!
I did not get any db file and recieved a mail from SUN that I have to create the db file and provide at least 20 records. Are you allowed to add 1 or 2 columns more in the database? (I don't have any wish) Just wanted to know if anyone has done it!
I am planning to use RandomAccessFile to read/write from the files. What are you guys using?


Ashik Uzzaman
Senior Member of Technical Staff, Salesforce.com, San Francisco, CA, USA.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: location of DB.DB file