• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

IOException thrown

 
Ranch Hand
Posts: 528
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Baring in mind that all variables are initialized correctly and all exceptions are being handled:



why is an IOException being thrown on the line marked //<----- HERE ??
 
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you post the complete stacktrace of the IOException please. That might give the rest of us a better idea of what is going on ...
 
Marcelo Ortega
Ranch Hand
Posts: 528
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well i traced back to where the actual exception was thrown and it was where the line marked HERE is in the readFully method. ???



?

Regards.
 
Ranch Hand
Posts: 284
Netbeans IDE Firefox Browser Debian
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

what value of fieldnameLength are you reading?
is the exception thrown in the first iteration?
how many iterations are you performing?

Verify you are reading "expected" values for these vars,

Regards
 
Marcelo Ortega
Ranch Hand
Posts: 528
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is my output (after i inserted various print statements):



fieldnameLength = 4
i = 0
fieldNames = 4 //length

fieldnameLength = 64
i = 1
fieldNames = 64

fieldnameLength = 8224
i = 2
fieldNames = 8224

Input / Output error with file: C:\db-1x1.db :null


[ September 29, 2005: Message edited by: Marzo Kaahn ]
 
Oricio Ocle
Ranch Hand
Posts: 284
Netbeans IDE Firefox Browser Debian
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Obviously 8224 bytes for a fieldName is too long.
Is your header section well readed (int,int, short)?
Are you sure your file cannot be corrupted?
 
Ranch Hand
Posts: 267
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
Wow That's large for a fieldlength! Make sure you are reading the db file according to the schema you have! If it doesnt work! Reboot your machine maybe(might help)!
 
Marcelo Ortega
Ranch Hand
Posts: 528
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When i open my db file i see this:
#######�####name#@##location#@##size####smoking####rate####date#
##owner##

It seems to me as if it is reading "name" and "location" and reading the rest all together.

Could the file corrupt itself by simply opening it in some text area?

What could be happening here?
[ September 29, 2005: Message edited by: Marzo Kaahn ]
 
Oricio Ocle
Ranch Hand
Posts: 284
Netbeans IDE Firefox Browser Debian
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Marzo,
you can redownload your assignment.
I have done that twice.
Be aware that the asignment version matches the first download.
However send an email to Sun telling what are you going to do

Let us know what's happens then...

Regards
[ September 29, 2005: Message edited by: Oricio Ocle ]
 
Marcelo Ortega
Ranch Hand
Posts: 528
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please excuse me if i am revealing too much code, but i'd like to know whether it is my code or whether the db file is corrupt.

My db specs are:


The format of data in the database file is as follows:

Start of file
4 byte numeric, magic cookie value. Identifies this as a data file
4 byte numeric, total overall length in bytes of each record
2 byte numeric, number of fields in each record

Schema description section.
Repeated for each field in a record:
2 byte numeric, length in bytes of field name
n bytes (defined by previous entry), field name
2 byte numeric, field length in bytes
end of repeating block

Data section.
Repeat to end of file:
1 byte "deleted" flag. 0 implies valid record, 1 implies deleted record
Record containing fields in order specified in schema section, no separators between fields, each field fixed length at maximum specified in schema information

End of file



My (rough) implementation:



Output:

magicCookie: 257
sizeBytes: 159
numFields: 7
IOException thrown!

All i want to do for now is at least store the field names for futher testing.

Any ideas?

Thanks in advance,
Marzo.
 
Oricio Ocle
Ranch Hand
Posts: 284
Netbeans IDE Firefox Browser Debian
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hey hey





are you sure?

Regards
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Like Oricio said -

You may want to print out all your variables at this stage -
so you can see how big you are allocating the byte arrays, etc.

and the loop has to account for all the repeating fields and their parts.

You are probably getting the first field name - but then the one byte
will not be enough to "soak up" all the other field name "parts"
before the next field name.
 
Marcelo Ortega
Ranch Hand
Posts: 528
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks people, i got it, i was reading a byte instead of a short at the end of the loop.

Thanks again.
 
I didn't say it. I'm just telling you what this tiny ad said.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic