简体   繁体   English

java jdbc:sqlite没有合适的驱动程序。 我认为类路径问题

[英]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: 这是我尝试过的:

  1. put the .jar in the same directory as my compiled program main stuff 将.jar放在与我编译的程序主要内容相同的目录中
  2. put the .jar in the same directory as my compiled class that uses the sql stuff 把.jar放在与我使用sql东西的编译类相同的目录中
  3. tried using the -classpath option when calling java from the terminal. 从终端调用java时尝试使用-classpath选项。 I tried this with relative addressing first, then an absolute path 我首先尝试相对寻址,然后是绝对路径
  4. 3 but with wildcards, ie .../*.jar 3但是带有通配符,即...... / * .jar
  5. sudo gedit /etc/environment. sudo gedit / etc / environment。 there was no CLASSPATH so i put this in: CLASSPATH=" .jar:/home/sheena/Java/lib/ .jar:.:.*.jar:/home/sheena/Java/lib/" 没有CLASSPATH所以我把它放在:CLASSPATH =“。 jar:/ home / sheena / Java / lib / .jar:。:。*。jar:/ home / sheena / Java / lib /”

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.

相关问题 没有找到适合 jdbc:sqlite 的驱动程序 - No suitable driver found for jdbc:sqlite java.sql.SQLException:找不到适用于jdbc:sqlite的驱动程序 - java.sql.SQLException: No suitable driver found for jdbc:sqlite Java JDBC - 找不到合适的驱动程序 - Java JDBC - No suitable Driver found 在java中没有为jdbc找到合适的驱动程序 - No suitable driver found for jdbc in java java.sql.SQLException:找不到适用于jdbc的驱动程序:sqlserver已尝试使用类路径 - java.sql.SQLException: No suitable driver found for jdbc:sqlserver tried classpath already 在使用maven连接到内存中SQLite的Java应用程序中找不到“ jdbc:sqlite:myDB.sqlite”的合适驱动程序 - No suitable driver found for “jdbc:sqlite:myDB.sqlite” with java application using maven to connect to in-memory SQLite Netbeans中的SQLite JDBC:找不到合适的驱动程序 - JDBC for SQLite in Netbeans: No suitable driver found 找不到适合 jdbc:sqlite (IntelliJ) 的驱动程序 - No suitable driver found for jdbc:sqlite (IntelliJ) 在应用图像上找不到适用于 jdbc:sqlite 的驱动程序 - No suitable driver found for jdbc:sqlite on app image java.sql.SQLException:找不到适用于jdbc:sqlite:db / Fakturi.sqlite的驱动程序 - java.sql.SQLException: No suitable driver found for jdbc:sqlite:db/Fakturi.sqlite
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM