• 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
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

OutOfMemoryError??

 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone...this is my problem:
If I start the application with a -db C:\\mydb.db option and mydb.db isn't a valid fly by night services database file (for example an ASCII file), the Data class does:
nFields = db.readInt();
description = new FieldInfo[nfields];
the value of nFields is absolutely wrong, because it contains a large integer value, so when it tries to dim the array description, it throws an OutOfMemoryError!
How I can achieve this behaviour?? I suppose is incorrect to insert in my code a try {} catch (OutOfMemoryError) { }
Thanks...
 
Ranch Hand
Posts: 109
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Some of us added a rudimentary integrity check to our startup code that would prevent this from happening if you opened up other files by mistake. There's another thread that discusses it, but I couldn't find it. Anyway, the code is like this:
 
Andrea Gazzarini
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Pete, but...
you can't write in your code
if(headerLen < 0 || nFields != 9 || recordCount < 1)
because in this way you will able to manage a datasource with only 9 field (future enhancements...). The structure of your database is hard-coded and I think it is not very well...
Thanks anyway...
 
If you are using a wood chipper, you are doing it wrong. Even on this tiny ad:
New web page for Paul's Rocket Mass Heaters movies
https://coderanch.com/t/785239/web-page-Paul-Rocket-Mass
reply
    Bookmark Topic Watch Topic
  • New Topic