J
java-john
I'm doing a 3 tier development (i.e. Presentation <-> Business <-> Data
Access). On the data access layer (DAL), I have factories that creates
the business objects. I have been researching and reading, the
literature seem to support passing in Connection objects into the DAL
from the business layer (BL); the idea is that the BL knows the
environment in which it is operating (i.e. Tomcat or stand alone).
My question is then, when I pass a Connection into the DAL from the BL,
how do I manage the opening and closing of the Connection? It is best
to open/close the Connection object in the same method, however, with
the advise that I pass in a Connection to the DAL, would I close it in
the DAL or BL?
If I pass in a DataSource into the DAL, now I shift the responsibility
of catching/throwing exceptions to the DAL, and I am not sure if this
is the least risky approach.
Access). On the data access layer (DAL), I have factories that creates
the business objects. I have been researching and reading, the
literature seem to support passing in Connection objects into the DAL
from the business layer (BL); the idea is that the BL knows the
environment in which it is operating (i.e. Tomcat or stand alone).
My question is then, when I pass a Connection into the DAL from the BL,
how do I manage the opening and closing of the Connection? It is best
to open/close the Connection object in the same method, however, with
the advise that I pass in a Connection to the DAL, would I close it in
the DAL or BL?
If I pass in a DataSource into the DAL, now I shift the responsibility
of catching/throwing exceptions to the DAL, and I am not sure if this
is the least risky approach.