1.修改Tomcat的context.xml文件
<Context reloadable="true">
<Resource name="jdbc/oracle" auth="Container"
type="javax.sql.DataSource" maxActive="100"
maxIdle="30" maxWait="10000" username="scott"
password="tiger" deiverClassName="oracle.jdbc.Oracle.Driver"
url="jdbc:oracle:thin:@localhost:1521:test"/>
<Resource name="jdbc/mysal" auth="Container"
type="javax.sql.DataSource" maxActive="100"
maxIdle="30" maxWait="10000" username="root"
password="mysqladmin" deiverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost/test"/>
</Context>
2.修改hibernate.cfg.xml配置文件
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.datasource">java:comp/env/jdbc/oracle</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.Oracle9iDialect</property>
<!-- Enable Hibernate's current session context -->
<property name="current_session_context_class">org.hibernate.context.ManagedSessionContext</property>
<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>
<!-- Drop and re-create the database schema on startup -->
<property name="hbm2ddl.auto">create</property>
<mapping resource="org/hibernate/tutorial/domain/Person.hbm.xml"/>
</session-factory>
</hibernate-configuration>
本文介绍如何在Tomcat中配置数据库连接池,并通过Hibernate进行Oracle数据库的映射配置。主要涉及context.xml和hibernate.cfg.xml两个文件的修改。
376

被折叠的 条评论
为什么被折叠?



