• 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

How to code client of DAO?

 
Ranch Hand
Posts: 254
1
MySQL Database Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm trying my hand at using the DAO pattern but I doubt if I'm using it as it is meant. For the time being I'm calling the JDBC implementation (which is all that I'm going to need at this point).

Is retrieving the data in the main method for serious use case a good thing? I was reading old posts and a bottom post showed using the DAO with the help of dependency injection? I've never used dependency injection and would like to know how it would come in handy here.

Do let me know your thoughts and how could I improve my code.

Here is the code getting the data from the persistent store,

 
Rancher
Posts: 989
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dependency injection would remove the dependency between your client class and the JdbcCustomerInfoDao class. So all the client knows would be CustomerInfoDao which would typically be an interface.
Dependency injection however requires some libraries that implement it to be available in your client environment. Popular ones are CDI , Spring and Google's Guice.
 
Ahsan Bagwan
Ranch Hand
Posts: 254
1
MySQL Database Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for your response. It definitely helps me in getting started with DI.
 
When evil is afoot and you don't have any arms you gotta be hip and do the legwork, but always kick some ... 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