A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
Win a copy of
The Mikado Method
this week in the
Agile and other Processes
forum!
JavaRanch
»
Java Forums
»
Certification
»
EJB Certification (SCBCD/OCPJBCD)
Author
look up datasource from session bean
Anuj Troy
Ranch Hand
Joined: Apr 07, 2005
Posts: 30
posted
Apr 08, 2005 07:59:00
0
hii how can we lookup dataSource(to accessa db connection pool) from a session bean?
regards
anuj
SCJP 1.4, SCWCD 1.4
your eyes cannot see what your mind does not know
Keerthi P
Ranch Hand
Joined: Aug 19, 2003
Posts: 203
posted
Apr 08, 2005 10:47:00
0
Context context = new InitialContext(); Object namedObject = context.lookup("<data-source-jndi-name>"); javax.sql.DataSource dataSource = (javax.sql.DataSource)namedObject; java.sql.Connection con = dataSource.getConnection(); doCRUD(con); // perform any database operations.
Cheers.<br />Keerthi<br />(SCJP, SCWCD, SCBCD)
Anuj Troy
Ranch Hand
Joined: Apr 07, 2005
Posts: 30
posted
Apr 11, 2005 06:09:00
0
hii Keerthi
thanks a lot for the help
i tried it today and it worked.
regards
anuj
I agree. Here's the link:
http://zeroturnaround.com/jrebel/download
subject: look up datasource from session bean
Similar Threads
org.hibernate.exception.GenericJDBCException: Cannot open connection
transaction in Container managed session bean
Transaction EJB session bean
Bean Managed Transactions
02049: timeout: distributed transaction waiting for lock
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter