开发者

Problems connecting to a database. Java/SQLite

try {
    con = DriverManager.getConnection("jdbc:sqlite:db/Freepark.sqlite");
} catch (SQLException e) {
    // TODO Auto-generated catch block
    System.out.println("error al buscar开发者_如何转开发 la base de datos");
}

I am trying to do my first queries on an SQL database but I am having problems connecting to it. I think the problem is the URL for sure. The project name is BaseTest and inside project folder I have a subfolder called db and inside it is Freepark.sqlite. When I run the project the println message appears so I know that the problem is the URL. Things like class.forName are already done above this code sample.


First and foremost don't swallow the exception, which is what you are doing and why you are unable to figure out the root cause.


You are losing all of the exception information in your catch block. let the exception bubble up or otherwise print it.

you need to do something like

Class.forName("org.sqlite.JDBC");  
connection = DriverManager.getConnection("jdbc:sqlite:pathtodb");
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜