一、异常说明
运行java连接SQLite使用代码示例,结果报“java.sql.SQLException: No suitable driver found for jdbc:sqlite:sample.db”错误异常,提示缺少依赖包驱动
Exception in thread "main" java.sql.SQLException: No suitable driver found for jdbc:sqlite:sample.db@b@ at java.sql.DriverManager.getConnection(DriverManager.java:689)@b@ at java.sql.DriverManager.getConnection(DriverManager.java:270)@b@ at com.xwood.demo.db.SQLiteDemo.main(SQLiteDemo.java:21)
二、解决方法
如下图打开ideal的project settings(File - Project Structure...),如下图,选择“Modules” - "Dependencies"依赖包,点击+并选择“JARs or directories.”, 并指向sqLite依赖包具体位置地址(下载解压版本SqlStudio包,并选择sqlstudio_win_1.0.3/sqlstudio/lib/sqlite-jdbc-3.39.3.0.jar位置)