使用 H2 的 Android 示例
我看到你在 Android 上做了一些测试。 当我尝试使用 H2 运行测试时,我收到 FileNotFoundException。 我正在尝试使用嵌入模式,这是我的代码片段:
String url = "jdbc:h2:~/myTestDB" + ";FILE_LOCK=FS" + ";PAGE_SIZE=1024"
+ ";CACHE_SIZE=8192";
Class.forName("org.h2.Driver");
return DriverManager.getConnection(url, "sa", "");
我也尝试过:
String url = "jdbc:h2:/data/data/" + "com.mydomain.MyApp"
+ "/data/myTestDB" + ";FILE_LOCK=FS" + ";PAGE_SIZE=1024"
+ ";CACHE_SIZE=8192";
但没有运气。
我已将 myTest.h2.db 放入 Android 项目的 /assets 文件夹中。 如果您可以发布代码示例,那就太好了!
谢谢
I saw that you've done some tests on Android.
When I am trying to run my test with H2, I am getting FileNotFoundException.
I am trying to use use embedded mode and here is my code snippet:
String url = "jdbc:h2:~/myTestDB" + ";FILE_LOCK=FS" + ";PAGE_SIZE=1024"
+ ";CACHE_SIZE=8192";
Class.forName("org.h2.Driver");
return DriverManager.getConnection(url, "sa", "");
I have also tried:
String url = "jdbc:h2:/data/data/" + "com.mydomain.MyApp"
+ "/data/myTestDB" + ";FILE_LOCK=FS" + ";PAGE_SIZE=1024"
+ ";CACHE_SIZE=8192";
but with no luck.
I've put myTest.h2.db in /assets folder of my Android project.
If you can post your code sample that would be great!
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道问题是什么,你能发布完整的错误消息和堆栈跟踪吗? “官方”文档在这里:
http://h2database.com/html/tutorial.html#android
I don't know what the problem could be, could you post the complete error message and stack trace? The 'official' documentation is here:
http://h2database.com/html/tutorial.html#android