2011-01-22 110 views
0

我收到此錯誤。請幫幫我。無法打開Hibernate Session進行交易

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

Hibernate沒有任何問題。您的連接設置不正確。 (我看到nullpointer同時獲取協議和網址作爲根本原因)。粘貼您的連接配置。 (爲什麼這是在jndi下?是否從服務器數據源獲得連接) – 2011-01-22 08:10:14

回答

0

我最近遇到這個問題。我發現,由於從應用程序到數據庫的連接丟失,此錯誤彈出。在DB處於脫機狀態時可能會執行一些操作。

請檢查您的連接相關參數。

希望這會有所幫助。

相關問題