In a Session Bean, is opening database connection through resource reference the only way to go? I find it very hard. Are there alternatives?

Bozidar Dangubic

It is not very hard to use resource reference.
Just declare the resource reference in your ejb-jar.xml file and you are ready to go.

The alternative would be to package the JDBC driver that is required to connect to the database inside your jar file along with the Session EJB and then to load the driver and get a connection from the DriverManager.
This is really not a way to go. There is nothing in the spec that will prohibit this kind of programming but it is really a horrible way of doing things.
In addition, it is much harder than it would be to simply create a resource reference to your data source and get a connection that way.

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact