Meaningless Drivel is fun!*
The moose likes JDBC and the fly likes OOP and JDBC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "OOP and JDBC" Watch "OOP and JDBC" New topic
Author

OOP and JDBC

Elton Hughes
Ranch Hand

Joined: Jun 19, 2003
Posts: 72
Hello All,
I am new to Java and JDBC and I have a question.
Below is a program that works extremely well, but has one minor annoyance.

So far, so good. The only problem is that I need wage information for grants 201, 501, 542, 604, and 744. Not only that, but there are 10 other SQL statements that need to be run on each grant.
So, is it possible to make an abstract class of almost all of the code and then have concrete class with a main method fill in the rest?
Or, is there a better way of re-using code and not end up with 50 classes (that do work extremely well)??
Thank you for your time.
Elton
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30065
    
149

Elton,
First step is to put that main method in an object (for reuse.) Look into using a prepared statement. Then you can pass the id in using the constructor (or a set method) and reuse the sql.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: OOP and JDBC
 
Similar Threads
what is HttpSessionBindingListener
How to connect to mysql database?
ClassCastException with Connection Pooling
JDBC Connection (or "I Am At My Wits End")
Need Code Review