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

If number of records over Max int, How to List All Records?

 
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If the number of records in the db file over Maximum integer, How to List All Records? because the maximum index of an array is the Max int, the size of Vector and ArrayList is interger. Sun's db file might have records over the max int because the record number is a long number. How to handle it?
It is also possible that findByCriteria get a lot of records that over Max int, but return type is long[], the max index is max interger,so the long[] can not hold so many records. The program will crash if this happen.

Peter
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Peter,
I don't think you need to worry about that in your code. Make a note of it in your documentation (to show you did think of it) then don't worry about it. In my opinion, dealing with such a problem (and with how to display so many records, and with how to transfer that many records over the network, and ...) goes beyond the scope of the assignment.
Regards, Andrew
 
Peter Yunguang Qiu
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Andrew:
You are right, I should document the problem. I don't worry about my code. What I think is if the method

is a reasonable design. Sun should document it clearly and tell us the following assumption:
We should assume findByCriteria can't find the number of records beyond max int. But that is not enough, because "It must allow the user to search the data for all records"( I think here "search" also means transmit and display). Therefore, we should also asume "all records" in db file is less than max integer. If we assume that, use integer as the record number is enough.
If we didn't assume that, the solution would be use long[] array or ArrayList or Vector to transmit data many times. the method seek(long pos) alow us to do that.
Peter
 
Peter Yunguang Qiu
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't think we should handle the long record number.

Even if we counted all the hotel rooms in the world, the result number would be less than Max_integer. Suppose all of the people in the United States went out of home and each of them rented 10 rooms in hotel at the same day, the number of rooms needed would be less than Max_integer. So, the long record number doesn't make sense unless the URLyBird would fly out of the earth some day. But right now Sun let us MUST use
long[] to hold record numbers, we HAVE TO use it?
Peter
[ December 21, 2003: Message edited by: Peter Yunguang Qiu ]
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You MUST use a datatype of long here. But there's no "MUST" that you need to allow all possible values of the datatype. For example, a long could also be negative - but I don't think anyone here uses negative record numbers. I could imagine ways you could do it if you really wanted to, but I would prefer to avoid such needless confusion. So it's fine if you don't support some values of record numbers, like negative numbers, or anything over Integer.MAX_VALE. No problem.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic