My own primitive database

H

Hellnar

Greetings
For an assignment , I have to combine java and CGI to make a basic web
page (auction type) , I will need to keep some data to track the info
of items users etc so I will have t arrange some kind of primitive
database (such as writing data to a file and reading back when needed)
or something like that. What would you recommend for such basic data
keeping (also please mention what java libraries I should be looking
for)?

Cheers
 
T

Thomas Kellerer

Hellnar wrote on 06.04.2008 11:03:
Greetings
For an assignment , I have to combine java and CGI to make a basic web
page (auction type) , I will need to keep some data to track the info
of items users etc so I will have t arrange some kind of primitive
database (such as writing data to a file and reading back when needed)
or something like that. What would you recommend for such basic data
keeping (also please mention what java libraries I should be looking
for)?

Why don't you go for a small embedded SQL database like Derby, HSQLDB or H2?

Thomas
 
H

Hellnar

Hellnar wrote on 06.04.2008 11:03:


Why don't you go for a small embedded SQL database like Derby, HSQLDB or H2?

Thomas
Sounds interesting , would it be an easy learning curve ? Also, would
these embedded databases need a new software to be installed at the
server ? (excuse my ignorance , I am pretty newbie at this :) )
Cheers
 
M

Martin Gregorie

Sounds interesting , would it be an easy learning curve ? Also, would
these embedded databases need a new software to be installed at the
server ? (excuse my ignorance , I am pretty newbie at this :) )
If you're using Java 6 you already have Derby installed. It is called
Javadb by Sun. I don't know where it ends up on Windows, but on a *NIX box
its installed in /opt/sun/javadb along with its documentation and some
example code. You'll have to adjust the search path and classpath before
using it, but otherwise its all there.
 
C

CK

Words to the wise said:
Greetings
For an assignment , I have to combine java and CGI to make a basic web
page (auction type) , I will need to keep some data to track the info
of items users etc so I will have t arrange some kind of primitive
database (such as writing data to a file and reading back when needed)
or something like that. What would you recommend for such basic data
keeping (also please mention what java libraries I should be looking
for)?

Why not just use a properties file, if you only need something flat
that is.
--
Claus Dragon <[email protected]>
=(UDIC)=
d++ e++ T--
K1!2!3!456!7!S a29
"Coffee is a mocker. So, I am going to mock."

- Me, lately.
 
M

Mark Space

Hellnar said:
Greetings
For an assignment , I have to combine java and CGI to make a basic web
page (auction type) , I will need to keep some data to track the info
of items users etc so I will have t arrange some kind of primitive
database (such as writing data to a file and reading back when needed)
or something like that. What would you recommend for such basic data
keeping (also please mention what java libraries I should be looking
for)?

Cheers

Derby does sound like a good idea, but if your assignment requires you
to implement more of it yourself, look at RandomAccessFile. That's how
we would have implemented a simple DB back in the old days.

To make an index, you can open the file, read it in, and drop the keys
into a TreeMap. Or look at persisting the TreeMap to disk.

Will you be using actual CGI? or using a container like Tomcat? Any
thought to implementing the web server in Java too? How "real" should
this auction site be?
 
M

Mark Space

Chase said:
The simplest way to do that would be to read it from a file.

That's actually a good point. Read the entire file into memory and just
deal with it there. That's certainly much easier than trying to fiddle
with record locking on disk or embedding SQL.

However, the OP may want a more "real" site. Don't forget that Facebook
was started by a student (or two) in his dorm. If the site is intended
to be "real" the OP should probably be using SQL and a web container
too, maybe even Struts or Spring or something like that.
 
R

Roedy Green

What would you recommend for such basic data
keeping (also please mention what java libraries I should be looking
for)?

There are so many databases out there, so many free that these is no
point in rolling your own. They deal with recovery in case of a crash
so you don't lose everything. That is quite difficult to arrange when
you roll your own.
 
R

Roedy Green

Also, would
these embedded databases need a new software to be installed at the
server ? (excuse my ignorance , I am pretty newbie at this :) )

Derby comes with the JDK. Others you would have to install. But his
is a microscopic amount of work compared with writing and debugging
your own. There are already way more than enough databases. There are
thousands of higher priority task on the planet than creating yet
another.

See http://mindprod.com/jgloss/sqlvendors.html
 
D

David A. Redick

Ever play with SQLite http://sqlite.org ?
Its one of the those single file non-server databases.
I find it much more useful and just a .INI file or XML file for data
storage.
Here's a JDBC for it http://www.zentus.com/sqlitejdbc/

You probility could / should use it to prototype with before taking
the time to setup
a PostgreSQL or MySQL or similiar "real" databases. Usually they're a
pain.

If this is a one time school/lab project then I would just use SQLite
or similiar
single file SQL databasette.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top