<!-- A configuração abaixo deve ser adicionada ao context.xml do diretório conf do tomcat! -->
<Resource name="jdbc/testeDB"
auth="Container"
type="javax.sql.DataSource"
maxActive="100"
maxIdle="30"
maxWait="10000"
username="admin"
password="admin"
driverClassName="oracle.jdbc.OracleDriver"
url="jdbc:oracle:thin:@192.168.0.9:1521:XE"
removeAbandoned="true"
removeAbandonedTimeout="60"
logAbandoned="true"/>
OBS: Copiar ojdbc14.jar para o diretório lib do TomCat.
<!-- Adicionar no Web.xml-->
<resource-ref><description>DataSource testeDB</description>
<res-ref-name>jdbc/testeDB</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
<!-- hibernate.cgf.xml -->
<!-- Configuração com Data Source -->
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="hibernate.jdbc.use_streams_for_binary=">true</property>
<property name="hibernate.connection.datasource">java:/comp/env/jdbc/testeDB</property>
<property name="current_session_context_class">thread</property>
<!-- Configuração sem Data Source
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@192.168.0.9:1521:XE</property>
<property name="hibernate.connection.username">admin</property>
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.password">admin</property>
<property name="hibernate.jdbc.use_streams_for_binary=">true</property>
-->
<!-- Pool de Conexões - C3P0
Colocar JARs na pasta lib do TomCat
Não é necessário quando a conexão é feita através de um Data Source. Nesse caso, o poll deve ser configurado no context.xml
<property name="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</property>
<property name="hibernate.org.c3p0.min_size">3</property>
<property name="hibernate.org.c3p0.max_size">30</property>
<property name="hibernate.org.c3p0.timeout">10</property>
<property name="hibernate.org.c3p0.max_statements">0</property>
<property name="hibernate.org.c3p0.idle_test_period">30</property>
<property name="hibernate.org.c3p0.acquire_increment">5</property>
-->
Boa noite Alexandre,
ResponderExcluirComo eu construo uma SessionFactory com o hibernate 4+ utilizando o JNDI Datasource?