Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Validation for database file

 
pramod karnani
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 147
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Carlos Morillo
Ranch Hand
Posts: 221
Java Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please also check the FAQ for Why do we care about the magic cookie?.


Hope this helps,


Carlos.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic