Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Obtain reference of database connection pool within EJB stateless bean for OC4J

Dimitris Karageorgopoulos
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear all,

from an EJB stateless session bean i need to connect to my Oracle database and run a PL/SQL procedure.
For this purpose I need to connect using a connection pool because if I use the data source, my database runs out of resources.
I can get a reference of my data source using the following piece of code:

@Resource(name = "jdbc/SPYROSDS")
private javax.sql.DataSource dataSource;

however I don't know how to get a reference of the relevant connection pool for this data source.

The connection pool is configured in the data-sources.xml file (I use Oracle OC4J as my J2EE container) as displayed below:

<data-sources xmlns:xsi="" xsi:noNamespaceSchemaLocation="">
<connection-pool name="jdev-connection-pool-SPYROS">
<connection-factory factory-class="oracle.jdbc.pool.OracleDataSource" user="SPYROS" password="->DataBase_User_s48G8JcPHAHFJjv-sPnIY3lJSsi10msRK-WGVRiGGcI=" url="jdbcracle:thin:@devl903:1521:ORCLDEV"/>
<managed-data-source name="jdev-connection-managed-SPYROS" jndi-name="jdbc/SPYROSDS" connection-pool-name="jdev-connection-pool-SPYROS"/>
<native-data-source name="jdev-connection-native-SPYROS" jndi-name="jdbc/SPYROSCoreDS" url="jdbcracle:thin:@devl903:1521:ORCLDEV" user="SPYROS" password="->DataBase_User_zYWc7htSe5NdYqHV1xahJqpwrMMrv1jhfJon08ntRCY=" data-source-class="oracle.jdbc.pool.OracleDataSource"/>

however I fail to get a reference of the connection pool programmatically.

Does anybody know how to do it ?

  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic