aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Validation for database file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Validation for database file" Watch "Validation for database file" New topic
Author

Validation for database file

pramod karnani
Ranch Hand

Joined: May 22, 2007
Posts: 88

Hi All,

First of all I would like to know that

Sun accessor can check our application with any database file ?
or they will check our application with the database file that Sun provided ?


What are the validation for the database file we should do before starting application?

I am doing the following validation for database file before starting application:

1.correct magic cookie
2.readable file
3.writable file
4. should exist
5. should ends with *.db



I know the magic cookie for my database file so I hard code since without reading file how can we know the exact value of magic cookie so I hard coded in constant file . is it okay?


Am I missing some validation for database file ?



Please let me know.


Regards,
Pramod
Yucca Nel
Ranch Hand

Joined: Nov 20, 2008
Posts: 147

pramod karnani wrote:
Hi All,

First of all I would like to know that

Sun accessor can check our application with any database file ?
or they will check our application with the database file that Sun provided ?


What are the validation for the database file we should do before starting application?

I am doing the following validation for database file before starting application:

1.correct magic cookie
2.readable file
3.writable file
4. should exist
5. should ends with *.db



I know the magic cookie for my database file so I hard code since without reading file how can we know the exact value of magic cookie so I hard coded in constant file . is it okay?


Am I missing some validation for database file ?



Please let me know.


Regards,
Pramod


Perhaps too much validation... the magic cookie is itself enough validation. Here is my sequence of file validation I did.
1. GUI allows user to select file from current directory and does a default display of all files that end in .db This means that this application is not tied to files that end with .db but uses .db files as default. File should be readable and writable yes. I hardcode the magic cookie lower down as a validation but as a means of protection (due to this db being share by legacy application) I ALSO ensured that schema matches so that this application ill not create corrupt data for any existing application using the same database.


SCJP 6.0, SCJD (400/400), SCBCD for JEE 5, SCWCD 1.4 I do videos for development at
http://www.youtube.com/user/thejartender?feature=mhee
I am probably the only developer ever to have had an orange sized brain tumor in my brain while learning development!!
Carlos Morillo
Ranch Hand

Joined: Jun 06, 2009
Posts: 221

Please also check the FAQ for Why do we care about the magic cookie?.


Hope this helps,


Carlos.


SCSA, OCA, SCJP 5.0, SCJD, CCDH, CCAH http://www.linkedin.com/in/carlosamorillo
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Validation for database file