Connecting to SQLite Database Fails

寵の児 提交于 2019-12-31 03:41:30

问题


I am attempting to access my SQLite3 database in a Java Applet. When I run my code to connect to the database I get this error No suitable driver found for a.db, how can I fix it?

Now I am not entirely sure I have actually installed the correct driver...I will tell you what I have done & could you tell me what else I need to do to make Eclipse IDE find the SQLitejdbc driver:

  • BK info: On windows 7, using Eclipse Helios Java
  • I have a SQLite3 database created in python & I want to read it in my Java Applet
  • I have downloaded the file sqlitejdbc-V056.jar from http://www.zentus.com/sqlitejdbc/
  • Then I copied & pasted the above file to the paths C:\Program Files\Java\jre6\lib & C:\Program Files\Java\jre6\lib\ext
  • Run the following code in a Java Applet & get an exception thrown with the text: "No suitable driver found for a.db"
Class.forName("org.sqlite.JDBC");
Connection conn = DriverManager.getConnection("a.db"); // exception thrown here

Any information would be really helpful. Do I need to import the driver into my Eclipse project?


回答1:


Try this:-

Class.forName("org.sqlite.JDBC");
Connection conn = DriverManager.getConnection("jdbc:sqlite:a.db");


来源:https://stackoverflow.com/questions/4917855/connecting-to-sqlite-database-fails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!