hibernate mysql connection.url

在E盘的PRJ_J2EE项目中,由于类路径包含了多个SLF4J绑定,导致了SLF4J警告。具体来说,它在activemq-all-5.14.1.jar和slf4j-log4j12-1.4.3.jar中发现了SLF4J的实现。实际绑定为Log4jLoggerFactory。同时,日志显示Hibernate配置过程中遇到了问题,无法找到hibernate.properties文件,并尝试从hibernate_ehcache/hibernate.cfg.xml加载配置,但因XML解析错误(实体引用未以';'结束)而失败,引发HibernateException。

 

SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/E:/PRJ_J2EE/PrjFlexJava/WebContent/WEB-INF/lib/activemq-all-5.14.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/E:/PRJ_J2EE/PrjFlexJava/WebContent/WEB-INF/lib/slf4j-log4j12-1.4.3.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
2022-09-05 18:24:25,682  INFO org.hibernate.cfg.Environment - Hibernate 3.3.1.GA
2022-09-05 18:24:25,688  INFO org.hibernate.cfg.Environment - hibernate.properties not found
2022-09-05 18:24:25,693  INFO org.hibernate.cfg.Environment - Bytecode provider name : javassist
2022-09-05 18:24:25,699  INFO org.hibernate.cfg.Environment - using JDK 1.4 java.sql.Timestamp handling
2022-09-05 18:24:25,765  INFO org.hibernate.cfg.Configuration - configuring from resource: /hibernate_ehcache/hibernate.cfg.xml
2022-09-05 18:24:25,765  INFO org.hibernate.cfg.Configuration - Configuration resource: /hibernate_ehcache/hibernate.cfg.xml
2022-09-05 18:24:25,796 DEBUG org.hibernate.util.DTDEntityResolver - trying to resolve system-id [http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd]
2022-09-05 18:24:25,797 DEBUG org.hibernate.util.DTDEntityResolver - recognized hibernate namespace; attempting to resolve on classpath under org/hibernate/
2022-09-05 18:24:25,797 DEBUG org.hibernate.util.DTDEntityResolver - located [http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd] in classpath
2022-09-05 18:24:25,853 ERROR org.hibernate.util.XMLHelper - Error parsing XML: /hibernate_ehcache/hibernate.cfg.xml(9) 对实体 "characterEncoding" 的引用必须以 ';' 分隔符结尾。
Exception in thread "main" org.hibernate.HibernateException: Could not parse configuration: /hibernate_ehcache/hibernate.cfg.xml
	at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1528)
	at org.hibernate.cfg.Configuration.configure(Configuration.java:1462)
	at hibernate_ehcache.HibernateMySqlTest.save(HibernateMySqlTest.java:18)
	at hibernate_ehcache.HibernateMySqlTest.main(HibernateMySqlTest.java:53)
Caused by: org.dom4j.DocumentException: Error on line 9 of document  : 对实体 "characterEncoding" 的引用必须以 ';' 分隔符结尾。 Nested exception: 对实体 "characterEncoding" 的引用必须以 ';' 分隔符结尾。
	at org.dom4j.io.SAXReader.read(SAXReader.java:482)
	at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1518)
	... 3 more

<property name="connection.url"><![CDATA[jdbc:mysql://192.168.1.2:3306/mysql?useUnicode=true&characterEncoding=gb2312&serverTimezone=GMT%2B8&useSSL=false]]></property>

<?xml version='1.0' encoding='utf-8'?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <!-- MySQL 8.x 配置(使用新版驱动时) --> Connection conn = DriverManager.getConnection(url, user, pwd); <property name="connection.driver_class">com.mysql.cj.jdbc.Driver</property> <property name="connection.url">jdbc:mysql://localhost:3306/message_db?useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true</property> <property name="connection.username">root</property> <property name="connection.password">82615486</property> <!-- 连接池设置 --> <property name="hibernate.c3p0.min_size">5</property> <property name="hibernate.c3p0.max_size">20</property> <property name="hibernate.c3p0.timeout">1800</property> <property name="hibernate.c3p0.max_statements">50</property> <property name="dialect">org.hibernate.dialect.MySQL5InnoDBDialect</property> <property name="show_sql">true</property> <!-- 强制使用TLSv1.2协议 --> <property name="hibernate.connection.sslProtocol">TLSv1.2</property> <property name="hibernate.connection.sslEnabled">true</property> <mapping class="model.Message"/> <mapping class="model.User"/> </session-factory> </hibernate-configuration>tly registered JDBC driver list: Exception in thread "main" java.lang.ClassCastException: com.mysql.cj.jdbc.Driver cannot be cast to java.sql.Driver at servlet.TestConnection.main(TestConnection.java:24)
06-22
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

13805029595

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值