aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Database .db file question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Database .db file question" Watch "Database .db file question" New topic
Author

Database .db file question

Andreas Junizar
Greenhorn

Joined: Dec 13, 2011
Posts: 7
Hi,

I want to introduce myself, my name is Andreas Junizar, i am newbie on this exam. Actually i want to learn java. Right now my expertise is PHP, MySQL, and web technologies. Nice to meet you all!

Ok Lets get into the business.


Fellow programmers,

I just want to make sure (doubtful). the .db file i have received from OCMJD Exam. Based on the information from requirements :

--> It must allow the user to book a selected record, updating the database file accordingly.

Does this mean i need to update (book) the file itself?

If that so, that means i do not need to create database such as "localhost" or something. I want to clarify that in order to pass the exam.

Thanks

Ndre
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2267
    
    3

Hey, Andreas. Welcome to JavaRanch!

Well, the thing is, you'll have to create an application where a window is displayed to the user, and this window has a JTable with all records that are contained in the .db file. Then, when the user selects a row (where each row of the table has the information about one room), you somehow allow this user to book the room, that is, you'll just have to update the selected record with a customer ID (an 8-digit number).

Regarding the access to the .db file, you'll just have to implement the interface contained in the instructions, and this implementation will be responsible for accessing the .db file. You'll also have to make sure the access to this file is thread-safe, so the integrity of the file is guaranteed.

Now, you said that you want to learn Java... do you already have the SCJP/OCPJP?


Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
Andreas Junizar
Greenhorn

Joined: Dec 13, 2011
Posts: 7
Hey, Andreas. Welcome to JavaRanch!

Well, the thing is, you'll have to create an application where a window is displayed to the user, and this window has a JTable with all records that are contained in the .db file.
>>> This part I need to do the conversion from .db to JTable format in order to see it right. I need to build JTable contains all records so from there, I can do something like updating, creating, deleting items. Correct me if i am wrong.

Then, when the user selects a row (where each row of the table has the information about one room), you somehow allow this user to book the room, that is, you'll just have to update the selected record with a customer ID (an 8-digit number).
>>> Right now I can update the booking using this JTable. Customer ID is when you input right, or is it randomly generated.

Regarding the access to the .db file, you'll just have to implement the interface contained in the instructions, and this implementation will be responsible for accessing the .db file. You'll also have to make sure the access to this file is thread-safe, so the integrity of the file is guaranteed.
>>>Not quite understand about "integrity of the file is guaranteed"? May you explain this to me more?

Now, you said that you want to learn Java... do you already have the SCJP/OCPJP?
>>> Yes I did. Want to know about how developing software with it and learn about Java API.

Andreas Junizar
Greenhorn

Joined: Dec 13, 2011
Posts: 7
What I am saying here is

.db original file cannot be touch or changed. The application will take db1x1.db to be read and then put it on JTable in order to be updated, created, and deleted. Am I right? Correct me if i am wronged

Thanks
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2267
    
    3

This part I need to do the conversion from .db to JTable format in order to see it right. I need to build JTable contains all records so from there, I can do something like updating, creating, deleting items. Correct me if i am wrong.


Yes. You'll create a presentation layer, and there you'll put the code that displays the content of the .db file in a JTable. And by the way, the only thing that you have to let the user do is book a room, that is, update the customer id of that record. Creating and deleting records is not needed to be offered in the UI.

Right now I can update the booking using this JTable. Customer ID is when you input right, or is it randomly generated.


No, the user will somehow enter this id. For instance, when the user clicks on the "Book" button, a dialog is displayed, and there the user provides the customer id.

Not quite understand about "integrity of the file is guaranteed"? May you explain this to me more?


What if 2 users (in different machines, accessing the server) want to book the same room at the exact same time? One of them will have success, and for the other, you can display a dialog saying that the room is unavailable.

Yes I did. Want to know about how developing software with it and learn about Java API.


That's good! But do you already have the SCJP/OCPJP?

db original file cannot be touch or changed. The application will take db1x1.db to be read and then put it on JTable in order to be updated, created, and deleted. Am I right? Correct me if i am wronged


You just have to keep a copy of the original file to send it back to Oracle when you're done. But the file being used by the application will have to be changed, otherwise, how would you update records?
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2267
    
    3

And by the way, in order to quote the content of other posts, just press the button in the post you want to quote. Or put the text you want to quote inside "quote" tags.
Andreas Junizar
Greenhorn

Joined: Dec 13, 2011
Posts: 7
Roberto,

Thanks for your help.

To keep the integrity of the file if you want to update (for example), you need to read file, update, and save it to the file in process, is that correct?

If that so, everytime you do updating, deleting, you must always do read the file, (do something, like updating, and deleting), then save it into the file( which has magic cookies, field byte and so on).

Please correct me if i am wrong.

Thanks
Anayonkar Shivalkar
Bartender

Joined: Dec 08, 2010
Posts: 1510
    
    5

Andreas Junizar wrote: To keep the integrity of the file if you want to update (for example), you need to read file, update, and save it to the file in process, is that correct?


Simply reading, updating and saving the data to file does not guarantee the data integrity. Data integrity comes into picture when multiple users are dealing with data. e.g. both users read file, selects same record and try to update it. Then, should the code overwrite first user's data with another user? Or it should display a warning to second user that record is already being updated? In either case, data should not be corrupted. More detailed example would be : both user read a record. User 1 updates field 1 of that record, and user 2 updates field 2 of that record. So, final result must be a record with both fields updated. That is data integrity.

Andreas Junizar wrote: If that so, everytime you do updating, deleting, you must always do read the file, (do something, like updating, and deleting), then save it into the file( which has magic cookies, field byte and so on).


Well, this is not wrong, but it can be done with other ways with relatively less disk I/O operations. E.g. you don't have to read whole file every time. For most of the time in OCMJD assignment, creation and deletion of record is not necessary. So all you'll do is update the record (and if it is 'booking' of a record, then only one field would have to be updated). So, it is possible to read all the records at startup, and make changes to that data structure first, and then persist those on file after all changes are made. E.g. If more users are updating same record concurrently, then do all those operations in 'memory' (i.e. data structure), and once final data is ready, write it on disk. Further, since data structure is already updated, you don't have to read file again and again.

This is just one approach. You'll get several alternatives in Andrew Monkhouse's SCJD book.

All the best.


Regards,
Anayonkar Shivalkar (SCJP, SCWCD, OCMJD, OCEEJBD)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Database .db file question