开发者

cannot read SQLite database file in an Eclipse Plugin project

I am REALLY new to Eclipse plugin developement, so maybe my question sounds dumb, but I've been googling for hours...

Whats the way to load an SQLite db into my Eclipse plugin?

First I created a standalone Java application, it loaded, and processed the database file just file, but when I added the code (well copied the files to the new project) it says:

java.sql.SQLException: no such table: measurement

The db file is in the projects root dir.

I thought this issue is caused becouse the applicaiton cannot find the database file, so I changed the filename from test.db to asdftest.db, and I got the same error, so the problem was this indeed.

Thanks!

Here is the code:

public List<Coord> generateModel() {
        try {
            Class.forName("org.sqlite.JDBC");
            Connection conn = DriverManager
           开发者_如何转开发         .getConnection("jdbc:sqlite:test.db");
            Statement stat = conn.createStatement();
            ResultSet rs = stat
                    .executeQuery("select * from measurement where has_gps = 'TRUE';");

            LinkedList<Coord> nodes = new LinkedList<Coord>();

            while (rs.next()) {
                nodes.add(new Coord(rs.getString("_id"), rs.getString("lat"),
                        rs.getString("lon")));
            }
            rs.close();

            conn.close();

            return nodes;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜