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

B&S: Quesion about RecNo

Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My interface is

package suncertify.db;
public interface DBMain {
// Reads a record from the file. Returns an array where
//each element is a record value.
public String [] read(int recNo) throws RecordNotFoundException;
// Modifies the fields of a record. The new value for field n
// appears in data[n].
public void update(int recNo, String [] data)
throws RecordNotFoundException;
// Deletes a record, making the record number and associated disk
// storage available for reuse.
public void delete(int recNo) throws RecordNotFoundException;
// 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) throws RecordNotFoundException;
// Creates a new record in the database (possibly reusing a
// deleted entry). Inserts the given data, and returns the record
// number of the new record.
public int create(String [] data) throws DuplicateKeyException;
// Locks a record so that it can only be updated or deleted by this client.
// If the specified record is already locked, the current thread gives up
// the CPU and consumes no CPU cycles until the record is unlocked.
public void lock(int recNo) throws RecordNotFoundException;
// Releases the lock on a record.
public void unlock(int recNo) throws RecordNotFoundException;
// Determines if a record is currenly locked. Returns true if the
// record is locked, false otherwise.
public boolean isLocked(int recNo) throws RecordNotFoundException;

My database is not contain any record number field. It has only following field


Then how can I use recNo for update and create?
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you read the file into your program, assign logical record numbers ( I use 0 indexed records). I believe there are plenty posts on this topic. Search on recNo and B&S.

Good luck.
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I treat record numbers as the records index on the data file. For example:
the first record in the file is recNo 0, the second is recNo 1, the third is recNo 2 and so on...
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

do you sure that your instruction don't contain something that ... 2 byte falg . 00 implies valid record, 0x8000 implies deleted record !

best regards.
SCJP, SCJD ( in progress ... ).
Vaishali Paramane
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yes in may instruction contain that 2 byte flag.
I had problem how to maintain that database using record number.
because if some one update the record and other one also trying to update same record then how can understat second one client updating same(correct) record or not.

may b i am asking stuppid quesion .

thanks for reply
Our first order of business must be this tiny ad:
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic