[英]java jdbc:sqlite no suitable driver. classpath issues i think
I'm running ubuntu. 我正在运行ubuntu。 I installed sqlite3 and java via the synaptic package manager, and downloaded the sqlitejdbc-v056 jar.
我通过synaptic包管理器安装了sqlite3和java,并下载了sqlitejdbc-v056 jar。
My sqlite is working fine. 我的sqlite工作正常。 I've written some java code that compiles, but wont run.
我写了一些编译的java代码,但不会运行。 I used ant to compile the stuff and that worked fine once i put the jar in the same place as build.xml.
我使用ant来编译这些东西,一旦我将jar放在与build.xml相同的位置,它就能正常工作。
When i try to run the program (by saying java program) it says: java.sql.SQLException: No suitable driver found for jdbc:sqlite:test.db 当我尝试运行该程序时(通过说java程序),它说:java.sql.SQLException:没有为jdbc找到合适的驱动程序:sqlite:test.db
here's some of the offending code: 这是一些有问题的代码:
Class.forName("org.sqlite.JDBC");
Connection conn = DriverManager.getConnection("jdbc:sqlite:test.db");
From what I've read thus far it's probably a problem with my classpath, i'm not really sure how to fix it though. 从我到目前为止所读到的内容来看,我的类路径可能存在问题,但我不确定如何修复它。 here's what i've tried:
这是我尝试过的:
I feel like i'm out of options. 我觉得我没有选择。
on a separate but related note, i also really struggled to get javac to see the jar while i was compiling, i couldn't get the ant stuff about the classpath right either. 在一个单独但相关的说明中,我也非常努力让javac在我编译时看到jar,我也无法获得关于类路径的蚂蚁内容。 This part isn't as urgent as the stuff above but here's a little bit of build.xml:
这部分并不像上面的内容那么紧急,但这里有一点build.xml:
<path id="files-classpath">
<fileset dir="lib/" >
<include name="*.jar"/>
</fileset>
</path>
... ...
those are just some of the things i tried. 这些只是我试过的一些事情。
Any ideas would be much appreciated, the internet has surprisingly little info on this topic from what i can see... 任何想法都会非常感激,从我能看到的东西,互联网上关于这个话题的信息很少......
try running it like this: 尝试像这样运行它:
java -classpath ".:sqlite-jdbc-v056.jar" ProgramName
the ".:" is very important (i wasn't sure if your tried that or not from your description). “。:”非常重要(我不确定你是否尝试过你的描述)。 also i just guessed what the name of your .jar is, but obviously change it to reflect the actual name.
我也猜到了.jar的名字是什么,但显然要改变它以反映实际名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.