File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Database integrity check 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 "Database integrity check " Watch "Database integrity check " New topic
Author

Database integrity check

Miguel Roque
Ranch Hand

Joined: Oct 24, 2002
Posts: 126
Hello.
When we try to open a text file using the Data class we get a OutOfMemoryException. Due to this i've decided to implement a small integrity check on the data class. As the file size less the header length divided by the number of records should give us the record length, i've added the following code just before we create the array of field info.

Usualy when reading a text file, we get a huge number of fields, a huge header length and record count when compared with the file size. By making this comparison, when reading a text file we get values that are less than 1.
Comments please.
Thanks,
Miguel
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Why are you trying to open a text file with the Data class?
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Miguel Roque
Ranch Hand

Joined: Oct 24, 2002
Posts: 126
Hello Mark.
I'm not trying to open a text file, it's just a integrity check for future users of the data class so that they will not try to do it.
Thanks,
Miguel
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

OK. Is that one of the requirements? And Doesn't the Data class constructor throw an IOException if something like this happens?
Have fun.
Mark
Miguel Roque
Ranch Hand

Joined: Oct 24, 2002
Posts: 126
Hi.
No, it's not a requirement. No it doesn't throw a IOException because when we try to read a text file we can get a number of fields with values bigger that 10000000! Can you imagine a array of FieldInfo like this?
With this check, I'm just making the Data class more robust and more bullet prof!
I don't belive that I will lost points due to this. Do you think I will?
Thanks,
Miguel
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

I don't belive that I will lost points due to this. Do you think I will?
I can't answer that question.
But I know I didn't lose points by not changing it.
Mark
Miguel Roque
Ranch Hand

Joined: Oct 24, 2002
Posts: 126
Hello Mark.
Thanks for your help. I will keep the Data class with this small integrity check. I've read here some old post's of people that has done it.
I'm about to finish the coding. I'me reviewing the design and reading the notes made on paper so that I can start to write my designs file.
Best regards,
Miguel
 
Don't get me started about those stupid light bulbs.
 
subject: Database integrity check