Openshift Java SQLite,无法打开/创建数据库文件

时间:2015-04-23 19:59:07

标签: java sqlite openshift

我正在尝试使用Java在openshift环境中创建/访问SQLite数据库文件。代码在我正在测试的本地Tomcat服务器上正常工作,但在将其部署到openshift环境时不起作用。

相关代码如下,根据日志,我能够识别失败的行:

日志:

Apr 23, 2015 3:37:33 PM my_package.HelloWorld_sl doPost
INFO: jdbc:sqlite:/var/lib/openshift/5522c491fcf9335ab7000053/app-root/data/test
Apr 23, 2015 3:37:33 PM my_package.HelloWorld_sl doPost
INFO: Class Loaded
Apr 23, 2015 3:37:33 PM my_package.HelloWorld_sl doPost
INFO: Trying Database connection establishment

(上面没有任何结果)

Java代码:

..
db_filename="jdbc:sqlite:"+ "data" + File.separatorChar + "test.db";
LOGGER.info(db_filename);

Class.forName("org.sqlite.JDBC");
LOGGER.info("Class Loaded");
LOGGER.info("Trying Database connection establishment"); //I see this message in logs, but not the next LOGGER message so it is the following line that fails.
dbc =DriverManager.getConnection(db_filename);
LOGGER.info("Database connection established");

提前致谢。 鲍勃

1 个答案:

答案 0 :(得分:0)

可能是db文件不在您认为的位置,或者您没有访问该文件的权限。 是LOGGER.info(db_filename);回归你的期望? 如果是,您(您的程序)是否具有写权限?

'dbc'也是一个错字,对吗?假设是'jdbc'