使用 H2 的 Android 示例

发布于 2024-10-08 04:29:39 字数 619 浏览 9 评论 0原文

我看到你在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

九局 2024-10-15 04:29:39

我不知道问题是什么,你能发布完整的错误消息和堆栈跟踪吗? “官方”文档在这里:

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文