[英]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.