hibernate配置jndi的问题

06-05-26 cqyaoran
我在tomcat里配好了jndi,测试了一下,没有问题,但我用在hibernet里时就报错.

13:10:39,484 INFO DatasourceConnectionProvider:51 - Using datasource: java:comp/env/jdbc/TestDB

13:10:39,500 WARN SettingsFactory:103 - Could not obtain connection metadata

org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'

at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:780)

at org.apache.commons.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)

at org.hibernate.connection.DatasourceConnectionProvider.getConnection(DatasourceConnectionProvider.java:59)

at org.hibernate.cfg.SettingsFactory.buildSettings(SettingsFactory.java:72)

at org.hibernate.cfg.Configuration.buildSettings(Configuration.java:1463)

at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1004)

at com.lib.ygt.basic.HibernateUtil.<clinit>(HibernateUtil.java:18)

at com.lib.ygt.userlogininfo.CheckUpUserLoginInfo.findUserCLoginid(CheckUpUserLoginInfo.java:33)

at com.lib.ygt.userlogininfo.UserLoginInfo.CheckUpUserLoginInfo(UserLoginInfo.java:38)

at com.lib.ygt.userlogininfo.servlet.UserLoginInfoServlet.service(UserLoginInfoServlet.java:32)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)

at com.lib.ygt.util.EncodingFilter.doFilter(EncodingFilter.java:23)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)

at com.lib.ygt.util.PowerFilter.doFilter(PowerFilter.java:56)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)

at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)

at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)

at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)

at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)

at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)

at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)

at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)

at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)

at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)

at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)

at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)

at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)

at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)

at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)

at java.lang.Thread.run(Unknown Source)

Caused by: java.sql.SQLException: No suitable driver

at java.sql.DriverManager.getDriver(Unknown Source)

at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:773)

... 40 more

13:10:39,578 INFO Dialect:92 - Using dialect: org.hibernate.dialect.Oracle9Dialect

hibernate.cfg.xml里的配置是这样的:

<!DOCTYPE hibernate-configuration PUBLIC

"-//Hibernate/Hibernate Configuration DTD 3.0//EN"

"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>

<!--<session-factory name="java:hibernate/SessionFactory">-->

<session-factory>

<property name="show_sql">true</property>

<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>

<property name="connection.datasource">java:comp/env/jdbc/TestDB</property>

<mapping resource="com/lib/ygt/database/TGwSmj.hbm.xml"/>

</session-factory>

</hibernate-configuration>

报错信息说的是驱动有问题,我查了一下应该没有问题.请大侠帮帮我

cqyaoran
2006-05-26 13:50
<session-factory>
   
		<property name="show_sql">true</property>
		<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
		<property name="connection.datasource">java:comp/env/jdbc/TestDB</property>
<mapping resource="com/lib/ygt/database/TTempZf.hbm.xml"/>
		
	</session-factory>

cqyaoran
2006-05-26 13:53
上面是hibernate.cfg.xml的配置信息

我用的是jsp+servlet+bean+hibernate结构

猜你喜欢