gpt4 book ai didi

java - HSQLDB连接错误

转载 作者:行者123 更新时间:2023-12-01 12:55:16 28 4
gpt4 key购买 nike

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

我用Google搜索了这个连接问题,但大多数都没有多大帮助,有人说可能是HSQLDB版本问题。数据库以“SHUT COMPRESS”模式关闭。有人给点建议吗?

最佳答案

因为第二个相对路径中的URL之间有空格。

C:/Program Files/tich Tools/mos tech/app/data/db/t1/t2/01/db
^ ^ ^

使用单引号 ''

Relative database file paths can be specified in a

platform independent manner as: '[dir1/dir2/.../dirn/]file-name-prefix'.

更多引用请访问HSQLDB JDBC

关于java - HSQLDB连接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23966048/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com