- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
实际上我正在尝试进行 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="hbm2ddl.auto">update</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="connection.url">jdbc:mysql://localhost:3306/temp</property>
<property name="connection.username">root</property>
<property name="connection.password">root</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<mapping resource="employee.hbm.xml"/>
</session-factory>
</hibernate-configuration>
这里是异常(exception)...
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" org.hibernate.HibernateException: Could not parse configuration: hibernate.cfg.xml
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1491)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1425)
at com.subhas.mypackage.StoreData.main(StoreData.java:13)
Caused by: org.dom4j.DocumentException: Connection refused: connect Nested exception: Connection refused: connect
at org.dom4j.io.SAXReader.read(SAXReader.java:484)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1481)
... 2 more
这是 employee.hbm.xml
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.subhas.mypackage.Employee" table="emp1000">
<id name="id">
<generator class="assigned"></generator>
</id>
<property name="firstName"></property>
<property name="lastName"></property>
</class>
</hibernate-mapping>
这是我的主课
public class StoreData {
public static void main(String[] args) {
//creating configuration object
Configuration cfg=new Configuration();
cfg.configure("hibernate.cfg.xml");
//creating session factory object
SessionFactory factory=cfg.buildSessionFactory();
//creating session object
Session session=factory.openSession();
//creating transaction object
Transaction transaction=session.beginTransaction();
Employee employee=new Employee();
employee.setId(5000);
employee.setfName("Subhas");
employee.setlName("Gupta");
//persisting the object
session.persist(employee);
//commit the transaction object
transaction.commit();
session.close();
System.out.println("Data Saved Successfully");
}
}
我无法为此找到完美的解决方案。有人可以帮助我吗?谢谢。
最佳答案
尝试将 DOCTYPE 更改为:
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
关于java - 异常 :Could not parse configuration: hibernate. cfg.xml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23681589/
我有一个Java项目,正在使用hibernate。这里的事情是我想将hibernate.cfg.xml文件放在“src”文件夹之外,但是当我配置该文件时,它显示FileNotFoundExceptio
我想了解 #[cfg(test)] 和 #[cfg(feature = "test")] 之间的区别,最好通过示例进行演示。 最佳答案 #[cfg(test)] 标记仅当启用 test 配置选项时才编
如果我启动 cppcheck,我会收到以下错误: cppcheckListLib.c(信息)无法加载 std.cfg。您的 Cppcheck 安装已损坏,请重新安装。 Cppcheck 二进制文件是在
我想了解 #[cfg(test)] 和 #[cfg(feature = "test")] 之间的区别,最好通过示例进行演示。 最佳答案 #[cfg(test)] 标记仅当启用 test 配置选项时才编
当我来的时候,我正在寻找一个很好的解决方法来保持我的 .tmux.conf 文件在系统之间保持一致(我有 OS X 和 Ubuntu,它们有不同的复制/粘贴支持技术)在这条提供解决方案的评论中:htt
所以我有这个主 package Hibernate; import java.util.List; import org.hibernate.Session; import org.hibernate
我的项目根文件夹中有hibernate.cfg.xml文件。 如果我运行的应用程序包含: SessionFactory sessionFactory = new Configuration().con
我收到上述错误。我的 Web 应用程序中已有 xml 文件 hibernate.cfg.xml。除此之外,我在 WebINF lib 文件夹下有 hibernate 所需的完整 jar 文件。 这是完
我在 IntelliJ IDE 中的 hibernate.cfg.xml 有问题。 这是我的 hibernate 配置文件: org.postgresql
我正在尝试使用 pgadmin3 连接到 ubuntu 中的 Postgresql9.1。我的 Pgadmin3 GUI 工具没有提供任何通过右键单击数据库来创建表的选项,但它在我看到的一些视频中可用
您好,我的项目 CFG 文件中的路径列表太长,我如何定义像 $(BDS) 这样的路径快捷方式谢谢 最佳答案 “选项”对话框 ->“环境选项”->“环境变量”。该页面有一个“用户覆盖”部分。这就是您定义
对于 LR 解析器,FIRST 集定义如下 ( source ): FIRST(A) is the set of terminals which can appear as the first ele
我有一种用 CFG 表示的相当简单的语言。 S → A z A → A y A | A x A | A w | v 因为有左递归,递归下降解析器不会削减它。但是,我还需要找到所有可能的解释
Hibernate 的常用配置文件主要分为 2 种:核心配置文件(hibernate.cfg.xml)和映射文件(Xxx.hbm.xml),它们主要用于配置数据库连接、事务管理、Hibernate 本
出于测试目的,我需要 cfg 始终为真/假。对于 true 我使用 #[ cfg( target_pointer_width = "64") ] ... 但显然不够通用。表达 cfg 以获得必要值(v
我有以下常量: const IS_WSL: bool = is_wsl!(); 我希望能够将它与 cfg 属性一起使用来执行条件编译。像这样的东西: #[cfg(const = "IS_WSL")]
我知道给定一个特定的上下文无关语法,要检查它是否有歧义,需要检查是否存在任何可以以不止一种方式派生的字符串。这是不可判定的。 但是,我有一个更简单的问题。给定一个特定的上下文无关文法和一个特定的字符串
以下文法有左递归: T -> Tx | TYx | YX | x X -> xx Y -> Yy | Yx | y 你如何去除左递归。我阅读了维基百科的解释,但我对 CFG 还很陌生,所以它没有多大意
我想将 $cfg['RowActionLinksWithoutUnique'] 设置为 TRUE 以便我可以在 phpMyAdmin 中编辑数据而无需任何主键,但在检查 config.inc.php
考虑以下上下文无关文法的扩展,它允许规则在左侧有一个(或多个)终结符在非终结符的右侧。即形式规则: A b -> ... 右手边可以是任何东西,就像在上下文无关文法中一样。特别是不是 要求,右侧将在末
我是一名优秀的程序员,十分优秀!