Android嵌入式h2database没有权限

时间:2015-11-13 16:07:17

标签: java android database h2

在尝试让h2database工作了大约8个小时之后,我决定在这里发帖以获得一些帮助。

        try {

        Class.forName("org.h2.Driver");
        Connection con = DriverManager.getConnection("jdbc:h2:~/test", "test", "test");
        Statement stmt = con.createStatement();
        stmt.executeUpdate("CREATE TABLE table1 ( user varchar(50) )");
        stmt.executeUpdate("INSERT INTO table1 ( user ) VALUES ( 'Claudio' )");
        stmt.executeUpdate("INSERT INTO table1 ( user ) VALUES ( 'Bernasconi' )");
        stmt.executeUpdate("INSERT INTO table1 ( user ) VALUES ( 'Mauro' )");
        stmt.executeUpdate("INSERT INTO table1 ( user ) VALUES ( 'Jeffrey' )");
        ResultSet rs = stmt.executeQuery("SELECT * FROM table1");
        while (rs.next()) {
            String name = rs.getString("user");
            tokens.add(name);
        }
        stmt.close();
        con.close();
    } catch (JdbcSQLException e) {
        System.out.println(e.getMessage());
        System.out.println(e.getSQL());
    } catch (Exception e) {
        System.out.println(e.getClass());
        System.out.println("exception");

        System.out.println(e.getMessage());
    }

发生以下错误:“执行DriverManager.getConnection()时打开失败:EROFS(只读文件系统)”

对我而言Android没有将文件写入内部存储的正确权限。

之前有过这个问题且知道解决方案的人?绝望了。

提前致谢,

Greetings Mauro

0 个答案:

没有答案