![](/img/trans.png)
[英]How to make a file path compatible with an embedded database? (Apache Derby Embedded)
[英]Derby Embedded with SPACE in the database path
我使用嵌入在桌面應用程序中的derby。 但是,當數據庫路徑中(任何級別的目錄中)都有空間時 ,derby驅動程序將無法連接到數據庫。
問候, :)
更新
public static final String connectionUrl = "jdbc:derby:[path]database;user=app;password=pass;";
String path = Utils.getPathOfJar();
String dbPath = connectionUrl.replace("[path]", path);
dbConnection = DriverManager.getConnection(dbPath);
首先,此問題僅在Linux中發生。
數據庫的路徑應在系統屬性中進行如下設置:
derby.system.home
像這樣:
String path = Utils.getPathOfJar();
path = path.jarFilePath.replaceAll("%20", "\\ ");
System.setProperty("derby.system.home", path);
public static final String connectionUrl = "jdbc:derby:database;user=app;password=pass;";
dbConnection = DriverManager.getConnection(connectionUrl);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.