Android Sample Using H2

I saw that you did some tests on Android. When I try to run my test with H2, I get a FileNotFoundException. I am trying to use the built-in usage 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 also tried:

    String url = "jdbc:h2:/data/data/" + "com.mydomain.MyApp"
            + "/data/myTestDB" + ";FILE_LOCK=FS" + ";PAGE_SIZE=1024"
            + ";CACHE_SIZE=8192";

but no luck.

I placed myTest.h2.db in the / assets folder of my Android project. If you can post your sample code, that would be great!

thank

+3
source share
1 answer

I do not know what the problem is, can you post a full error message and a stack trace? The "official" documentation is here:

http://h2database.com/html/tutorial.html#android

+1
source

Source: https://habr.com/ru/post/1780767/


All Articles