连接到SQLite数据库失败 [英] Connecting to SQLite Database Fails

查看:695
本文介绍了连接到SQLite数据库失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Java Applet中访问我的SQLite3数据库。当我运行我的代码连接到数据库时,我收到此错误找不到合适的驱动程序a.db ,我该如何解决?

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?

现在我不完全确定我确实安装了正确的驱动程序......我会告诉你我做了什么&你能告诉我还需要做些什么来让Eclipse IDE找到SQLitejdbc驱动程序:

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 :在Windows 7上,使用Eclipse Helios Java

  • 我在python&中创建了一个SQLite3数据库。我想在我的Java Applet中阅读它

  • 我从 http://www.zentus.com/sqlitejdbc/

  • 然后我复制了&将上述文件粘贴到路径C:\Program Files \ Java \ jre6 \lib& C:\Program Files\Java\jre6\lib\ext

  • 在Java Applet&中运行以下代码。得到一个文本引发的异常:没有为a.db找到合适的驱动程序

  • 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

任何信息都会非常有用。我是否需要将驱动程序导入Eclipse项目?

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

推荐答案

试试这个: -

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

这篇关于连接到SQLite数据库失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆