• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

location of DB.DB file

 
Ranch Hand
Posts: 389
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
ravi janap
Ranch Hand
Posts: 389
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 2379
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic