Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript 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 ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

NX: URLyBird: how to start with data access

Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My first time in this forum howdy all!!
I've just started with my 1.2.3 version of the URLyBIRD assignment. I've started reading the forum for hints tips an ideas. But there are so many things to concider, I'm almost afraid of starting of the wrong way, but today I finally opened eclipse and started with the data access layer.
I'm just putting the data access in one class right now, till it works and refactoring it as i go along.
What I was thinking was that the "server"controller class, creates one instance of the Data class. The constructor of the Data-Class opens a RA file object for file access. (and somewhere the server class calls a close for the RA file object)
What i'm still not certain of is how to access the data section of the data file.
First of you have to get to the data section of the db.file
What would be the correct way?


I've someone could give me a push in the right direction,

[Andrew: broke up long lines so that this displays without requiring horizontal scrolling]
[ November 13, 2003: Message edited by: Andrew Monkhouse ]
author and jackaroo
Posts: 12199
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Hans,
Welcome to JavaRanch.
Personal thoughts: your first solution is not very extensible if you ever need to add an extra field, or change the size of a field (or even work with a totally different database that has the same meta schema). In that respect, your second solution is much better.
But I would probably only want to read the schema once - once you have read it the first time, you can store the size of the schema and then just skip it for future reads.
I would also consider refactoring your two constructors - one could call the other. It won't make much difference with what you have now, but it might make a difference if you want to do much more in the constructors.
Regards, Andrew
Hans ter Wal
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Andrew,
Thanx welcome and the reply.
I went for option 2
Ranch Hand
Posts: 234
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, if you Data class performs a lot of other operations such as locking,
unlocking, deletes, search, find,....You may want a helper class to perform
all of the actual opening, and reading of the DB file. Then have
a variable in the Data class that refers to your helper class. Your Data
class can still write to the DB file but it gets an instance of the DB file
from the helper. When the Data class needs all of the records, it asks
the helper class, when it needs to know the length of a field it asks the helper class...and so on. Your helper class will more than likely be a singleton because I am assuming your assignment deals with only one file
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic