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

URLYBird Data Interface Questions

Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The create method of the Interface throws a DuplicateKeyException, what is the key? There are no room numbers, is it valid to have the same hotel in the same city have identical rooms available on the same night? I previously did the Flight Reservation Project some years ago and it used physical record numbers in embedded in the data however URLYBird has no Keys.

When updating, reading and deleting records the methods to do so take a record number (int) argument, record numbers are a logical construct, is it safe to assume that when assessing records a user must first search for a record before manipulating it, I'm assuming that it is not valid to directly input record numbers into a field on the interface.

Is it safe to assume that even when running in Non-networked Mode the Server first has to be started, my Server returns Session IDs first thing, and maintains a Synchronized list of all records that are locked by what Session ID, these are accessed thru static methods


public class Server extends Thread {
public final DataAccess = new DataAccess();

class DataAccess {
private static int sessionId;

public synchronized static int setSessionId() {
DataAccess.sessionId += ((int) (Math.random() * 100)) + 1;
return sessionId;

Even though I'll have a bogus socket connection that I'm not going to use, I can still use record locking in Non-Networked Mode, with no serialized objects, is this valid?

This is int the specification
It must allow the user to search the data for all records, or for records where the name and/or location fields exactly match values specified by the user.

This is in the interface
// Returns an array of record numbers that match the specified
// criteria. Field n in the database file is described by
// criteria[n]. A null value in criteria[n] matches any field
// value. A non-null value in criteria[n] matches any field
// value that begins with criteria[n]. (For example, "Fred"
// matches "Fred" or "Freddy".)
public int [] find(String [] criteria)

These don't match, one says "exactly match" the other says "begins with", which is correct
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Thomas! I beleive that the recNo is the actual physical number in which the record is written in the file. For instance, after the header length (which specifies the names of the fields and its sizes), the first record showed (flag and field info) should have recNo = 0. I think lots of people use that recNo as the primary key in the db, at least I am... Because of that, I will never have to throw a DuplicateKeyException in the create() method. I just implemented it as to follow Sun's spec, nothing else.

Concerning the equality issue, I think Sun leaves up to you whether two hotel rooms can be equal. According to my logic, two rooms may have same owner, the same location, the same hotel room, etc. and will still be two different rooms.

About the find() method, I think the one requiered by the DBMain interface is a low-level one that should be smartly called by a higher-level one responsible for looking for the "exact match" of the client's request (using regular expressions is my first idea - I haven't implemented it yet).

Have a nice day!
[ July 12, 2005: Message edited by: Alex Matute ]
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic