I would like to know if a session bean can access the database via JDBC. If so, how do I get the connection?
Thanks
-
Session Bean accessing JDBC (6 messages)
- Posted by: D HRS
- Posted on: December 06 2004 05:15 EST
Threaded Messages (6)
- Session Bean accessing JDBC by Martin Straus on December 06 2004 10:22 EST
- Data Access Objects by PJ Murray on December 09 2004 06:32 EST
- Session Bean accessing JDBC by Viswa mohan on December 06 2004 11:53 EST
- Session Bean accessing JDBC by Martin Straus on December 06 2004 14:55 EST
-
Session Bean accessing JDBC by David Wolf on December 08 2004 02:07 EST
- DAO as SLSBs by Lorrettus Mathews on December 21 2004 04:18 EST
-
Session Bean accessing JDBC by David Wolf on December 08 2004 02:07 EST
- Session Bean accessing JDBC by Martin Straus on December 06 2004 14:55 EST
-
Session Bean accessing JDBC[ Go to top ]
- Posted by: Martin Straus
- Posted on: December 06 2004 10:22 EST
- in response to D HRS
Yes, a session EJB can access a database through JDBC.
The usual way to implement this is using a DataSource, in order to delegate pool management and etcetera to the apps server.
How to configure a DataSource, depends on your app server. In Weblogic you must define connection pools and DataSources using them. In JBoss you must write a descriptor and deploy it the same way you deploy an EAR.
Hope it helps.
Regards,
Martin -
Data Access Objects[ Go to top ]
- Posted by: PJ Murray
- Posted on: December 09 2004 06:32 EST
- in response to Martin Straus
I think you should look at the Data Access Object Core J2EE Pattern
Background information is here:
http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html
http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html
When you're ready to start producing DAO code, you might prefer to generate it rather than write by hand.
FireStorm/DAO Java code generator imports database schema definitions from from live databases via JDBC and then generates a complete persistence tier based on the Data Access Object design pattern
http://www.codefutures.com/dao/
PJ Murray
CodeFutures - Java Code Generation
http://www.codefutures.com -
Session Bean accessing JDBC[ Go to top ]
- Posted by: Viswa mohan
- Posted on: December 06 2004 11:53 EST
- in response to D HRS
A session bean can access database via JDBC,but it is better not to include the data access code in SessionBean.
It can be implemented in other data access objects.This way your session bean remains independent of data access mechanism. -
Session Bean accessing JDBC[ Go to top ]
- Posted by: Martin Straus
- Posted on: December 06 2004 14:55 EST
- in response to Viswa mohan
Agree... missed that one ;)
It's a usual solution we know as "Data Access Object" (aka DAO)
Regards,
Martin -
Session Bean accessing JDBC[ Go to top ]
- Posted by: David Wolf
- Posted on: December 08 2004 14:07 EST
- in response to Martin Straus
There is no reason your logical DAO cant be a Stateless Session Bean. At least you get the instance pooling advantage.
Of course logically you want to seperate data access from business rules, but dont confuse logical design with physical implementation.
Dave Wolf
Cynergy Systems
Cynergy Systems -
DAO as SLSBs[ Go to top ]
- Posted by: Lorrettus Mathews
- Posted on: December 21 2004 16:18 EST
- in response to David Wolf
There is no reason your logical DAO cant be a Stateless Session Bean. At least you get the instance pooling advantage.Of course logically you want to seperate data access from business rules, but dont confuse logical design with physical implementation.Dave WolfCynergy SystemsCynergy Systems
It will be interesting to hear from architects who have taken this route. Does the instance pooling offer much of a help in case of DAOs, quantitatively speaking. Would the Romans, Johnsons, Tates, Fowlers and Sumitros approve of this approach?