Database programming with Java

D

Derek Clarkson

John said:
MS Access has made database programming simple for those who choose to
work in that environment. What db development environments are
available for Java developers to make quick db applications? What are
some of db options and Java libraries for creating databases for only
2-10 users in a LAN environment?

To be quite honest, I don't see whats wrong with Access for the environment
you describe (choke!, choke!). But if the system is to get any larger then
you might need to start looking at something different. You can do it is
Java, or any one of a number of alternatives. The question you really need
to ask is - What is the appropriate tool for the application I need to
develope, give the constrants I am aware of ?
Additionally, can you recommend a tutorial for how to design db apps
in Java? I'm primarily interested in where the db SQL code should
go...obviously not in the actual objects I'm storing, right? I mean, I
don't want my Customer objects to worry about how to store
themselves...

There are lots of tutorials around. The ones on java.sun.com are pretty good
for getting an initial idea. As for where you should put what, well thats
often a personal decision of the programmer based on their experience,
design philosophies and the requirements of the application.

Generally speaking I often write a DB class which manages access to the
database - connection, commits, rollbacks, disconnections, etc and provides
methods which enable me to easily access the DB from other classes with
only a line or two of code. For example, one common type of method I write
looks like this:

public ResultSet getRS(String SQLTemplate, String[] args)

With the connection already established by this class and error handling in
the method, it makes life much easier and allows me to get on with coding
the application.

I generally put the SQL in the classes which perform the tasks. This way the
SQL is within the context of the class that uses it. I've tried storing the
sqls in external properties files so they can be changed, but in the long
run I didn't find much advantage in doing this. When I first tried using
property files for sql I thought it would be a good idea because if we
changed DBs (which we did - several times) I could just change the sqls. In
reality this failed. The differences between databases is more than just
sql. I found I had to change the way that many of the classes worked as
well, especially if I had used stored procs instead of base sql. So my
opinion is to store the sql in the code. It's easiest and you always know
where the sql is, and what uses it. Makes changes easier to implement.
 
J

John O'Conner

MS Access has made database programming simple for those who choose to
work in that environment. What db development environments are
available for Java developers to make quick db applications? What are
some of db options and Java libraries for creating databases for only
2-10 users in a LAN environment?

Additionally, can you recommend a tutorial for how to design db apps
in Java? I'm primarily interested in where the db SQL code should
go...obviously not in the actual objects I'm storing, right? I mean, I
don't want my Customer objects to worry about how to store
themselves...

Best regards,
John O'Conner
 

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

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top