Loading [MathJax]/jax/output/CommonHTML/config.js
首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >Eclipselink忽略persistence.xml中的javax.persistence.jdbc.driver和javax.persistence.jdbc.url属性

Eclipselink忽略persistence.xml中的javax.persistence.jdbc.driver和javax.persistence.jdbc.url属性
EN

Stack Overflow用户
提问于 2018-12-21 17:32:37
回答 1查看 641关注 0票数 0

实际上,我正在将我们应用程序的所有组件更新到最新版本。因此,在其他方面,我将从eclipselink-2.5.0升级到eclipselink-2.7.3,并从Tomcat7升级到TomEE。

我的持久化单元给我带来了麻烦。它只是忽略javax.persistence.jdbc.driverjavax.persistence.jdbc.url,并以某种方式检测到HSQLPlatform数据库,而不是我的MySQL数据库。

这是我的persistence.xml:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
<persistence
  version='2.0'
  xmlns='http://java.sun.com/xml/ns/persistence'
  xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
  xsi:schemaLocation='http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd'>

  <persistence-unit name="DEV" transaction-type="RESOURCE_LOCAL">
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    <exclude-unlisted-classes>false</exclude-unlisted-classes>
    <properties>
      <property name='javax.persistence.jdbc.driver' value='com.mysql.jdbc.Driver' />      
      <property name='javax.persistence.jdbc.url' value='jdbc:mysql://xxxx.xxx.xxxx.xx.xx/xxxxx' />
      <property name='javax.persistence.jdbc.user' value='xxxxxx' />
      <property name='javax.persistence.jdbc.password' value='xxxxxx' />

      <!--  Optimization #14 - avoid auto flush cost on query execution -->
      <property name="eclipselink.persistence-context.flush-mode" value="commit" />
      <property name="eclipselink.cache.shared.default" value="false"/>

      <property name="eclipselink.logging.level" value="FINEST"/>

      <property name="eclipselink.connection-pool.default.initial" value="1" />
      <property name="eclipselink.connection-pool.node2.min" value="16"/>
      <property name="eclipselink.connection-pool.node2.max" value="16"/>
      <property name="eclipselink.connection-pool.node2.wait" value="300"/>
    </properties>
  </persistence-unit>

  ...

下面是相关的日志输出:

代码语言:javascript
代码运行次数:0
运行
AI代码解释
复制
[EL Finest]: 2018-12-21 11:49:35.543--ServerSession(774689836)--Thread(Thread[main,5,main])--Begin deploying Persistence Unit DEV; session /file:/C:/Java Workspace Photon/.metadata/.plugins/org.eclipse.wst.server.core/tmp1/wtpwebapps/PES/WEB-INF/classes/_DEV; state Predeployed; factoryCount 2
[EL Finest]: 2018-12-21 11:49:35.588--ServerSession(774689836)--Thread(Thread[main,5,main])--property=eclipselink.target-server; value=org.apache.openejb.jpa.integration.eclipselink.OpenEJBServerPlatform
[EL Finest]: 2018-12-21 11:49:35.588--ServerSession(774689836)--Thread(Thread[main,5,main])--property=eclipselink.logging.level; value=FINEST; translated value=FINEST
[EL Finest]: 2018-12-21 11:49:35.588--ServerSession(774689836)--Thread(Thread[main,5,main])--property=eclipselink.logging.level; value=FINEST; translated value=FINEST
[EL Finest]: 2018-12-21 11:49:35.591--ServerSession(774689836)--Thread(Thread[main,5,main])--property=javax.persistence.jdbc.user; value=xxxxxx
[EL Finest]: 2018-12-21 11:49:35.591--ServerSession(774689836)--Thread(Thread[main,5,main])--property=javax.persistence.jdbc.password; value=xxxxxx
[EL Finest]: 2018-12-21 11:49:35.618--ServerSession(774689836)--Thread(Thread[main,5,main])--property=eclipselink.connection-pool.default.initial; value=1
[EL Finest]: 2018-12-21 11:49:35.618--ServerSession(774689836)--Thread(Thread[main,5,main])--property=eclipselink.connection-pool.node2.wait; value=300
[EL Finest]: 2018-12-21 11:49:35.618--ServerSession(774689836)--Thread(Thread[main,5,main])--property=eclipselink.connection-pool.node2.min; value=16
[EL Finest]: 2018-12-21 11:49:35.618--ServerSession(774689836)--Thread(Thread[main,5,main])--property=eclipselink.connection-pool.node2.max; value=16
[EL Finest]: 2018-12-21 11:49:35.618--ServerSession(774689836)--Thread(Thread[main,5,main])--property=eclipselink.cache.shared.default; value=false; translated value=false
[EL Info]: 2018-12-21 11:49:35.64--ServerSession(774689836)--Thread(Thread[main,5,main])--EclipseLink, version: Eclipse Persistence Services - 2.7.3.v20180807-4be1041
[EL Finest]: 2018-12-21 11:49:35.656--Thread(Thread[main,5,main])--Database platform: org.eclipse.persistence.platform.database.oracle.Oracle12Platform, regular expression: (?is)oracle.*12.*
[EL Finest]: 2018-12-21 11:49:35.657--Thread(Thread[main,5,main])--Database platform: org.eclipse.persistence.platform.database.oracle.Oracle11Platform, regular expression: (?is)oracle.*11.*
[EL Finest]: 2018-12-21 11:49:35.657--Thread(Thread[main,5,main])--Database platform: org.eclipse.persistence.platform.database.oracle.Oracle10Platform, regular expression: (?is)oracle.*10.*
[EL Finest]: 2018-12-21 11:49:35.657--Thread(Thread[main,5,main])--Database platform: org.eclipse.persistence.platform.database.oracle.Oracle9Platform, regular expression: (?is)oracle.*9.*
[EL Finest]: 2018-12-21 11:49:35.657--Thread(Thread[main,5,main])--Database platform: org.eclipse.persistence.platform.database.Oracle12Platform, regular expression: (?is)core.oracle.*12.*
[EL Finest]: 2018-12-21 11:49:35.657--Thread(Thread[main,5,main])--Database platform: org.eclipse.persistence.platform.database.Oracle11Platform, regular expression: (?is)core.oracle.*11.*
[EL Finest]: 2018-12-21 11:49:35.657--Thread(Thread[main,5,main])--Database platform: org.eclipse.persistence.platform.database.Oracle10Platform, regular expression: (?is)core.oracle.*10.*
[EL Finest]: 2018-12-21 11:49:35.657--Thread(Thread[main,5,main])--Database platform: org.eclipse.persistence.platform.database.Oracle9Platform, regular expression: (?is)core.oracle.*9.*
[EL Finest]: 2018-12-21 11:49:35.657--Thread(Thread[main,5,main])--Database platform: org.eclipse.persistence.platform.database.oracle.OraclePlatform, regular expression: (?is)oracle.*
[EL Finest]: 2018-12-21 11:49:35.657--Thread(Thread[main,5,main])--Database platform: org.eclipse.persistence.platform.database.SQLAnywherePlatform, regular expression: SQL\ Anywhere.*
[EL Finest]: 2018-12-21 11:49:35.657--Thread(Thread[main,5,main])--Database platform: org.eclipse.persistence.platform.database.SybasePlatform, regular expression: (?i)(sybase.*)|(adaptive\ server\ enterprise.*)|(SQL\ Server.*)
[EL Finest]: 2018-12-21 11:49:35.657--Thread(Thread[main,5,main])--Database platform: org.eclipse.persistence.platform.database.SQLServerPlatform, regular expression: (?i)microsoft.*
[EL Finest]: 2018-12-21 11:49:35.657--Thread(Thread[main,5,main])--Database platform: org.eclipse.persistence.platform.database.JavaDBPlatform, regular expression: (?i).*derby.*
[EL Finest]: 2018-12-21 11:49:35.657--Thread(Thread[main,5,main])--Database platform: org.eclipse.persistence.platform.database.DB2ZPlatform, regular expression: (?i).*db2.*dsn.*
[EL Finest]: 2018-12-21 11:49:35.657--Thread(Thread[main,5,main])--Database platform: org.eclipse.persistence.platform.database.DB2MainframePlatform, regular expression: (?i).*(db2|AS).*(AS/400|qsq).*
[EL Finest]: 2018-12-21 11:49:35.657--Thread(Thread[main,5,main])--Database platform: org.eclipse.persistence.platform.database.DB2Platform, regular expression: (?i).*db2.*
[EL Finest]: 2018-12-21 11:49:35.657--Thread(Thread[main,5,main])--Database platform: org.eclipse.persistence.platform.database.PointBasePlatform, regular expression: (?is)pointbase.*
[EL Finest]: 2018-12-21 11:49:35.657--Thread(Thread[main,5,main])--Database platform: org.eclipse.persistence.platform.database.MySQLPlatform, regular expression: (?i)mysql.*
[EL Finest]: 2018-12-21 11:49:35.657--Thread(Thread[main,5,main])--Database platform: org.eclipse.persistence.platform.database.Informix11Platform, regular expression: (?i)(informix.*)|(ids.*)
[EL Finest]: 2018-12-21 11:49:35.657--Thread(Thread[main,5,main])--Database platform: org.eclipse.persistence.platform.database.PostgreSQLPlatform, regular expression: (?is)postgresql.*
[EL Finest]: 2018-12-21 11:49:35.657--Thread(Thread[main,5,main])--Database platform: org.eclipse.persistence.platform.database.H2Platform, regular expression: (?is)h2.*
[EL Finest]: 2018-12-21 11:49:35.657--Thread(Thread[main,5,main])--Database platform: org.eclipse.persistence.platform.database.HSQLPlatform, regular expression: (?is)hsql.*
[EL Fine]: 2018-12-21 11:49:35.657--Thread(Thread[main,5,main])--Detected database platform: org.eclipse.persistence.platform.database.HSQLPlatform
[EL Config]: 2018-12-21 11:49:35.674--ServerSession(774689836)--Connection(1116906950)--Thread(Thread[main,5,main])--connecting(DatabaseLogin(
    platform=>DatabasePlatform
    user name=> "xxxxxx"
    connector=>JNDIConnector datasource name=>null
))
[EL Config]: 2018-12-21 11:49:35.675--ServerSession(774689836)--Connection(1823071136)--Thread(Thread[main,5,main])--Connected: jdbc:hsqldb:file:C:\Java Workspace Photon\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\data\hsqldb\hsqldb
    User: SA
    Database: HSQL Database Engine  Version: 2.3.2
    Driver: HSQL Database Engine Driver  Version: 2.3.2
[EL Finest]: 2018-12-21 11:49:35.675--ServerSession(774689836)--Connection(1785609933)--Thread(Thread[main,5,main])--Connection acquired from connection pool [read].
[EL Finest]: 2018-12-21 11:49:35.675--ServerSession(774689836)--Connection(1785609933)--Thread(Thread[main,5,main])--Connection released to connection pool [read].
[EL Config]: 2018-12-21 11:49:35.675--ServerSession(774689836)--Connection(8105698)--Thread(Thread[main,5,main])--connecting(DatabaseLogin(
    platform=>HSQLPlatform
    user name=> "xxxxxx"
    connector=>JNDIConnector datasource name=>null
))

日志中显示的用户名/密码是正确的,但我不知道它试图连接到哪里。

怎么一回事?

EN

回答 1

Stack Overflow用户

发布于 2018-12-24 05:12:02

TomEE的默认数据源是HSQL DB,它是内存中的DB,在TomEE中可用。您的配置不适用于TomEE。所以TomEE使用默认的HSQL数据源,而不是您的DB.You必须定义数据源属性才能在TomEE中连接您的DB。你可以参考下面的链接。

JPA persistence.xml I want it to connect to MariaDB but it always connects to hsqldb

http://tomee.apache.org/datasource-config.html

http://tomee.apache.org/configuring-datasources-in-tests.html

我希望上面的细节能解决你的问题。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53888766

复制
相关文章
删除列中的 NULL 值
今天接到一个群友的需求,有一张表的数据如图 1,他希望能通过 SQL 查询出图 2 的结果。
白日梦想家
2020/07/20
9.9K0
删除列中的 NULL 值
从DataFrame中删除列
在操作数据的时候,DataFrame对象中删除一个或多个列是常见的操作,并且实现方法较多,然而这中间有很多细节值得关注。
老齐
2021/03/29
7K0
ExcelVBA删除指定列含有指定字符的所在的行
2.用SpecialCells(xlCellTypeConstants, 16)快速定位
哆哆Excel
2023/09/09
1K0
ExcelVBA删除指定列含有指定字符的所在的行
小技巧:R语言里删除带有缺失值的列
如果是要去除包含缺失值的行,直接使用na.omit()函数就可以了,但是如果要去除含有缺失值的列呢?
用户7010445
2021/07/12
8.3K0
小技巧:R语言里删除带有缺失值的列
算法-删除字符串中的公共字符
该文讲述了如何删除字符串中的公共字符,通过创建一个hash表来存储字符串中每个字符的出现次数,然后遍历字符串,将不需要删除的字符保留,需要删除的字符则用另一个数组存储,最后将修改后的字符串全部替换回来。这种方法的时间复杂度为O(n),空间复杂度为O(256)
chaibubble
2018/01/02
3.6K0
算法-删除字符串中的公共字符
在字符串中删除特定的字符
题目:输入两个字符串,从第一字符串中删除第二个字符串中所有的字符。例如,输入”They are students.”和”aeiou”,则删除之后的第一个字符串变成”Thy r stdnts.”。 首先我们考虑如何在字符串中删除一个字符。由于字符串的内存分配方式是连续分配的。我们从字符串当中删除一个字符,需要把后面所有的字符往前移动一个字节的位置。但如果每次删除都需要移动字符串后面的字符的话,对于一个长度为n的字符串而言,删除一个字符的时间复杂度为O(n)。而对于本题而言,有可能要删除的字符的个数是n,因此该
猿人谷
2018/01/17
9K0
如何在docker中删除images
本文由腾讯云+社区自动同步,原文地址 https://stackoverflow.club/90/
羽翰尘
2019/11/20
2.5K0
R语言最优化问题中的共轭函数
在回归模型研究中,我们将讨论优化,而经典工具就是所谓的共轭。给定函数f:Rp→R,其共轭值为函数f ⋆:Rp→R使得
拓端
2021/01/13
7450
如何在Python中删除(删除)文件和目录
本教程说明了如何使用os,pathlib和shutil模块中的功能删除文件和目录。
用户5005176
2021/08/10
13.1K0
如何在序列标注过程中打标?
英文打标,token可以是一个单词(e.g. awesome),也可以是一个字符(e.g. a)。
伊泽瑞尔
2022/06/01
3610
如何在序列标注过程中打标?
Python字符串中删除特定字符的方法
这篇文章主要介绍了Python字符串中删除特定字符的方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧 分析
全栈程序员站长
2022/06/28
6.5K0
Python字符串中删除特定字符的方法
pandas’_pandas 删除列
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
全栈程序员站长
2022/10/02
2.7K0
pandas’_pandas 删除列
Python从字符串中删除字符
Sometimes we want to remove all occurrences of a character from a string. There are two common ways to achieve this.
全栈程序员站长
2022/09/01
5.8K0
如何在 Linux 中强制删除目录?
在Linux系统中,有时候可能会遇到无法正常删除目录的情况,例如目录包含非空文件、没有删除权限等。在这种情况下,我们可以使用一些强制删除的方法来解决问题。本文将详细介绍在Linux中如何强制删除目录的几种常见方法。
网络技术联盟站
2023/06/08
8.7K0
如何在 Linux 中强制删除目录?
对比Excel,Python pandas删除数据框架中的列
删除列也是Excel中的常用操作之一,可以通过功能区或者快捷菜单中的命令或者快捷键来实现。上一篇文章,我们讲解了Python pandas删除数据框架中行的一些方法,删除列与之类似。然而,这里想介绍一些新方法。取决于实际情况,正确地使用一种方法可能比另一种更好。
fanjy
2022/04/13
7.2K0
对比Excel,Python pandas删除数据框架中的列
如何在Linux中删除软链接
符号链接(也称为软链接或符号链接)在 Linux 中是一种特殊类型的文件,可用作另一个文件的快捷方式。 你可以使用 ln 命令创建软链接。但是怎么删除呢? 在 Linux 中没有专门用于删除符号链接的特殊命令。你可以使用 rm 命令,该命令也用于删除文件和目录。 rm symbolic_link_name 你也可以在此处使用取消链接命令。不要用它的名字。它不仅用于删除链接;它也可以删除文件。 unlink symbolic_link_name 使用 rm 命令删除符号链接 你所要做的就是为命令提供链接路
入门笔记
2022/11/14
13.4K1
如何在Linux中删除软链接
如何从 Python 中的字符串列表中删除特殊字符?
在进行字符串处理和文本分析时,有时我们需要从字符串列表中删除特殊字符。特殊字符可能是空格、标点符号、换行符等,在某些情况下它们可能干扰我们的文本处理或分析任务。Python 提供了多种方法来删除字符串列表中的特殊字符。本文将详细介绍在 Python 中删除字符串列表中特殊字符的几种常用方法,并提供示例代码帮助你理解和应用这些方法。
网络技术联盟站
2023/06/01
8.4K0
JAVA - String 中删除指定字符
JAVA老师给我们留了一个课后作业,要求我们通过搜索JDK用尽可能多的方法删除String类中的指定字符,我只想到了 11 种方法,如果有不足或者遗漏希望读者能够不吝赐教。
林老师带你学编程
2019/05/25
4.6K0
点击加载更多

相似问题

plone REST :如何通过在Plone上进行REST调用来操纵plone上的用户?

12

在Plone中搜索用户并显示用户记录

11

在NoSql中插入带日期的生日

118

如何使用php在MySQL中插入出生日期?

20

在Plone中清理用户输入的代码

10
添加站长 进交流群

领取专属 10元无门槛券

AI混元助手 在线答疑

扫码加入开发者社群
关注 腾讯云开发者公众号

洞察 腾讯核心技术

剖析业界实践案例

扫码关注腾讯云开发者公众号
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
查看详情【社区公告】 技术创作特训营有奖征文