No suitable driver found (SQLite)

前端 未结 5 2043
夕颜
夕颜 2020-12-05 23:44

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 {           
           


        
5条回答
  •  没有蜡笔的小新
    2020-12-06 00:03

    There is something more than just Class.forName.

    In the case you did both things below: - Added the sqlite jar library to lib folder under your project, reference to it in the project build path. - Added Class.forName("org.sqlite.JDBC") statement. And the error message "No suit driver" still appear, its may caused by your database path. If you are using Windows: Instead of:

    DriverManager.getConnection("D:\\db\\my-db.sqlite").
    

    You should use:

    DriverManager.getConnection("jdbc:sqlite:D:\\db\\my-db.sqlite").
    

    The "jdbc:sqlite:" will do the trick.

    If you are using Linux, just change the seperator character: DriverManager.getConnection("jdbc:sqlite:/your/somepath/my-db.sqlite").

提交回复
热议问题