Reputation: 21
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.
Upvotes: 0
Views: 126
Reputation: 120168
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");
Upvotes: 2
Reputation: 24316
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.
Upvotes: 2