无法打开Hibernate Session进行事务处理

时间:2011-01-22 08:02:36

标签: hibernate jndi

我收到此错误。请帮帮我。

org.springframework.transaction.CannotCreateTransactionException: Could not open Hibernate Session for transaction; nested exception is org.hibernate.exception.GenericJDBCException: Cannot open connection
 org.springframework.orm.hibernate3.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:599)
 org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:374)
 org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:263)
 org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:101)
 org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
 org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
 $Proxy20.findFlierByID(Unknown Source)
 servlets.AwardServlet.doGet(AwardServlet.java:34)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause

org.hibernate.exception.GenericJDBCException: Cannot open connection
 org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:126)
 org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:114)
 org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
 org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:52)
 org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:449)
 org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167)
 org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:142)
 org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:85)
 org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1354)
 org.springframework.orm.hibernate3.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:558)
 org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:374)
 org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:263)
 org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:101)
 org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
 org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
 $Proxy20.findFlierByID(Unknown Source)
 servlets.AwardServlet.doGet(AwardServlet.java:34)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause

org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'
 org.apache.tomcat.dbcp.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1452)
 org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1371)
 org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
 org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.getConnection(LocalDataSourceConnectionProvider.java:82)
 org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446)
 org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167)
 org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:142)
 org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:85)
 org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1354)
 org.springframework.orm.hibernate3.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:558)
 org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:374)
 org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:263)
 org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:101)
 org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
 org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
 $Proxy20.findFlierByID(Unknown Source)
 servlets.AwardServlet.doGet(AwardServlet.java:34)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause

java.lang.NullPointerException
 sun.jdbc.odbc.JdbcOdbcDriver.getProtocol(Unknown Source)
 sun.jdbc.odbc.JdbcOdbcDriver.knownURL(Unknown Source)
 sun.jdbc.odbc.JdbcOdbcDriver.acceptsURL(Unknown Source)
 java.sql.DriverManager.getDriver(Unknown Source)
 org.apache.tomcat.dbcp.dbcp.BasicDataSource.createConnectionFactory(BasicDataSource.java:1437)
 org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:1371)
 org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:1044)
 org.springframework.orm.hibernate3.LocalDataSourceConnectionProvider.getConnection(LocalDataSourceConnectionProvider.java:82)
 org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446)
 org.hibernate.jdbc.ConnectionManager.getConnection(ConnectionManager.java:167)
 org.hibernate.jdbc.JDBCContext.connection(JDBCContext.java:142)
 org.hibernate.transaction.JDBCTransaction.begin(JDBCTransaction.java:85)
 org.hibernate.impl.SessionImpl.beginTransaction(SessionImpl.java:1354)
 org.springframework.orm.hibernate3.HibernateTransactionManager.doBegin(HibernateTransactionManager.java:558)
 org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:374)
 org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:263)
 org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:101)
 org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
 org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
 $Proxy20.findFlierByID(Unknown Source)
 servlets.AwardServlet.doGet(AwardServlet.java:34)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:717)

我在网上看过很多例子,但我无法解决这个问题。所以请帮助我。

1 个答案:

答案 0 :(得分:0)

我最近遇到过这个问题。我发现,由于应用程序连接丢失数据库,弹出此错误。在DB离线时,您可能正在执行某些操作。

请检查您的连接相关参数。

希望这有帮助。