org.h2.jdbc.JdbcSQLException:数据库可能已在使用中:“被另一个进程锁定”
Posted
技术标签:
【中文标题】org.h2.jdbc.JdbcSQLException:数据库可能已在使用中:“被另一个进程锁定”【英文标题】:org.h2.jdbc.JdbcSQLException: Database may be already in use: "Locked by another process" 【发布时间】:2012-06-12 19:14:16 【问题描述】:我正在尝试按照指示设置 Virgo 示例项目绿页 (http://www.eclipse.org/virgo/documentation/greenpages-documentation-2.4.0.RELEASE/docs/html/ch02s03.html)。当我执行数据脚本时出现异常。
数据库是这样启动的:
start java -cp ";C:\Users\flowersj\.m2\repository\com\h2database\h2\1.3.161\h2-1.3.161.jar"
org.h2.tools.Server
在该行插入数据失败的脚本:
java -cp ";C:\Users\flowersj\.m2\repository\com\h2database\h2\1.3.161\h2-1.3.161.jar"
org.h2.tools.RunScript
-url jdbc:h2:tcp://localhost/~/greenpages-db/greenpages
-user greenpages -password pass -script db.sql
例外是:
Exception in thread "main" org.h2.jdbc.JdbcSQLException: Database may be already in use: "Locked by another process". Possible solutions: close all other connection(s); use the server mode [90020-161]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
at org.h2.message.DbException.get(DbException.java:169)
at org.h2.message.DbException.get(DbException.java:146)
at org.h2.store.FileLock.getExceptionAlreadyInUse(FileLock.java:435)
at org.h2.store.FileLock.lockFile(FileLock.java:332)
at org.h2.store.FileLock.lock(FileLock.java:128)
at org.h2.engine.Database.open(Database.java:539)
at org.h2.engine.Database.openDatabase(Database.java:219)
at org.h2.engine.Database.<init>(Database.java:214)
at org.h2.engine.Engine.openSession(Engine.java:56)
at org.h2.engine.Engine.openSession(Engine.java:159)
at org.h2.engine.Engine.createSessionAndValidate(Engine.java:138)
at org.h2.engine.Engine.createSession(Engine.java:121)
at org.h2.server.TcpServerThread.run(TcpServerThread.java:124)
at java.lang.Thread.run(Unknown Source)
at org.h2.engine.SessionRemote.done(SessionRemote.java:538)
at org.h2.engine.SessionRemote.initTransfer(SessionRemote.java:109)
at org.h2.engine.SessionRemote.connectServer(SessionRemote.java:373)
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:267)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:110)
at org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:94)
at org.h2.Driver.connect(Driver.java:72)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at org.h2.tools.RunScript.process(RunScript.java:312)
at org.h2.tools.RunScript.runTool(RunScript.java:140)
at org.h2.tools.RunScript.main(RunScript.java:68)
【问题讨论】:
好吧,在这种情况下,数据库很可能已经在使用中,就像错误消息说的那样...... 【参考方案1】:我发现我无法在执行 data.bat 脚本的同时运行 Virgo 服务器。我以为是在支持多连接的模式下启动的。
【讨论】:
以上是关于org.h2.jdbc.JdbcSQLException:数据库可能已在使用中:“被另一个进程锁定”的主要内容,如果未能解决你的问题,请参考以下文章