sqllite java驱动,java.sql.SQLException:找不到适合jdbc:sqlite的驱动程序

My Java program (one of my very first) seems to be hanging at the following line of standard code:

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

Connection c = null;

Statement stmt = null;

c = DriverManager.getConnection("jdbc:sqlite:test.db");

c.setAutoCommit(false);

I'm recieving the following error:

java.sql.SQLException: No suitable driver found for jdbc:sqlite:test.db

However, when running the java application I'm providing the correct location of the jdbc driver (I think);

sudo java -cp ./jsoup-1.7.3.jar:./sqlite-jdbc-3.7.2.jar:.

any idea how to proceed?

thanks a million

解决方案

sudo java -cp ./jsoup-1.7.3.jar:./sqlite-jdbc-3.7.2.jar:.

any idea how to proceed? thanks a million

Yes. Two major problems I see. One, unless you have a very good reason, don't run your program with sudo. It could cause you major pain later if you do.

Second, your classpath doesn't look correct. jar files are located on it. The first part should be the path to search and the second the jars to search for.

java -cp ".:jsoup-1.7.3.jar:sqlite-jdbc-3.7.2.jar" ...

Finally, I assume you downloaded from sqlite here and jsoup here and have the jar files in your current directory and if it still isn't working you should check those files are correct.

$ sha1sum sqlite-jdbc-3.7.2.jar

cea9f7f8e6bcb580d953a8651fb8391640de0f85 sqlite-jdbc-3.7.2.jar

$ sha1sum jsoup-1.7.3.jar

ab1f22cadc2f8b514e55ba368f5128056fe304da jsoup-1.7.3.jar

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值