2011-09-07 24 views
10

我試圖按照chapter 1 of the HSQLDB doc的說明,並開始在我的服務器,如:如何使用sqltool連接到基於文件的HSQLDB數據庫?

java -cp hsqldb-2.2.5/hsqldb/lib/hsqldb.jar org.hsqldb.Server -database.0 file:#pathtodb# -dbname.0 xdb 

,我有理由相信,工作的原因,而是說(除其他事項外):

Database [index=0, id=0, db=file:#pathtodb#, alias=xdb] opened sucessfully in 2463 ms. 

然而,在下一步我嘗試使用雖然SqlTool連接和基於chapter 8 of the documentation我想出了這個命令來連接:

java -jar hsqldb-2.2.5/hsqldb/lib/sqltool.jar localhost-sa 

其中提供了以下錯誤:在虧損

[[email protected]]: [Thread[HSQLDB Connection @4ceafb71,5,HSQLDB Connections @60072ffb]]: database alias= does not exist 

我:

Failed to get a connection to 'jdbc:hsqldb:hsql://localhost' as user "SA". 
Cause: General error: database alias does not exist 

在服務器說。我應該在連接時指定別名嗎?我的數據庫有什麼別名呢?該服務器沒有說關於什麼...

(也,是我抄sqltool.rc文件到我的主文件夾。

回答

7

你的服務器有-dbname.0 xdb作爲數據庫別名。因此,連接URL應該包括xdb例如jdbc:hsqldb:hsql://localhost/xdb

服務器可以服務多個數據庫用不同的化名。無別名的URL對應於不包括別名設置服務器的命令行。

1

這個錯誤已被獵捕着我過去 5個小時。 加上這個愚蠢的錯誤:HSQL Driver not working?

如果你想用Apache Tomcat在servlet上運行你的hsqldb,你需要關閉runManagerSwing.bat。我知道這聽起來微不足道,但即使您創建了所需的數據庫,並且隨後使用Tomcat運行Eclipse J22 Servlet,您也會遇到一些錯誤。所以runManagerSwing.bat必須關閉。

0

您還可以使用以下語句從基於文件的商店獲取連接。如果您從Windows運行應用程序,則可以使用此功能。

connection = DriverManager.getConnection("jdbc:hsqldb:file:///c:/hsqldb/mydb", "SA", ""); 
1

java -jar /hsqldb-2.3.2/hsqldb/lib/sqltool.jar --inlineRc=url=jdbc:hsqldb:localhost:3333/runtime,user=sa Enter password for sa: as2dbadmin SqlTool v. 5337. JDBC Connection established to a HSQL Database Engine v. 2.3.2 database

+7

這是對堆棧溢出好的做法是添加一個解釋,爲什麼你的解決方案應該工作。有關更多信息,請閱讀[如何提問](http://stackoverflow.com/help/how-to-answer)。 –

相關問題