wood burning stoves 2.0*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Bodgitt and Scarper create method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Bodgitt and Scarper create method" Watch "Bodgitt and Scarper create method" New topic
Author

Bodgitt and Scarper create method

Glen Iris
Ranch Hand

Joined: Jul 13, 2011
Posts: 164

Hey All,

In the B&S interface which I must implement, there exists a create method with an int return type. The requirements do not state that the program requires the ability to add new records to the db.

From reading through other threads on here, I know I must write the code for the method even though my program will not use it.

What is the best way to indicate that the creation of a new record failed (for any reason)? The return type is int so I cannot return null. The return type int is supposed to indicate the new record number. What if there is no new record number as the operation has failed? I was thinking of returning -1.

Any Thoughts?


OCPJP 6, OCMJD
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5126
    
  12

Returning a negative number is a possibility. Returning a (runtime) exception could be another one.


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
 
Don't get me started about those stupid light bulbs.
 
subject: Bodgitt and Scarper create method
 
Similar Threads
beginner / idiot
About RecordNotFoundException
URLyBird 1.1.1
Create method: impossible to call from lock/unlock.
URLyBird Data Access Package Design