I hope someone can help me. I\'m working on a simple application which connects with an SQLite database. Following is my connection code:
try {
I got the same problem. I used maven and added dependency:
org.xerial
sqlite-jdbc
3.15.1
It could be compiled and I got:
No suitable driver found for jdbc:sqlite:xx.db
I Checked the classpath and I was sure sqlite-jdbc-3.15.1.jar was there. I guess that for some reason, the Class was not loaded, I don't know why. so I added
Class.forName("org.sqlite.JDBC");
at the beginning of my code. It worked!
And ,I delete the line above. It still works! I cleaned the project and rebuild it, no more Class.forName() is needed!!! I still Don't know why. But the problem is solved. I think Class.forName() can be used for diagnose if the class you need is in the classpath.