HSQLDB错误:java.sql.BatchUpdateException: fail batch

本文介绍了解决使用HibernateTemplate时遇到的BatchUpdateException错误的方法。通过禁用HSQLDB的批量更新功能并设置hibernate.jdbc.batch_size参数为0来解决此问题。
部分错误信息:
java.sql.BatchUpdateException: failed batch
org.hsqldb.jdbc.jdbcStatement.executeBatch(Unknown Source)
org.hsqldb.jdbc.jdbcPreparedStatement.executeBatch(Unknown Source)

导致这个错误的原因只是使用了HibernateTemplate中的一个简单方法:
getHibernateTemplate().bulkUpdate("delete FileInfo where fileId = ?", fileId);

初步认为是HSQLDB的问题,关闭了HSQLDB的批量更新功能就解决了问题。
由于使用的是hibernate,所以设置了hibernate.jdbc.batch_size=0就解决了问题。
[root@yfw ~]# cd /opt/openfire [root@yfw openfire]# sudo -u openfire tee /opt/openfire/conf/openfire.xml > /dev/null << 'EOF' > <?xml version="1.0" encoding="UTF-8"?> > <jive> > <adminConsole> > <port>9090</port> > <securePort>9091</securePort> > </adminConsole> > <locale>en_US</locale> > <setup>true</setup> <!-- 关键:强制进入安装模式 --> > </jive> > EOF [root@yfw openfire]# [root@yfw openfire]# # 设置权限 [root@yfw openfire]# sudo chown openfire:openfire /opt/openfire/conf/openfire.xml [root@yfw openfire]# sudo chmod 644 /opt/openfire/conf/openfire.xml [root@yfw openfire]# sudo chown -R openfire:openfire /opt/openfire/logs [root@yfw openfire]# sudo chmod -R 755 /opt/openfire/logs [root@yfw openfire]# sudo su - openfire Last login: Sat Nov 15 17:22:29 CST 2025 on pts/0 ✅ JAVA_HOME: /usr/lib/jvm/java-11-openjdk ✅ Maven home: /opt/maven ✅ Java version: openjdk version "11.0.13" 2021-10-19 LTS ✅ Environment loaded for openfire PATH = /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/lib/jvm/java-11-openjdk/bin:/opt/maven/bin:/usr/local/ffmpeg/bin:/opt/spark/bin JAVA_HOME = /usr/lib/jvm/java-11-openjdk [openfire@yfw ~]$ cd /opt/openfire [openfire@yfw openfire]$ ./bin/start.sh --no-daemon Starting OpenFire in foreground mode... 17:35:21.754 [main] ERROR org.jivesoftware.util.JiveGlobals - Unable to load default security properties from: /opt/openfire/conf/openfire.xml java.io.IOException: XML properties file must be writable: security.xml at org.jivesoftware.util.XMLProperties.<init>(XMLProperties.java:156) ~[xmppserver-5.0.2.jar:5.0.2] at org.jivesoftware.util.JiveGlobals.loadSecurityProperties(JiveGlobals.java:1312) [xmppserver-5.0.2.jar:5.0.2] at org.jivesoftware.util.JiveGlobals.isXMLPropertyEncrypted(JiveGlobals.java:1010) [xmppserver-5.0.2.jar:5.0.2] at org.jivesoftware.util.XMLProperties.getProperty(XMLProperties.java:212) [xmppserver-5.0.2.jar:5.0.2] at org.jivesoftware.util.XMLProperties.getProperty(XMLProperties.java:171) [xmppserver-5.0.2.jar:5.0.2] at org.jivesoftware.util.JiveGlobals.getXMLProperty(JiveGlobals.java:310) [xmppserver-5.0.2.jar:5.0.2] at org.jivesoftware.openfire.XMPPServer.initialize(XMPPServer.java:367) [xmppserver-5.0.2.jar:5.0.2] at org.jivesoftware.openfire.XMPPServer.start(XMPPServer.java:658) [xmppserver-5.0.2.jar:5.0.2] at org.jivesoftware.openfire.XMPPServer.<init>(XMPPServer.java:221) [xmppserver-5.0.2.jar:5.0.2] at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:?] at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) [?:?] at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [?:?] at java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) [?:?] at java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:128) [?:?] at jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:347) [?:?] at java.lang.Class.newInstance(Class.java:645) [?:?] at org.jivesoftware.openfire.starter.ServerStarter.start(ServerStarter.java:92) [startup.jar:5.0.2] at org.jivesoftware.openfire.starter.ServerStarter.main(ServerStarter.java:56) [startup.jar:5.0.2] 17:35:21.791 [main] ERROR org.jivesoftware.util.JiveProperties - null java.lang.NullPointerException: null at java.lang.Class.forName0(Native Method) ~[?:?] at java.lang.Class.forName(Class.java:375) ~[?:?] at org.jivesoftware.database.DefaultConnectionProvider.start(DefaultConnectionProvider.java:99) ~[xmppserver-5.0.2.jar:5.0.2] at org.jivesoftware.database.DbConnectionManager.setConnectionProvider(DbConnectionManager.java:652) ~[xmppserver-5.0.2.jar:5.0.2] at org.jivesoftware.database.DbConnectionManager.ensureConnectionProvider(DbConnectionManager.java:109) ~[xmppserver-5.0.2.jar:5.0.2] at org.jivesoftware.database.DbConnectionManager.getConnection(DbConnectionManager.java:162) ~[xmppserver-5.0.2.jar:5.0.2] at org.jivesoftware.util.JiveProperties.loadProperties(JiveProperties.java:472) [xmppserver-5.0.2.jar:5.0.2] at org.jivesoftware.util.JiveProperties.init(JiveProperties.java:108) [xmppserver-5.0.2.jar:5.0.2] at org.jivesoftware.util.JiveProperties.getInstance(JiveProperties.java:84) [xmppserver-5.0.2.jar:5.0.2] at org.jivesoftware.util.JiveGlobals.getProperty(JiveGlobals.java:547) [xmppserver-5.0.2.jar:5.0.2] at org.jivesoftware.util.cache.CacheFactory.<clinit>(CacheFactory.java:102) [xmppserver-5.0.2.jar:5.0.2] at org.jivesoftware.openfire.XMPPServer.initialize(XMPPServer.java:381) [xmppserver-5.0.2.jar:5.0.2] at org.jivesoftware.openfire.XMPPServer.start(XMPPServer.java:658) [xmppserver-5.0.2.jar:5.0.2] at org.jivesoftware.openfire.XMPPServer.<init>(XMPPServer.java:221) [xmppserver-5.0.2.jar:5.0.2] at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:?] at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) [?:?] at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [?:?] at java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) [?:?] at java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:128) [?:?] at jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:347) [?:?] at java.lang.Class.newInstance(Class.java:645) [?:?] at org.jivesoftware.openfire.starter.ServerStarter.start(ServerStarter.java:92) [startup.jar:5.0.2] at org.jivesoftware.openfire.starter.ServerStarter.main(ServerStarter.java:56) [startup.jar:5.0.2] Database setup or configuration error: Please verify your database settings and check the logs/openfire.log file for detailed error messages. 17:35:24.385 [main] ERROR org.jivesoftware.openfire.XMPPServer - Database could not be accessed java.sql.SQLException: ConnectionManager.getConnection() failed to obtain a connection after 11 attempts. The exception from the last attempt is as follows: java.sql.SQLException: Check JDBC properties; data source was not be initialised at org.jivesoftware.database.DbConnectionManager.getConnection(DbConnectionManager.java:204) ~[xmppserver-5.0.2.jar:5.0.2] at org.jivesoftware.openfire.XMPPServer.verifyDataSource(XMPPServer.java:1010) [xmppserver-5.0.2.jar:5.0.2] at org.jivesoftware.openfire.XMPPServer.start(XMPPServer.java:666) [xmppserver-5.0.2.jar:5.0.2] at org.jivesoftware.openfire.XMPPServer.<init>(XMPPServer.java:221) [xmppserver-5.0.2.jar:5.0.2] at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:?] at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) [?:?] at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [?:?] at java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) [?:?] at java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:128) [?:?] at jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:347) [?:?] at java.lang.Class.newInstance(Class.java:645) [?:?] at org.jivesoftware.openfire.starter.ServerStarter.start(ServerStarter.java:92) [startup.jar:5.0.2] at org.jivesoftware.openfire.starter.ServerStarter.main(ServerStarter.java:56) [startup.jar:5.0.2] java.lang.IllegalArgumentException: java.sql.SQLException: ConnectionManager.getConnection() failed to obtain a connection after 11 attempts. The exception from the last attempt is as follows: java.sql.SQLException: Check JDBC properties; data source was not be initialised at org.jivesoftware.openfire.XMPPServer.verifyDataSource(XMPPServer.java:1020) at org.jivesoftware.openfire.XMPPServer.start(XMPPServer.java:666) at org.jivesoftware.openfire.XMPPServer.<init>(XMPPServer.java:221) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) at java.base/java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:128) at java.base/jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:347) at java.base/java.lang.Class.newInstance(Class.java:645) at org.jivesoftware.openfire.starter.ServerStarter.start(ServerStarter.java:92) at org.jivesoftware.openfire.starter.ServerStarter.main(ServerStarter.java:56) Caused by: java.sql.SQLException: ConnectionManager.getConnection() failed to obtain a connection after 11 attempts. The exception from the last attempt is as follows: java.sql.SQLException: Check JDBC properties; data source was not be initialised at org.jivesoftware.database.DbConnectionManager.getConnection(DbConnectionManager.java:204) at org.jivesoftware.openfire.XMPPServer.verifyDataSource(XMPPServer.java:1010) ... 11 more 17:35:24.386 [main] ERROR org.jivesoftware.openfire.XMPPServer - java.sql.SQLException: ConnectionManager.getConnection() failed to obtain a connection after 11 attempts. The exception from the last attempt is as follows: java.sql.SQLException: Check JDBC properties; data source was not be initialised java.lang.IllegalArgumentException: java.sql.SQLException: ConnectionManager.getConnection() failed to obtain a connection after 11 attempts. The exception from the last attempt is as follows: java.sql.SQLException: Check JDBC properties; data source was not be initialised at org.jivesoftware.openfire.XMPPServer.verifyDataSource(XMPPServer.java:1020) ~[xmppserver-5.0.2.jar:5.0.2] at org.jivesoftware.openfire.XMPPServer.start(XMPPServer.java:666) [xmppserver-5.0.2.jar:5.0.2] at org.jivesoftware.openfire.XMPPServer.<init>(XMPPServer.java:221) [xmppserver-5.0.2.jar:5.0.2] at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:?] at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) [?:?] at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) [?:?] at java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) [?:?] at java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:128) [?:?] at jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:347) [?:?] at java.lang.Class.newInstance(Class.java:645) [?:?] at org.jivesoftware.openfire.starter.ServerStarter.start(ServerStarter.java:92) [startup.jar:5.0.2] at org.jivesoftware.openfire.starter.ServerStarter.main(ServerStarter.java:56) [startup.jar:5.0.2] Caused by: java.sql.SQLException: ConnectionManager.getConnection() failed to obtain a connection after 11 attempts. The exception from the last attempt is as follows: java.sql.SQLException: Check JDBC properties; data source was not be initialised at org.jivesoftware.database.DbConnectionManager.getConnection(DbConnectionManager.java:204) ~[xmppserver-5.0.2.jar:5.0.2] at org.jivesoftware.openfire.XMPPServer.verifyDataSource(XMPPServer.java:1010) ~[xmppserver-5.0.2.jar:5.0.2] ... 11 more Error starting the server. Please check the log files for more information.
最新发布
11-16
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值