到TOMCAT安装目录找到/Conf/server.xml文件在你的标签内部加入下面的代码
<
Context
path
=""
docBase
=""
debug ="5" reloadable ="true" >
< WatchedResource > WEB-INF/web.xml </ WatchedResource >
< Resource name ="JNDI/gamvan" auth ="Container" type ="javax.sql.DataSource"
maxActive ="100" maxIdle ="30" maxWait ="10000"
username ="admin" password ="admin" driverClassName ="oracle.jdbc.driver.OracleDriver"
url ="jdbc:oracle:thin:@127.0.0.1:1521:oracle" />
</ Context >
debug ="5" reloadable ="true" >
< WatchedResource > WEB-INF/web.xml </ WatchedResource >
< Resource name ="JNDI/gamvan" auth ="Container" type ="javax.sql.DataSource"
maxActive ="100" maxIdle ="30" maxWait ="10000"
username ="admin" password ="admin" driverClassName ="oracle.jdbc.driver.OracleDriver"
url ="jdbc:oracle:thin:@127.0.0.1:1521:oracle" />
</ Context >
在你的项目的/WEB-INF/ 打开web.xml 在web-app标签内部加上如下代码
<
resource-ref
>
< description > Oracle Datasource example </ description >
< res-ref-name > JNDI/gamvan </ res-ref-name >
< res-type > javax.sql.DataSource </ res-type >
< res-auth > Container </ res-auth >
</ resource-ref >
< description > Oracle Datasource example </ description >
< res-ref-name > JNDI/gamvan </ res-ref-name >
< res-type > javax.sql.DataSource </ res-type >
< res-auth > Container </ res-auth >
</ resource-ref >
配置hibernate的配置文件hibernate.cfg.xml
<!--
Datasource Start
-->
< property name ="connection.datasource" > java:comp/env/JNDI/gamvan </ property >
< property name ="show_sql" > false </ property >
< property name ="dialect" > org.hibernate.dialect.SQLServerDialect </ property >
<!-- Datasource END -->
< property name ="connection.datasource" > java:comp/env/JNDI/gamvan </ property >
< property name ="show_sql" > false </ property >
< property name ="dialect" > org.hibernate.dialect.SQLServerDialect </ property >
<!-- Datasource END -->