This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

OOP and JDBC

 
Elton Hughes
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34178
340
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic