Re: Android - Table "ARTICLE" not found Error

71 views
Skip to first unread message

Thomas Mueller

unread,
Jun 27, 2012, 1:03:41 PM6/27/12
to h2-da...@googlegroups.com
Hi,

Most likely the table was not created, or it was created in a different database (a different path).

What is your database URL? I suggest to use an absolute path, for example jdbc:h2:/data/db/test. Using a relative path such as jdbc:h2:test is a common reason for such problems.

Regards,
Thomas



On Wednesday, June 27, 2012, r_jeff_m wrote:
On Android

I was using H2 version 1.3.151 without any problems. I upgraded to 1.3.167 and all was fine too, until I recreated the database.

I recreated the database and reloaded it, now I get this error on Android (but not on Windows/Java 1.5).

06-27 13:56:07.532: E/LibraryDB(276): org.h2.jdbc.JdbcSQLException: Table "ARTICLE" not found; SQL statement:

Under Java 1.5 and Windows, the same code works fine.

Any Ideas?

**************

    void Open(String filename) throws SQLException {
    try {
        Class.forName("org.h2.Driver");
    } catch (ClassNotFoundException ex) {
        Logger.getLogger(LibraryDB.class.getName()).log(Level.SEVERE, null, ex);
    }
    this.sFileName = filename;

    String url = "jdbc:h2:" + sFileName + ";IFEXISTS=TRUE"; // only open it if it's already there
    conn = DriverManager.getConnection(url, "sa", "");

   
    }



    Article getArticle(UUID articleUUID) {
    try {
        Statement stmt = conn.createStatement();
        String myStmt = String.format("SELECT * FROM public.article WHERE uuid='%s'", articleUUID.toString());
        ResultSet rs = stmt.executeQuery(myStmt);
        if (rs.first()) {
        Article myHint = new Article(rs);
        stmt.close();
        return myHint;
        }
    } catch (SQLException ex) {
        Logger.getLogger(LibraryDB.class.getName()).log(Level.SEVERE, null, ex);
    }
    return null;
    }

--
You received this message because you are subscribed to the Google Groups "H2 Database" group.
To view this discussion on the web visit https://groups.google.com/d/msg/h2-database/-/xxeoZ2xKE0oJ.
To post to this group, send email to h2-da...@googlegroups.com.
To unsubscribe from this group, send email to h2-database...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/h2-database?hl=en.

r_jeff_m

unread,
Jun 27, 2012, 7:20:37 PM6/27/12
to h2-da...@googlegroups.com
Thanks for the reply Thomas

The database is created externally to android and then added to the assets. On first run it is copied to the android application data directory.

The db (rLibrary) is then opened with:

jdbc:h2:/data/data/com.app.mobile/files/db/rLibrary;IFEXISTS=TRUE

This did work (1.3.151) before I recreated the db with 1.3.167
I've tried both the full and small jars.

Regards

r_jeff_m

unread,
Jul 3, 2012, 2:41:11 PM7/3/12
to h2-da...@googlegroups.com
Well... chalk it up to dumb user error. ;)

I had a problem copying over the db. All is fine now.
Reply all
Reply to author
Forward
0 new messages