框架技术--hibernate jpa异常(Exception Description: Unable to acquire a connection from driver [null], use)

本文主要是介绍框架技术--hibernate jpa异常(Exception Description: Unable to acquire a connection from driver [null], use),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

使用hibernate JPA在本地部署调试都没有问题,但是打成war包,放到服务后,就会抛出异常。

[#|2013-12-11T12:28:23.947+0800|SEVERE|glassfish3.1.2|javax.enterprise.system.std.com.sun.enterprise.server.logging|_ThreadID=25;_ThreadName=Thread-2;|javax.persistence.PersistenceException: Exception [EclipseLink-4021] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DatabaseException
Exception Description: Unable to acquire a connection from driver [null], user [null] and URL [null].  Verify that you have set the expected driver class and URL.  
Check your login, persistence.xml or sessions.xml resource.  
The jdbc.driver property should be set to a class that is compatible with your database platformat org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:517)at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.getDatabaseSession(EntityManagerFactoryDelegate.java:188)at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:277)at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:294)at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:272)at com.haierpip.dao.impl.AdvDaoImpl.getAdvInfo(AdvDaoImpl.java:132)at com.haierpip.util.AdvUtil.advStrategy(AdvUtil.java:68)at com.haierpip.servlet.LiveEpgServlet.doPost(LiveEpgServlet.java:131)at com.haierpip.servlet.LiveEpgServlet.doGet(LiveEpgServlet.java:63)at javax.servlet.http.HttpServlet.service(HttpServlet.java:668)at javax.servlet.http.HttpServlet.service(HttpServlet.java:770)at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1550)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:343)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)at com.haierpip.util.visitRecord.AccessFilter.doFilter(AccessFilter.java:23)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:256)at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:217)at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:279)at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:161)at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:331)at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)at com.sun.enterprise.v3.services.impl.ContainerMapper$AdapterCallable.call(ContainerMapper.java:317)at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:195)at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:860)at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:757)at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1056)at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:229)at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)at com.sun.grizzly.ContextTask.run(ContextTask.java:71)at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)at java.lang.Thread.run(Thread.java:662)
Caused by: Exception [EclipseLink-4021] (Eclipse Persistence Services - 2.3.2.v20111125-r10461): org.eclipse.persistence.exceptions.DatabaseException
Exception Description: Unable to acquire a connection from driver [null], user [null] and URL [null].  Verify that you have set the expected driver class and URL.  Check your login, persistence.xml or sessions.xml resource.  The jdbc.driver property should be set to a class that is compatible with your database platformat org.eclipse.persistence.exceptions.DatabaseException.unableToAcquireConnectionFromDriverException(DatabaseException.java:376)at org.eclipse.persistence.sessions.DefaultConnector.connect(DefaultConnector.java:91)at org.eclipse.persistence.sessions.DatasourceLogin.connectToDatasource(DatasourceLogin.java:162)at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.loginAndDetectDatasource(DatabaseSessionImpl.java:584)at org.eclipse.persistence.internal.jpa.EntityManagerFactoryProvider.login(EntityManagerFactoryProvider.java:206)at org.eclipse.persistence.internal.jpa.EntityManagerSetupImpl.deploy(EntityManagerSetupImpl.java:488)... 39 more
|#]

经一番搜索,找到点有用的资料: http://www.coderanch.com/t/502791/ORM/databases/exception-JPA-application


修改persistence.xmll配置文件中连接数据库参数即可使用:

<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost/experiments"/> 
<property name="javax.persistence.jdbc.user" value="root"/> 
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver"/> 
<property name="javax.persistence.jdbc.password" value=""/> 
<property name="eclipelink.ddl-generation" value="create-tables"/> 
<property name="eclipelink.jdbc.connections.min" value="1"/> 
<property name="eclipelink.jdbc.connections.max" value="2"/> 
<property name="eclipelink.logging.level" value="FINEST"/>

至于原因还需要查找。


这篇关于框架技术--hibernate jpa异常(Exception Description: Unable to acquire a connection from driver [null], use)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1001640

相关文章

Java利用JSONPath操作JSON数据的技术指南

《Java利用JSONPath操作JSON数据的技术指南》JSONPath是一种强大的工具,用于查询和操作JSON数据,类似于SQL的语法,它为处理复杂的JSON数据结构提供了简单且高效... 目录1、简述2、什么是 jsONPath?3、Java 示例3.1 基本查询3.2 过滤查询3.3 递归搜索3.4

Python中随机休眠技术原理与应用详解

《Python中随机休眠技术原理与应用详解》在编程中,让程序暂停执行特定时间是常见需求,当需要引入不确定性时,随机休眠就成为关键技巧,下面我们就来看看Python中随机休眠技术的具体实现与应用吧... 目录引言一、实现原理与基础方法1.1 核心函数解析1.2 基础实现模板1.3 整数版实现二、典型应用场景2

Java异常架构Exception(异常)详解

《Java异常架构Exception(异常)详解》:本文主要介绍Java异常架构Exception(异常),具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录1. Exception 类的概述Exception的分类2. 受检异常(Checked Exception)

Python Dash框架在数据可视化仪表板中的应用与实践记录

《PythonDash框架在数据可视化仪表板中的应用与实践记录》Python的PlotlyDash库提供了一种简便且强大的方式来构建和展示互动式数据仪表板,本篇文章将深入探讨如何使用Dash设计一... 目录python Dash框架在数据可视化仪表板中的应用与实践1. 什么是Plotly Dash?1.1

基于Flask框架添加多个AI模型的API并进行交互

《基于Flask框架添加多个AI模型的API并进行交互》:本文主要介绍如何基于Flask框架开发AI模型API管理系统,允许用户添加、删除不同AI模型的API密钥,感兴趣的可以了解下... 目录1. 概述2. 后端代码说明2.1 依赖库导入2.2 应用初始化2.3 API 存储字典2.4 路由函数2.5 应

Python GUI框架中的PyQt详解

《PythonGUI框架中的PyQt详解》PyQt是Python语言中最强大且广泛应用的GUI框架之一,基于Qt库的Python绑定实现,本文将深入解析PyQt的核心模块,并通过代码示例展示其应用场... 目录一、PyQt核心模块概览二、核心模块详解与示例1. QtCore - 核心基础模块2. QtWid

Java报NoClassDefFoundError异常的原因及解决

《Java报NoClassDefFoundError异常的原因及解决》在Java开发过程中,java.lang.NoClassDefFoundError是一个令人头疼的运行时错误,本文将深入探讨这一问... 目录一、问题分析二、报错原因三、解决思路四、常见场景及原因五、深入解决思路六、预http://www

一文带你深入了解Python中的GeneratorExit异常处理

《一文带你深入了解Python中的GeneratorExit异常处理》GeneratorExit是Python内置的异常,当生成器或协程被强制关闭时,Python解释器会向其发送这个异常,下面我们来看... 目录GeneratorExit:协程世界的死亡通知书什么是GeneratorExit实际中的问题案例

最新Spring Security实战教程之Spring Security安全框架指南

《最新SpringSecurity实战教程之SpringSecurity安全框架指南》SpringSecurity是Spring生态系统中的核心组件,提供认证、授权和防护机制,以保护应用免受各种安... 目录前言什么是Spring Security?同类框架对比Spring Security典型应用场景传统

Java捕获ThreadPoolExecutor内部线程异常的四种方法

《Java捕获ThreadPoolExecutor内部线程异常的四种方法》这篇文章主要为大家详细介绍了Java捕获ThreadPoolExecutor内部线程异常的四种方法,文中的示例代码讲解详细,感... 目录方案 1方案 2方案 3方案 4结论方案 1使用 execute + try-catch 记录