H2 不保存价值,不抛出任何异常
Posted
技术标签:
【中文标题】H2 不保存价值,不抛出任何异常【英文标题】:H2 not saving value and not throwing any exceptions 【发布时间】:2012-09-04 12:11:14 【问题描述】:我开始使用 h2 数据库。
我正在使用以下代码在数据库中保存一个值 -
public class MyDao extends NamedParameterJdbcDaoSupport
public void save()
System.out.println("Saving..");
getNamedParameterJdbcTemplate().update(
"insert into mytable values(:time)",
new MapSqlParameterSource("time", new Date()));
System.out.println("Saved..");
弹簧配置-
<bean id="dataSource" class="org.h2.jdbcx.JdbcConnectionPool"
destroy-method="dispose">
<constructor-arg>
<bean class="org.h2.jdbcx.JdbcDataSource">
<property name="URL" value="jdbc:h2:tcp://localhost:8082/test/" />
<property name="user" value="sa" />
<property name="password" value="" />
</bean>
</constructor-arg>
</bean>
代码打印Saving..
,然后从不打印Saved..
。它在更新语句处冻结。
没有抛出异常。这是为什么呢?
编辑:
Full thread dump Java HotSpot(TM) Client VM (23.4-b01 mixed mode, sharing):
"Thread-5" prio=6 tid=0x03fd9c00 nid=0x1dcc runnable [0x0887f000]
java.lang.Thread.State: RUNNABLE
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
- locked <0x23a9d4d0> (a java.io.BufferedInputStream)
at java.io.DataInputStream.readInt(Unknown Source)
at org.h2.value.Transfer.readInt(Transfer.java:151)
at org.h2.engine.SessionRemote.done(SessionRemote.java:560)
at org.h2.engine.SessionRemote.initTransfer(SessionRemote.java:111)
at org.h2.engine.SessionRemote.connectServer(SessionRemote.java:395)
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:287)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:108)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:92)
at org.h2.Driver.connect(Driver.java:72)
at org.h2.jdbcx.JdbcDataSource.getJdbcConnection(JdbcDataSource.java:181)
at org.h2.jdbcx.JdbcDataSource.getXAConnection(JdbcDataSource.java:315)
at org.h2.jdbcx.JdbcDataSource.getPooledConnection(JdbcDataSource.java:341)
at org.h2.jdbcx.JdbcConnectionPool.getConnectionNow(JdbcConnectionPool.java:226)
at org.h2.jdbcx.JdbcConnectionPool.getConnection(JdbcConnectionPool.java:199)
- locked <0x23c127d8> (a org.h2.jdbcx.JdbcConnectionPool)
at org.springframework.jdbc.datasource.DataSourceUtils.doGetConnection(DataSourceUtils.java:111)
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:77)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:573)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:812)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:834)
at org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate.update(NamedParameterJdbcTemplate.java:260)
at com.kshitiz.data.db.MyDao.save(MyDao.java:14)
at com.kshitiz.data.db.DatabaseDaemon.run(DatabaseDaemon.java:17)
Locked ownable synchronizers:
- None
"Thread-3" prio=6 tid=0x063e8000 nid=0x1be4 waiting on condition [0x075cf000]
java.lang.Thread.State: TIMED_WAITING (sleeping)
at java.lang.Thread.sleep(Native Method)
at com.kshitiz.ReadDaemon.run(ReadDaemon.java:25)
Locked ownable synchronizers:
- None
"Prism Font Disposer" daemon prio=10 tid=0x03e2b000 nid=0x1918 in Object.wait() [0x072ff000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x28f10b98> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(Unknown Source)
- locked <0x28f10b98> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(Unknown Source)
at com.sun.t2k.Disposer.run(Disposer.java:71)
at java.lang.Thread.run(Unknown Source)
Locked ownable synchronizers:
- None
"Thread-2" daemon prio=6 tid=0x03ee3400 nid=0x10d0 runnable [0x00000000]
java.lang.Thread.State: RUNNABLE
Locked ownable synchronizers:
- None
"JavaFX Application Thread" prio=6 tid=0x03ede800 nid=0x1080 runnable [0x04b2f000]
java.lang.Thread.State: RUNNABLE
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.access$100(WinApplication.java:29)
at com.sun.glass.ui.win.WinApplication$2$1.run(WinApplication.java:67)
at java.lang.Thread.run(Unknown Source)
Locked ownable synchronizers:
- None
"Disposer" daemon prio=10 tid=0x03eb2c00 nid=0x48c in Object.wait() [0x0416f000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x28d107b0> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(Unknown Source)
- locked <0x28d107b0> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(Unknown Source)
at com.sun.glass.utils.Disposer.run(Disposer.java:69)
at java.lang.Thread.run(Unknown Source)
Locked ownable synchronizers:
- None
"QuantumRenderer-0" daemon prio=6 tid=0x03eb2400 nid=0xee4 waiting on condition [0x040df000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x28d10848> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(Unknown Source)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(Unknown Source)
at java.util.concurrent.LinkedBlockingQueue.take(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.getTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:98)
at java.lang.Thread.run(Unknown Source)
Locked ownable synchronizers:
- None
"JavaFX-Launcher" prio=6 tid=0x03e17c00 nid=0xb1c waiting on condition [0x03c8f000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x28d220b8> (a java.util.concurrent.CountDownLatch$Sync)
at java.util.concurrent.locks.LockSupport.park(Unknown Source)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(Unknown Source)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(Unknown Source)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(Unknown Source)
at java.util.concurrent.CountDownLatch.await(Unknown Source)
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:330)
at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:47)
at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:115)
at java.lang.Thread.run(Unknown Source)
Locked ownable synchronizers:
- None
"Service Thread" daemon prio=6 tid=0x015f4000 nid=0x1ed4 runnable [0x00000000]
java.lang.Thread.State: RUNNABLE
Locked ownable synchronizers:
- None
"C1 CompilerThread0" daemon prio=10 tid=0x015ee400 nid=0x1df8 waiting on condition [0x00000000]
java.lang.Thread.State: RUNNABLE
Locked ownable synchronizers:
- None
"Attach Listener" daemon prio=10 tid=0x015ed000 nid=0x950 waiting on condition [0x00000000]
java.lang.Thread.State: RUNNABLE
Locked ownable synchronizers:
- None
"Signal Dispatcher" daemon prio=10 tid=0x015e3400 nid=0x1b38 runnable [0x00000000]
java.lang.Thread.State: RUNNABLE
Locked ownable synchronizers:
- None
"Finalizer" daemon prio=8 tid=0x015d7400 nid=0xb54 in Object.wait() [0x03a7f000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x28d10d58> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(Unknown Source)
- locked <0x28d10d58> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(Unknown Source)
at java.lang.ref.Finalizer$FinalizerThread.run(Unknown Source)
Locked ownable synchronizers:
- None
"Reference Handler" daemon prio=10 tid=0x015d2800 nid=0x1294 in Object.wait() [0x038cf000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x28d104e8> (a java.lang.ref.Reference$Lock)
at java.lang.Object.wait(Object.java:503)
at java.lang.ref.Reference$ReferenceHandler.run(Unknown Source)
- locked <0x28d104e8> (a java.lang.ref.Reference$Lock)
Locked ownable synchronizers:
- None
"main" prio=6 tid=0x016bc400 nid=0x1f40 waiting on condition [0x016af000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x28d10de0> (a java.util.concurrent.CountDownLatch$Sync)
at java.util.concurrent.locks.LockSupport.park(Unknown Source)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(Unknown Source)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly(Unknown Source)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(Unknown Source)
at java.util.concurrent.CountDownLatch.await(Unknown Source)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:134)
at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:75)
at javafx.application.Application.launch(Application.java:209)
at com.kshitiz.ui.Main.main(Main.java:73)
Locked ownable synchronizers:
- None
"VM Thread" prio=10 tid=0x015d1400 nid=0x1f44 runnable
"VM Periodic Task Thread" prio=10 tid=0x01615c00 nid=0x1114 waiting on condition
JNI global references: 309
服务器端线程转储 -
Full thread dump Java HotSpot(TM) Client VM (23.4-b01 mixed mode, sharing):
"H2 Console thread" prio=6 tid=0x05ea2000 nid=0x15d8 runnable [0x04baf000]
java.lang.Thread.State: RUNNABLE
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
- locked <0x239da8c0> (a java.io.BufferedInputStream)
at org.h2.server.web.WebThread.readHeaderLine(WebThread.java:212)
at org.h2.server.web.WebThread.process(WebThread.java:114)
at org.h2.server.web.WebThread.run(WebThread.java:93)
at java.lang.Thread.run(Unknown Source)
Locked ownable synchronizers:
- None
"H2 Console thread" prio=6 tid=0x05ea1400 nid=0x1f54 runnable [0x04eef000]
java.lang.Thread.State: RUNNABLE
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
- locked <0x23c120b8> (a java.io.BufferedInputStream)
at org.h2.server.web.WebThread.readHeaderLine(WebThread.java:212)
at org.h2.server.web.WebThread.process(WebThread.java:114)
at org.h2.server.web.WebThread.run(WebThread.java:93)
at java.lang.Thread.run(Unknown Source)
Locked ownable synchronizers:
- None
"H2 Console thread" prio=6 tid=0x05ea0c00 nid=0xd7c runnable [0x04e1f000]
java.lang.Thread.State: RUNNABLE
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
- locked <0x23c141c8> (a java.io.BufferedInputStream)
at org.h2.server.web.WebThread.readHeaderLine(WebThread.java:212)
at org.h2.server.web.WebThread.process(WebThread.java:114)
at org.h2.server.web.WebThread.run(WebThread.java:93)
at java.lang.Thread.run(Unknown Source)
Locked ownable synchronizers:
- None
"H2 Console thread" prio=6 tid=0x05ea0800 nid=0x15f0 runnable [0x04caf000]
java.lang.Thread.State: RUNNABLE
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
- locked <0x28ffe380> (a java.io.BufferedInputStream)
at org.h2.server.web.WebThread.readHeaderLine(WebThread.java:212)
at org.h2.server.web.WebThread.process(WebThread.java:114)
at org.h2.server.web.WebThread.run(WebThread.java:93)
at java.lang.Thread.run(Unknown Source)
Locked ownable synchronizers:
- None
"H2 Console thread" prio=6 tid=0x05ea0000 nid=0xe54 runnable [0x0468f000]
java.lang.Thread.State: RUNNABLE
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
- locked <0x29000498> (a java.io.BufferedInputStream)
at org.h2.server.web.WebThread.readHeaderLine(WebThread.java:212)
at org.h2.server.web.WebThread.process(WebThread.java:114)
at org.h2.server.web.WebThread.run(WebThread.java:93)
at java.lang.Thread.run(Unknown Source)
Locked ownable synchronizers:
- None
"H2 Console thread" prio=6 tid=0x05e9fc00 nid=0x328 runnable [0x03d0f000]
java.lang.Thread.State: RUNNABLE
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
- locked <0x29009958> (a java.io.BufferedInputStream)
at org.h2.server.web.WebThread.readHeaderLine(WebThread.java:212)
at org.h2.server.web.WebThread.process(WebThread.java:114)
at org.h2.server.web.WebThread.run(WebThread.java:93)
at java.lang.Thread.run(Unknown Source)
Locked ownable synchronizers:
- None
"H2 Log Writer TEST" daemon prio=6 tid=0x0409e800 nid=0x31c in Object.wait() [0x04d8f000]
java.lang.Thread.State: TIMED_WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x29000688> (a org.h2.store.WriterThread)
at org.h2.store.WriterThread.run(WriterThread.java:104)
- locked <0x29000688> (a org.h2.store.WriterThread)
at java.lang.Thread.run(Unknown Source)
Locked ownable synchronizers:
- None
"H2 File Lock Watchdog C:/Users/kshitiz/test.lock.db" daemon prio=10 tid=0x03ed6400 nid=0x1154 waiting on condition [0x0498f000]
java.lang.Thread.State: TIMED_WAITING (sleeping)
at java.lang.Thread.sleep(Native Method)
at org.h2.store.FileLock.run(FileLock.java:492)
at java.lang.Thread.run(Unknown Source)
Locked ownable synchronizers:
- None
"H2 TCP Server (tcp://192.168.1.145:9092) thread" prio=6 tid=0x03f08800 nid=0x1764 runnable [0x04bfe000]
java.lang.Thread.State: RUNNABLE
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
- locked <0x29004920> (a java.io.BufferedInputStream)
at java.io.DataInputStream.readInt(Unknown Source)
at org.h2.value.Transfer.readInt(Transfer.java:151)
at org.h2.server.TcpServerThread.process(TcpServerThread.java:246)
at org.h2.server.TcpServerThread.run(TcpServerThread.java:149)
at java.lang.Thread.run(Unknown Source)
Locked ownable synchronizers:
- None
"H2 Console thread" prio=6 tid=0x04008400 nid=0x17c0 runnable [0x04b1f000]
java.lang.Thread.State: RUNNABLE
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at java.io.BufferedInputStream.fill(Unknown Source)
at java.io.BufferedInputStream.read(Unknown Source)
- locked <0x28f309c0> (a java.io.BufferedInputStream)
at org.h2.server.web.WebThread.readHeaderLine(WebThread.java:212)
at org.h2.server.web.WebThread.process(WebThread.java:114)
at org.h2.server.web.WebThread.run(WebThread.java:93)
at java.lang.Thread.run(Unknown Source)
Locked ownable synchronizers:
- None
"DestroyJavaVM" prio=6 tid=0x017eb800 nid=0x1b38 waiting on condition [0x00000000]
java.lang.Thread.State: RUNNABLE
Locked ownable synchronizers:
- None
"H2 PG Server (pg://192.168.1.145:5435)" prio=6 tid=0x03fd3000 nid=0xb3c runnable [0x0629f000]
java.lang.Thread.State: RUNNABLE
at java.net.DualStackPlainSocketImpl.accept0(Native Method)
at java.net.DualStackPlainSocketImpl.socketAccept(Unknown Source)
at java.net.AbstractPlainSocketImpl.accept(Unknown Source)
at java.net.PlainSocketImpl.accept(Unknown Source)
- locked <0x28f30ba0> (a java.net.SocksSocketImpl)
at java.net.ServerSocket.implAccept(Unknown Source)
at java.net.ServerSocket.accept(Unknown Source)
at org.h2.server.pg.PgServer.listen(PgServer.java:182)
at org.h2.tools.Server.run(Server.java:544)
at java.lang.Thread.run(Unknown Source)
Locked ownable synchronizers:
- None
"H2 TCP Server (tcp://192.168.1.145:9092)" prio=6 tid=0x03fda000 nid=0xa10 runnable [0x04f9f000]
java.lang.Thread.State: RUNNABLE
at java.net.DualStackPlainSocketImpl.accept0(Native Method)
at java.net.DualStackPlainSocketImpl.socketAccept(Unknown Source)
at java.net.AbstractPlainSocketImpl.accept(Unknown Source)
at java.net.PlainSocketImpl.accept(Unknown Source)
- locked <0x28e03a88> (a java.net.SocksSocketImpl)
at java.net.ServerSocket.implAccept(Unknown Source)
at java.net.ServerSocket.accept(Unknown Source)
at org.h2.server.TcpServer.listen(TcpServer.java:239)
at org.h2.tools.Server.run(Server.java:544)
at java.lang.Thread.run(Unknown Source)
Locked ownable synchronizers:
- None
"AWT-EventQueue-0" prio=6 tid=0x03f30c00 nid=0x18a4 waiting on condition [0x04a6f000]
java.lang.Thread.State: WAITING (parking)
at sun.misc.Unsafe.park(Native Method)
- parking to wait for <0x28e03c90> (a java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject)
at java.util.concurrent.locks.LockSupport.park(Unknown Source)
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(Unknown Source)
at java.awt.EventQueue.getNextEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Locked ownable synchronizers:
- None
"AWT-Windows" daemon prio=6 tid=0x03efa800 nid=0x1cd8 runnable [0x0471f000]
java.lang.Thread.State: RUNNABLE
at sun.awt.windows.WToolkit.eventLoop(Native Method)
at sun.awt.windows.WToolkit.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Locked ownable synchronizers:
- None
"AWT-Shutdown" prio=6 tid=0x03f6a000 nid=0x1920 in Object.wait() [0x047af000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x28e03df8> (a java.lang.Object)
at java.lang.Object.wait(Object.java:503)
at sun.awt.AWTAutoShutdown.run(Unknown Source)
- locked <0x28e03df8> (a java.lang.Object)
at java.lang.Thread.run(Unknown Source)
Locked ownable synchronizers:
- None
"Java2D Disposer" daemon prio=10 tid=0x03f3c000 nid=0x18bc in Object.wait() [0x045df000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x28e03e88> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(Unknown Source)
- locked <0x28e03e88> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(Unknown Source)
at sun.java2d.Disposer.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Locked ownable synchronizers:
- None
"H2 Console Server (http://192.168.1.145:8082)" prio=6 tid=0x03edd800 nid=0x1298 runnable [0x03b0f000]
java.lang.Thread.State: RUNNABLE
at java.net.DualStackPlainSocketImpl.accept0(Native Method)
at java.net.DualStackPlainSocketImpl.socketAccept(Unknown Source)
at java.net.AbstractPlainSocketImpl.accept(Unknown Source)
at java.net.PlainSocketImpl.accept(Unknown Source)
- locked <0x28e03f68> (a java.net.SocksSocketImpl)
at java.net.ServerSocket.implAccept(Unknown Source)
at java.net.ServerSocket.accept(Unknown Source)
at org.h2.server.web.WebServer.listen(WebServer.java:341)
at org.h2.tools.Server.run(Server.java:544)
at java.lang.Thread.run(Unknown Source)
Locked ownable synchronizers:
- None
"Service Thread" daemon prio=6 tid=0x0199f000 nid=0x15ac runnable [0x00000000]
java.lang.Thread.State: RUNNABLE
Locked ownable synchronizers:
- None
"C1 CompilerThread0" daemon prio=10 tid=0x0198ec00 nid=0x18d0 waiting on condition [0x00000000]
java.lang.Thread.State: RUNNABLE
Locked ownable synchronizers:
- None
"Attach Listener" daemon prio=10 tid=0x0198d000 nid=0x103c waiting on condition [0x00000000]
java.lang.Thread.State: RUNNABLE
Locked ownable synchronizers:
- None
"Signal Dispatcher" daemon prio=10 tid=0x0198a000 nid=0x1efc runnable [0x00000000]
java.lang.Thread.State: RUNNABLE
Locked ownable synchronizers:
- None
"Finalizer" daemon prio=8 tid=0x01973400 nid=0x1d0c in Object.wait() [0x03abf000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x28e04220> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(Unknown Source)
- locked <0x28e04220> (a java.lang.ref.ReferenceQueue$Lock)
at java.lang.ref.ReferenceQueue.remove(Unknown Source)
at java.lang.ref.Finalizer$FinalizerThread.run(Unknown Source)
Locked ownable synchronizers:
- None
"Reference Handler" daemon prio=10 tid=0x01971c00 nid=0x1e30 in Object.wait() [0x0185f000]
java.lang.Thread.State: WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <0x28e03970> (a java.lang.ref.Reference$Lock)
at java.lang.Object.wait(Object.java:503)
at java.lang.ref.Reference$ReferenceHandler.run(Unknown Source)
- locked <0x28e03970> (a java.lang.ref.Reference$Lock)
Locked ownable synchronizers:
- None
"VM Thread" prio=10 tid=0x01970800 nid=0x15b0 runnable
"VM Periodic Task Thread" prio=10 tid=0x019a9c00 nid=0x19e8 waiting on condition
JNI global references: 604
【问题讨论】:
你能得到一个完整的线程转储并发布吗?要获取进程 ID,请在命令行上运行jps -l
,然后运行 jstack -l <pid>
以获取完整的线程转储。
@KshitizSharma 服务器端怎么样,你也可以发布完整的线程转储吗?实际上我会先检查H2服务器版本是否与客户端相同(理论上应该没有问题,但过去有一些兼容性)。
@ThomasMueller 也这样做了。客户端和服务器都运行 1.3.168
@ThomasMueller 如果我将数据库 url 字符串更改为 localhost
而不是 localhost:8082
,问题就会消失。我不明白为什么会这样。它不应该在端口 8082 上运行吗?
@KshitizSharma Web 服务器的默认端口是 8082,但这是错误的服务器。您不想连接到 Web 服务器,而是想连接到 TCP 服务器。默认端口是 9092。
【参考方案1】:
问题出在 jdbc url 中,它应该包含 localhost:9092
而不是 localhost:8082
。
从上面的评论中引用 Thomas Mueller -
Web 服务器的默认端口是 8082,但这是错误的 服务器。你不想连接到网络服务器,你想 连接到 TCP 服务器。那里的默认端口是 9092。
【讨论】:
以上是关于H2 不保存价值,不抛出任何异常的主要内容,如果未能解决你的问题,请参考以下文章