- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我使用 here 中的说明创建了一个示例 Oracle 12c PDB(可插拔数据库) 。如何使用 Hibernate 应用程序连接到这个可插拔数据库?我正在使用 here 中的示例 Hibernate 应用程序
我更改了 hibernate.cfg.xml 文件,如下所示:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="connection.url">jdbc:oracle:thin:@localhost:1521:sys</property>
<property name="connection.username">sys as sysdba</property>
<property name="connection.password">helloWORLD12</property>
<property name="connection.driver_class">oracle.jdbc.OracleDriver</property>
<property name="dialect">org.hibernate.dialect.Oracle12cDialect</property>
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<property name="hbm2ddl.auto">create</property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<property name="current_session_context_class">thread</property>
<mapping class="net.codejava.hibernate.Book" />
</session-factory>
</hibernate-configuration>
但是当我运行程序时,我收到以下错误跟踪:
Exception in thread "main" org.hibernate.HibernateException: Error accessing stax stream
at org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor.unmarshal(JaxbCfgProcessor.java:107)
at org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor.unmarshal(JaxbCfgProcessor.java:65)
at org.hibernate.boot.cfgxml.internal.ConfigLoader.loadConfigXmlResource(ConfigLoader.java:57)
at org.hibernate.boot.registry.StandardServiceRegistryBuilder.configure(StandardServiceRegistryBuilder.java:163)
at net.codejava.hibernate.BookManager.setup(BookManager.java:23)
at net.codejava.hibernate.BookManager.main(BookManager.java:100)
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[18,6]
Message: The processing instruction target matching "[xX][mM][lL]" is not allowed.
at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(XMLStreamReaderImpl.java:604)
at com.sun.xml.internal.stream.XMLEventReaderImpl.peek(XMLEventReaderImpl.java:276)
at org.hibernate.boot.cfgxml.internal.JaxbCfgProcessor.unmarshal(JaxbCfgProcessor.java:103)
... 5 more
请让我知道我哪里出错了。网上几乎没有关于将 Oracle 12c PDB 与 Hibernate 结合使用的资源。
更新 1:我的配置文件中有一行额外的 XML 代码,这会导致 XML 解析错误。现在 - 如何将 CDB/PDB 与特定用户帐户关联,因为不建议通过 SYS 用户使用 PDB。
我有一个名为“pdb1”的 PDB,它与 sys 用户帐户关联。它存储在以下位置:
D:\app\myusername\virtual\oradata\orcl\pdb1
我创建了一个新用户“c##test”,然后使用以下命令在登录用户“c##test”时创建了一个 pdb:
create pluggable database pdb3 admin user pdb_admin3 identified by helloWORLD12
file_name_convert=('D:\app\myusername\virtual\oradata\orcl\pdbseed\',
'D:\app\myusername\virtual\oradata\test\pdb3\');
“pdb3”已成功创建,但未与用户“c##test”关联。
我现在得到的错误跟踪如下:https://pastebin.com/skVMLkqT
最佳答案
问题出在您使用的语法上。您正在使用 :SID 而不是/SERVICE_NAME ,因此请确保将此行更改为:
<property name="connection.url">jdbc:oracle:thin:@localhost:1521/sys</property>
要查看哪些服务可用,请执行lsnrctl service
。
<小时/>Please also note that you are trying to use sys account which is a the same as root. to avoid future problems, it's best practice to create a new account an use that instead.
根据您的堆栈跟踪,您错过了 oracle 驱动程序依赖项:
ClassNotFoundException: Could not load requested class : oracle.jdbc.OracleDriver
您应该将此依赖项添加到您的 pom.xml
文件中,请执行以下步骤:
https://www.oracle.com/technetwork/database/features/jdbc/jdbc-ucp-122-3110062.html
指定您的路径,而不是Path/to/your/
mvn install:install-file -Dfile={Path/to/your/ojdbc8.jar} DgroupId=com.oracle -DartifactId=ojdbc8 -Dversion=12.2.0.1 -Dpackaging=jar
3-向Pom.xml添加依赖
<!-- ORACLE database driver -->
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc8</artifactId>
<version>12.2.0.1</version>
</dependency>
关于java - 如何使用 Hibernate 连接到 Oracle 12c PDB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52269157/
我正在启动一个 web api 项目,当我尝试在逻辑层(这是一个单独的 csproj)中设置断点时我注意到了这个问题,它显示了未经验证的断点。 深入研究后,我发现调试控制台显示“无法找到或打开 PDB
我已经下载了 FreeImage 源代码并自己为 X64 MT DLL 进行了静态构建。 一切正常,除了当我在 freeimage.lib 文件中使用链接时,我收到很多烦人的链接器警告,我不太了解原因
Ubuntu 16.04 Python 3.5.2 如果我运行 python,在 virtualenv 中,我会得到 Python 3.5.2。 问题是: (photoarchive) admin@s
在 pdb 模式下,我经常想单步执行一个函数。这是一个说明我可能会做什么的情况。给定代码: def f(x): print('doing important stuff..') res
我有父进程调用它的子进程。我把 import pdb; pdb.set_trace() 进入子进程代码。 当我使用 python -m pdb parent.py 启动父级时,它被卡住了。调试器不响应
这个问题在这里已经有了答案: Cannot find or open the PDB file in Visual Studio C++ 2010 (7 个答案) 关闭 8 年前。 我正在使用最近升
我对 python 和 pdb 比较陌生,但我对 gdb 有很多经验。 我的问题是,如果我在某个时候在我的代码中设置了一些断点,我将想要更改某些内容并重新运行我的调试 session ,同时保留这些断
我对编译器和链接器 PDB 文件分别有什么区别感到困惑(即在 Visual Studio 中,Project Properties > C/C++ > Output Files >程序数据库文件名 v
我有一个 PDB 文件列表。我想使用 BioPython 中的 Bio.PDB 模块提取所有文件的配体(因此,杂原子)并将每个单独保存到 PDB 文件中。 我尝试了一些解决方案,例如:Remove h
尝试使用 pdb 调试我的基于 python 的 roguelike。我想弄清楚的是,函数handle_keys()是否像我所问的那样返回0。我有另一个函数没有按预期运行,所以我试图找出问题发生的地方
我有私有(private) pdb 文件,我必须将其转换为公共(public)文件。有工具吗? 最佳答案 使用PDBCopy . pdbcopy 是 Windows 调试工具的一部分,可通过 Wind
在静态编译的链接阶段在 Windows 上构建时可能会出现 LNK4099 警告。 例如使用 nmake 和 VC10 进行构建时,我收到一连串 LNK4099 警告,例如: libcurl_a_de
我的 Visual Studio 2013 ASP.NET webform 应用程序有 3 个 DLL 程序集。调试时,DLL 和 PDB 仅在三个 DLL 中的两个(项目/VB 模块和一个 C# 模
我有一个 Python 程序,里面有一个函数 foo()。 我使用 PDB 运行程序,并在程序中某处的任意断点处停止。 现在,我可以很容易地从 PDB 中调用 foo(),我只需键入: !foo()
我正在尝试使用 this tutorial 学习 pdb引用自 another stackoverflow question ,我正处于“入门”部分的第 3 步。 In [12]: %paste #
我有 DLL,并且有用于创建 DLL 的确切源代码。当我们从客户那里获得转储文件时,我希望我们的本地符号服务器能够工作。 (在我们产品的下一个补丁/版本之前无法在客户站点更新 DLL) 最佳答案 这似
这个问题可能真的很愚蠢,但就是这样。以下语句触发特定电子邮件的异常: File "/Users/me/tools/maildir-deduplicate/maildir_deduplicate/m
在从我的旧 XP 移动到新的 vista PC 后,我在 VS2005 中的一个旧项目中收到以下几个警告: UnitTest++.vsnet2005.lib(TestRunner.obj) : 警告
我正在尝试使用 Visual Studio 编译 Qt 4.8.6 项目(我使用的是用于 Qt4.8.6 的 visual studio 插件)。我在调试和 Release模式 (-debug-and
我想用ipdb而不是 pdb与 py.test --pdb选项。这可能吗?如果是这样,如何? 显然,我可以使用 import ipdb; ipdb.set_trace()在代码中但需要运行测试,观察它
我是一名优秀的程序员,十分优秀!