0
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.

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

2

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");

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.