...
<resource-ref>
<description>DB Connection</description>
<res-ref-name>jdbc/MaDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
...
META-INF/context.xml : i created this file to declare my datasource for my webapp only
<?xml version="1.0" encoding="ISO-8859-1"?>
<Context
docBase="${catalina.home}/webapps/app"
path="/app"
reloadable="true">
<Resource
name="jdbc/MaDB"
type="javax.sql.DataSource "
auth="Container"
username="admin"
password="pass"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost/databaseName?autoReconnect=true"/>
</Context>
hibernate.cfg.xml:
...
<property name="connection.datasource">java:comp/env/jdbc/MaDB</property>
<property name="dialect"> org.hibernate.dialect.MySQLDialect</property>
<!--### Apache DBCP Connection Pool ###-->
<!--connection pool-->
<property name="hibernate.dbcp.maxActive">10</property>
<property name="hibernate.dbcp.whenExhaustedAction">1</property>
<property name="hibernate.dbcp.maxWait">100</property>
<property name="hibernate.dbcp.maxIdle ">10</property>
...
Partager