Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2009
    Rep Power

    Default Common DataBase Layer


    I am beginner in J2ee,wanna know how can we create centralized database layer,whether i need to make java bean class or package??? please some one explain with me the example

  2. #2
    travishein's Avatar
    travishein is offline Senior Member
    Join Date
    Sep 2009
    Rep Power


    I like to use a kind of data accessor approach to database work, where I have a Java bean to "model" the table data, that is ususally one bean or every table, or entity thing I might be interested in using in my application.

    And then i have an accessor that fetches me an instance of this bean by querying the database and then populating the results into the bean, or takes an instance of the bean as a parameter and uses the appropriate SQL query to store this into the databse table(s). I would even make this accessor an interface method, and then provider an second class that implements this interface, so as to allow for different low level back end implementations if I later choose to do this.

    So for this, I would have
    - a package for the beans.
    - a package for the data accessor interfaces
    - a package for the data accessor implementation

    Then I discovered Hibernate and later iBatis, which i now mainly use the latter, as I prefer to have the control over the SQL queries, so this would be my data accessor implementation.

    I also like to use a single interface and implementation of what I call a 'manager', where the implementation ties together one or more data accessor interfaces, such that I have a single component that has all the application level functions i want to do, so my things just need to maintian a reference to this manager, and its implementation has references to the many data accessor classes. this allows for me to have a complex method, such as one that invokes a query in one data accessor and then with each result invokes a second query in a different data accessor. this becomes really useful when the data accessors are backed by different databases, or even different types of data stores, such as LDAP. once you make everything conform to a data accessor interface that gets you a bean, many different things like this become readily possible. I think for this reason some people call this what I call a 'manager' interface, the 'facade design pattern'.

    Hope thats inspirational.

Similar Threads

  1. ';' expected, not of the common kind..
    By Addez in forum New To Java
    Replies: 6
    Last Post: 09-02-2009, 04:37 AM
  2. ow to get Home directory using Common Net ftp api?
    By cprash.aggarwal in forum Advanced Java
    Replies: 1
    Last Post: 03-01-2009, 05:57 PM
  3. How to get Home directory using Common Net ftp api?
    By cprash.aggarwal in forum Networking
    Replies: 1
    Last Post: 03-01-2009, 05:37 PM
  4. Creating layer on images ?
    By Qmalq in forum AWT / Swing
    Replies: 2
    Last Post: 01-27-2009, 10:20 PM
  5. Where i have to write the common data to jsp
    By trill in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 08-07-2007, 07:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts