Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

[URLyBird] JTable - getRowCount()

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

Another question. Below a simplified view of my data layer.



DBAccess is the given interface from the assigment





So I have a class RoomRepository, which I use in my GUI. This class works with HotelRooms. My repository does the convertion from a HotelRoom to a String[]. I have a Field in this class of type Data (which is the given interface). The class Data implements the given interface and requires String[]. My Data contains a basic cache. My Data-class also contains a variable of type FlatAccessFile. The FlatAccessFile does the actual read and write operations on my RandomAccessFile.

Now for a JTable I need to know how many rows there are in my database. In my case this information is know by the FlatAccessFile. But eventually my roomRepository needs this knowledge. How can I give this information to the repository.

1) May I add methods to the DBAccess interface? a method getRowcount or something like that?

2) I can add the the method to Data-class and in my repository use a field dbAccess of type Data and not of the type DBAccess (Given Interface)

How did you solve this? Has anyone has an opion at this problem?

Thanks in advance.

Greetz,
Kim
[ November 25, 2008: Message edited by: Kim Lauwers ]
 
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you need to know how many rows are in the database?
 
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Kim,

1) May I add methods to the DBAccess interface? a method getRowcount or something like that?



You should not modify the given interface. For finding out the number of rows from your table you should use the results of your find() method from the DBAcess interface implementation.

Greetings,
Liviu
 
Kim Lauwers
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Alecsandru Cocarla:
Why do you need to know how many rows are in the database?



You're right, my mistake

Thanks
 
Create symphonies in seed and soil. For this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic