Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-29-2007, 02:25 PM
Member
 
Join Date: Jul 2007
Posts: 1
Rep Power: 0
Ixnay is on a distinguished road
Exclamation Where to proceed now?
Hi
I have to create a database but not by using a JDBC by using textPad. It is going to be command line.I would like to know if i can store data,read,delete,search by using RandomAccess onto dat or txt files? for example: i have to delete an item by using the seek() then deleting it. Can this be possible?

This database is like an inventory database storing materials like life-jackets and wakeboards for example. So i created a main class, then sub-classes. I have created my classes which use inheritance.

Secondly, my program has a "address database" in it, which has the name, phone numbers and address of contacts.. Can i use a linked list to store data here?

And no im not getting paid, and it is for personal achievement.. just incase your planning to give nasty replies.. Now that i have already created my classes, can someone tell me where to proceed now please
Thanks
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 07-29-2007, 04:31 PM
Senior Member
 
Join Date: Jul 2007
Posts: 135
Rep Power: 0
brianhks will become famous soon enough
Default
You can use a text file for this but it is difficult. You cannot just insert into the middle of a file, nor can you just delete. You will end up rewriting the entire file out again.

You may find it easier to use a 100% Java DB embedded into your application like HSQLDB I've used it before and it is very easy.

Good luck.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-29-2007, 06:37 PM
levent
Guest
 
Posts: n/a
Default
Quote:
You can use a text file for this but it is difficult. You cannot just insert into the middle of a file, nor can you just delete. You will end up rewriting the entire file out again.
I think this should be possible with random access files.

Quote:
You may find it easier to use a 100% Java DB embedded into your application like HSQLDB I've used it before and it is very easy.
Latest version of JDK comes with a database which should simplify database developments. But i am not sure if JRE includes it too.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 07-29-2007, 08:06 PM
Senior Member
 
Join Date: Jul 2007
Posts: 135
Rep Power: 0
brianhks will become famous soon enough
Default
Originally Posted by levent View Post
I think this should be possible with random access files.
It is possible but difficult. For example lets say you have the following file of names:
George Bush
Kermit the Frog
Bill Clinton
Mike Young
Skooby Doo

Now you wish to delete Bill Clinton. The name "Bill Clinton" takes up 12 bytes right in the middle of the file. You cannot just remove them like in an editor. You can blank them out but, in order to remove them you must rewrite the file from at least the beginning of Bill Clinton to the end.

For a small database you can read the entire thing into memory and write it back out when you have finished manipulating it.

Or you can use fixed length records in the file so that every name takes up 20 bytes (or whatever). This will still leave holes in the middle of the file that you have to keep track of and fill back in when inserting data.

The only two viable choices are to read the whole lot into a memory structure and write it out when done or to use a real database such as hsqldb (I advocate hsqldb because I've used it and it is delightfully easy).
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 07-29-2007, 08:16 PM
levent
Guest
 
Posts: n/a
Default
Quote:
The only two viable choices are to read the whole lot into a memory structure and write it out when done or to use a real database such as hsqldb (I advocate hsqldb because I've used it and it is delightfully easy).
I agree to this comment. These are the best approaches for this problem.

There are databases which does not require a database server. The databases are kept as plain files in your file system and as far as i know you can reach them with JDBC.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +2. The time now is 03:10 AM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org