Connection pool for Distributed Web modules using Hibernate with C3P0
I have a Web Service (model-layer
) which communicates with Database. This module is responsible of saving and retrieving the data and managing the transaction. Also many BL are defined her. The other isolated web modules use this service to save and retrieve their required data.
Right now the model-layer
is becoming bottle neck. I need to change the architecture.
I want to move the Hibernate Entity classes and BL to their respected web modules. So each web module will communicate to same Database. But I do not want a distributed connection pool and transaction maintained on each module.
I know that there should be a way to use a Single Connection Pool for all the distributed web modules. But I need a professional opinion that how should I do that.
I do not want to use the Spring
framework, which is already been denied solution by the organization.
Right now I am trying find the solution by saving the serialized object of connection on LDAP and all the modules will use that connection pool. And right now I am scratching my head 开发者_JAVA百科wondering if I am going in the right direction.
Please guide me to correct path. If spring is the only option then please advise me that as well. I will try to convince my company.
I guess I have found the Answer.
I have used a shared DataSource (*-ds.xml)
on a single JBoss server.
Datasource file is as follows
<datasources>
<local-tx-datasource>
<jndi-name>jdbc/wc-mysql</jndi-name>
<connection-url>jdbc:mysql://MyPC-IP:3306/DB</connection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>
<user-name>xUser</user-name>
<password>xXxXx</password>
<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.MySQLExceptionSorter</exception-sorter-class-name>
<use-java-context>false</use-java-context>
<metadata>
<type-mapping>mySQL</type-mapping>
</metadata>
</local-tx-datasource>
</datasources>
This DS is available to all the JBoss servers running on different location.
One thing to make sure that <use-java-context>false</use-java-context>
will make the DS publicly available so you need to do the security handshake yourself.
精彩评论