HSQLDB连接错误

时间:2014-05-31 03:17:24

标签: java hsqldb

我创建了一个用于连接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 个答案:

答案 0 :(得分:1)

因为第二个URL

Relative Path.之间有空格
C:/Program Files/tich Tools/mos tech/app/data/db/t1/t2/01/db
          ^          ^         ^

使用单引号 ''

  

可以在

中指定相关数据库文件路径      

平台无关的方式'[dir1 / dir2 /.../ dirn /] file-name-prefix'

如需更多参考,请转至HSQLDB JDBC