HSQLDB连接错误
Posted
技术标签:
【中文标题】HSQLDB连接错误【英文标题】:HSQLDB connection error 【发布时间】:2014-05-31 03:17:24 【问题描述】:我创建了一个用于连接 HSQLDB 的 java 程序,第一个运行良好,
public final static String DRIVER = "org.hsqldb.jdbcDriver";
public final static String URL = "jdbc:hsqldb:file:F:/hsqlTest/data/db";
public final static String DBNAME = "SA";
但这些不是
public final static String DRIVER = "org.hsqldb.jdbcDriver";
public final static String URL = "jdbc:hsqldb:file:C:/Program Files/tich Tools/mos tech/app/data/db/t1/t2/01/db";
public final static String DBNAME = "SA";
错误显示如下:
java.sql.SQLException: error in script file line: 1 unexpected token: ?
at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
at org.hsqldb.jdbc.Util.sqlException(Unknown Source)
at org.hsqldb.jdbc.JDBCConnection.<init>(Unknown Source)
at org.hsqldb.jdbc.JDBCDriver.getConnection(Unknown Source)
at org.hsqldb.jdbc.JDBCDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at HSQLDBManagerImp.getconn(HSQLDBManagerImp.java:48)
at TESTHSQLDB.main(TESTHSQLDB.java:15)
Caused by: org.hsqldb.HsqlException: error in script file line: 1 unexpected token: ?
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.scriptio.ScriptReaderText.readDDL(Unknown Source)
at org.hsqldb.scriptio.ScriptReaderBase.readAll(Unknown Source)
at org.hsqldb.persist.Log.processScript(Unknown Source)
at org.hsqldb.persist.Log.open(Unknown Source)
at org.hsqldb.persist.Logger.openPersistence(Unknown Source)
at org.hsqldb.Database.reopen(Unknown Source)
at org.hsqldb.Database.open(Unknown Source)
at org.hsqldb.DatabaseManager.getDatabase(Unknown Source)
at org.hsqldb.DatabaseManager.newSession(Unknown Source)
... 7 more
Caused by: org.hsqldb.HsqlException: unexpected token: ?
at org.hsqldb.error.Error.parseError(Unknown Source)
at org.hsqldb.ParserBase.unexpectedToken(Unknown Source)
at org.hsqldb.ParserCommand.compilePart(Unknown Source)
at org.hsqldb.ParserCommand.compileStatement(Unknown Source)
at org.hsqldb.Session.compileStatement(Unknown Source)
... 16 more
我用谷歌搜索了这个连接问题,但大多数都没有多大帮助,有人说这可能是 HSQLDB 版本问题。 dbase 在“SHUT COMPRESS”模式下关闭。 有人给点建议吗?
【问题讨论】:
【参考方案1】:因为第二个Relative Path.
URL
之间有空格
C:/Program Files/tich Tools/mos tech/app/data/db/t1/t2/01/db
^ ^ ^
使用单引号 ''
。
相对数据库文件路径可以在a中指定
平台无关方式为:'[dir1/dir2/.../dirn/]file-name-prefix'。
更多参考请到HSQLDB JDBC
【讨论】:
以上是关于HSQLDB连接错误的主要内容,如果未能解决你的问题,请参考以下文章
HSQLDB prepareStatement("SET SCHEMA ?") 错误