Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

[URLyBird] JTable - getRowCount()

 
Kim Lauwers
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 ]
 
Alecsandru Cocarla
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?
 
Liviu Carausu
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic