• 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

Obtain JDBC Connection in SessionBean using JTA.

 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I have EJB2.1 + JDK5 + J2EE1.4 and weblogic9.2.
I am currently using SessionBeans with hibernate. Hibernate is using JTA transactions � so the database connection is being controlled by application server, this is small example of such session bean:

@Session(ejbName = "AlertService", transactionType = Session.SessionTransactionType.CONTAINER, type = Session.SessionType.STATELESS)
@JndiName(remote = "ejb.AlertServiceRemoteHome")
@FileGeneration(remoteClass = Constants.Bool.TRUE, remoteHome = Constants.Bool.TRUE, localClass = Constants.Bool.FALSE, localHome = Constants.Bool.FALSE)
public class AlertService extends GenericSessionBean implements SessionBean{

@RemoteMethod(transactionAttribute = Constants.TransactionAttribute.REQUIRED)
public String createBookmarkAlert(Object raw_freq, Set output,
String userLogin) {
org.hibernate.Session session = HibernateUtil.getSession();
�.


This solution is great, because the transaction is being controlled on SessioBean level.

Now i need to obtain JDBC connection, that also is being controlled by JTA � so it will automatically start, and rollback for me transactions.

How to do it?

Thanks,
Maciej
 
I just had the craziest dream. This tiny ad was in it.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic