• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Database Access Class Pattern

 
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This could probably go in the patterns forum...or JSP... or... here?

Scenario:

You want to use a PreparedStatement to issue an INSERT statement somewhere in your application.


What if at some point you want to add another field to that tablename and modify the PreparedStatement?

What does the pattern look like if I want to create a Database Class that creates the connection, creates the datasource and handles the executeUpdate() part?

Should I encapsulate the Database Class into my business object, or do you encapsulate the Database Class into an intermediary class and then encapsulate the intermediary class into your business object?

Am I looking at a Factory pattern or a Data Access Object pattern? (that's not a quiz... I'm not looking at any patterns currently.)

Or should I just leave it alone and cram everything into one method in my business object that creates the connection, datasource, etc.? Something has to get recompiled anyway... (just read the evil design patterns by Paul...)

This is where I'm at.

I'm adding a PQIDBLog property to my business object and passing the PreparedStatment to this class. Yes, this is part of a web app. I want to log certain points of the web app to a database, rather than the server log files. Is this the right approach?

 
What could go wrong in a swell place like "The Evil Eye"? Or with this tiny ad?
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic