• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Doubt about recNo in URLyBird 1.1.2

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I downloaded my SCJD assignment yesterday.I went through the specifications and found that the records which are in in the database do not have a primary key.Also,most of the methods like create,update etc have recNo as the parameter.

My doubt is that can I use recNo as the primary key and include it as a record field.This would be similar to the way its done in Andrew`s SCJD book.
Then it would also be possible to throw a DuplicateKeyException which is thrown by create() method.
 
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Rohan,

yes, you can use recNo as primary-key in you application, but you cannot add it as a field into the database. You probably have something like "but because the data must continue to be manipulated.." in your assignment.

I did not throw the DuplicateKeyException anywhere in my application, but I'm sure you can. As long as you explain it in your choices.txt, you'll be fine.

Herman
 
rohan tiwari
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The DB interface provided by Sun has a method create() that throws a DuplicateKeyException.
 
Ranch Hand
Posts: 516
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by rohan tiwari:
The DB interface provided by Sun has a method create() that throws a DuplicateKeyException.



The DB interface provided by Sun has a method create() that can throw DuplicateKeyException.

It is possible that your implementation does not throw it. In that case, mention it in your design choices.

Regards,
Alex
 
rohan tiwari
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Alex,

it is given that

"Your data access class must be called "Data.java", must be in a package called "suncertify.db", and must implement the following interface: "

So I think that I have to follow the interface as it is.
[ January 12, 2008: Message edited by: rohan tiwari ]
 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by rohan tiwari:
Alex,

it is given that

"Your data access class must be called "Data.java", must be in a package called "suncertify.db", and must implement the following interface: "

So I think that I have to follow the interface as it is.

[ January 12, 2008: Message edited by: rohan tiwari ]



Hi,

You're right you must implement the interface so in your implementation class you have to declare your method throws that exception but in your method, you don't have to throw it.
 
Alex Belisle Turcot
Ranch Hand
Posts: 516
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi.

The interface tells you which checked exception you can throw. Any other non-specified checked Exception cannot be thrown.

So the interface really doesnt tell you must throw it, but rather that you cannot throw something else. You are free to implement it or not, but it is still a good idea to mention your choice is your design choices doc.

Regards,
Alex
[ January 12, 2008: Message edited by: Alex Belisle Turcot ]
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How can you have a duplicate key when you are not specifying a key in the first place ? Or is it you might have duplicate keys afterwards if clients created a record at the same time
 
Herman Schelti
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Michael,



Good question: that's why I did not use the DuplicateKeyException at all.

Herman
 
reply
    Bookmark Topic Watch Topic
  • New Topic