Quinger 2 de mar. de 2008
andrefariagomes 2 de mar. de 2008
Cara, eu recomendaria que você deixasse o pool de conexões a cargo do tomcat:
No arquivo server.xml do tomcat:
<Resource name=“jdbc/myoracle” auth=“Container”
type=“javax.sql.DataSource” driverClassName=“oracle.jdbc.OracleDriver”
url=“jdbc:oracle:thin:@127.0.0.1 :1521:mysid”
username=“scott” password=“tiger” maxActive=“20” maxIdle=“10”
maxWait="-1"/>
No seu web.xml
<resource-ref>
<description>Oracle Datasource example</description>
<res-ref-name>jdbc/myoracle</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
Para obter o datasource :
Context initContext = new InitialContext ();
Context envContext = ( Context ) initContext . lookup ( “ java :/ comp / env ” );
DataSource ds = ( DataSource ) envContext . lookup ( “ jdbc / myoracle ” );
Connection conn = ds . getConnection ();
// etc .
no spring (datasource)
<bean id= “dataSource”
class= “org.springframework.jndi.JndiObjectFactoryBean” >
<property name= “jndiName” >
<value> java:comp/env/jdbc/myoracle</value>
</property>
</bean>
no spring (hibernate)
<bean id= “sessionFactory”
class= “org.springframework.orm.hibernate.
LocalSessionFactoryBean” >
<property name= “dataSource” ><ref bean= “dataSource”/ ></property>
<property name= “hibernateProperties” >
<props>
<prop key= “hibernate.dialect” >
…
</prop>
<prop key= “hibernate.hbm2ddl.auto” > update</prop>
</props>
</property>
</bean>
Espero ter ajudado no que precisava…
Qualquer dúvida estamos aí…
Mais informações:
http://tomcat.apache.org/tomcat-6.0-doc/jndi-datasource-examples-howto.html
http://www.javafree.org/content/view.jf?idContent=46
Since the first version of this article was published in October, 2003, the Spring Framework has steadily grown in popularity. It has progressed through version 1.0 final to the present 1.2, and has been adopted in a wide range of industries and...
Javabuntu 2 de mar. de 2008
vlw a todos isso que eu precisava…