简体   繁体   中英

No suitable driver found for jdbc:sqlite (IntelliJ)

private final static String DATABASE_URL = "jdbc:sqlite:src/main/resources/adventure.db";

This always returns:

Exception in thread "main" java.sql.SQLException: No suitable driver found for jdbc:sqlite:src/main/resources/adventure.db

I've heard there was a possible way to fix this by going to View > Tool Windows > Database, hitting the + button, and then when creating the new SQLite database, click on the Driver: SQLite link to be able to download the SQLite driver. However, I've done that many times. It has failed every time because I receive the exact same error.

There's also a solution I read where you can supposedly type in:

Class.forName("org.sqlite.JDBC");

That doesn't work either. I just get hit with the error

"Cannot resolve symbol 'forName'"

So I'm just at a dead end because none of the solutions work for me. How am I supposed to fix this error that has been a pain in the ass?

Since you have the database file in your resource folder I would use

private final static String DATABASE_URL = "jdbc:sqlite:resources:adventure.db";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM