File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Using database in program. Design ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "Using database in program. Design ?" Watch "Using database in program. Design ?" New topic

Using database in program. Design ?

Michael Boehm
Ranch Hand

Joined: Jun 02, 2010
Posts: 51
After having run through Sun's beginning tutorial on JDBC I am playing around with making a small program that retrieves some rows from a local mySQL database.

Is it reasonable to create a class whos responsibility is to retrieve rows based on schema-dependent queries ?
After this I have been thinking that it seems likely that this class is something I could use whenever I am connecting to a database from a program so it could be beneficial to make it reusable. But then one needs to somehow "abstract" the specific relational schema for the present database away and somehow make this class "generic". So it is as if I am in need of constructing some interface for the database which can give me info about its schema(s). Don't know if I am making sense here !
Martin Vanyavchich
Ranch Hand

Joined: Sep 16, 2008
Posts: 241
I think you're making sense A lot has been done regarding this issue.

Take a look at Apache Cayenne, CRUD maybe even Hibernate or TopLink



I no good English.
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46412
You might however be reinventing the wheel; things like ResultSet might already provide the functionality you require.

And I shall move this thread to our JDBC forum.
I agree. Here's the link:
subject: Using database in program. Design ?
It's not a secret anymore!