当前位置: 代码迷 >> J2EE >> JNDI连接不到数据源实例?该怎么解决
  详细解决方案

JNDI连接不到数据源实例?该怎么解决

热度:46   发布时间:2016-04-22 01:57:52.0
JNDI连接不到数据源实例?
main net.sf.hibernate.connection.DatasourceConnectionProvider -[FATAL] -Could not find datasource: java:comp/env/jdbc/sysuser
javax.naming.NamingException: Cannot create resource instance

这是我hibernate中的部分配置:
<session-factory>
<property name="hibernate.jdbc.batch_size">5</property>
<property name="connection.datasource">java:comp/env/jdbc/sysuser</property>
<property name="testConnectionOnCheckin">true</property>
  <property name="idleConnectionTestPeriod">60</property>
这是TOMCAT中的配置conf>localhost:
<?xml version="1.0" encoding="utf-8" ?>
<Context docBase="F:\TechMonProject\WebRoot" path="/TechMonProject" debug="0" privileged="true">
 <Resource name="jdbc/sysuser" auth="Container" type="com.mchange.v2.c3p0.ComboPooledDataSource"/>
  <ResourceParams name="jdbc/sysuser">
  <parameter>
  <name>factory</name>
  <value>org.apache.naming.factory.BeanFactory</value>
  </parameter>
  <!-- C3P0 database connection settings -->
  <parameter>
  <name>driverClass</name>
  <value>oracle.jdbc.driver.OracleDriver</value>
  </parameter>
  <parameter>
  <name>jdbcUrl</name>
<value>jdbc:oracle:thin:@localhost:1521:yy</value>
  </parameter>
  <parameter>
  <name>user</name>
<value>sysuser</value>
  </parameter>
  <parameter>
  <name>password</name>
  <value>itsm0718</value>
  </parameter>
  <!-- DBCP connection pooling options -->
  <parameter>
  <name>minPoolSize</name>
  <value>5</value>
  </parameter>
  <parameter>
  <name>maxPoolSize</name>
  <value>40</value>
  </parameter>
  <parameter>
  <name>acquireIncrement</name>
  <value>2</value>
  </parameter>
  </ResourceParams>

 <Resource name="jdbc/msuser" auth="Container" type="com.mchange.v2.c3p0.ComboPooledDataSource"/>
  <ResourceParams name="jdbc/msuser">
  <parameter>
  <name>factory</name>
  <value>org.apache.naming.factory.BeanFactory</value>
  </parameter>
  <parameter>
  <name>driverClass</name>
  <value>oracle.jdbc.driver.OracleDriver</value>
  </parameter>
  <parameter>
  <name>jdbcUrl</name>
  <value>jdbc:oracle:thin:@localhost:1521:yy</value>
  </parameter>
  <parameter>
  <name>user</name>
  <value>msuser</value>
  </parameter>
  <parameter>
  <name>password</name>
  <value>itsm0718</value>
  </parameter>
  <parameter>
  <name>minPoolSize</name>
  <value>1</value>
  </parameter>
  <parameter>
  <name>maxPoolSize</name>
  <value>10</value>
  相关解决方案