第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

沒有找到適合“jdbc:sqlite:myDB.sqlite”的驅(qū)動程序

沒有找到適合“jdbc:sqlite:myDB.sqlite”的驅(qū)動程序

富國滬深 2021-10-28 09:14:21
我正在嘗試編寫一個 java 應(yīng)用程序以使用 maven 連接到內(nèi)存中的 sqlite db。我也向 pom.xml 文件添加了 SQLite 依賴項。當(dāng)我運行程序時,我收到錯誤:“java.lang.ClassNotFoundException: org.sqlite.JDBC”和“沒有找到適合 jdbc:sqlite:myDB.sqlite 的驅(qū)動程序”。請讓我知道我是否遺漏了什么。謝謝你!public class Application {  public static void main(String[] args) throws  ClassNotFoundException{    System.out.println("Application class created\n");    Connection connection = null;    try {        Class.forName("org.sqlite.JDBC");    }catch (ClassNotFoundException e){        System.err.println("Class not found"+e);    }    try{        connection = DriverManager.getConnection("jdbc:sqlite::memory:");        Statement statement = connection.createStatement();        statement.setQueryTimeout(33);        statement.executeUpdate("create table demo (id integer, name string)");        statement.executeUpdate("insert into demo(1, 'A')");        ResultSet mySet = statement.executeQuery("select * from demo");        while(mySet.next()){            System.out.println("Name is : "+mySet.getString("name"));            System.out.println("Id is : "+mySet.getInt("id"));        }    }    catch (SQLException sqlException){        System.err.println(sqlException.getMessage());    }    finally {        try{            if(connection!=null)                connection.close();        }        catch (SQLException sqlException){            System.err.println(sqlException);        }    }}}我的 POM 文件依賴是:  <properties>    <maven.compiler.source>1.8</maven.compiler.source>    <maven.compiler.target>1.8</maven.compiler.target></properties><!-- https://mvnrepository.com/artifact/org.xerial/sqlite-jdbc --><dependencies>    <!-- https://mvnrepository.com/artifact/org.hibernate/hibernate-core -->    <dependency>        <groupId>org.xerial</groupId>        <artifactId>sqlite-jdbc</artifactId>        <version>3.23.1</version>    </dependency>
查看完整描述

1 回答

?
牧羊人nacy

TA貢獻1862條經(jīng)驗 獲得超7個贊

刪除 maven-jar-plugin


并使用此插件生成包含所有依賴項的 jar,并運行 jar-with-dependencies


<plugin>

    <groupId>org.apache.maven.plugins</groupId>

    <artifactId>maven-assembly-plugin</artifactId>

    <executions>

        <execution>

            <phase>package</phase>

            <goals>

                <goal>single</goal>

            </goals>

            <configuration>

                <archive>

                    <manifest>

                        <mainClass>

                            your.main.Class

                        </mainClass>

                    </manifest>

                </archive>

                <descriptorRefs>

                    <descriptorRef>jar-with-dependencies</descriptorRef>

                </descriptorRefs>

            </configuration>

        </execution>

    </executions>

</plugin>


查看完整回答
反對 回復(fù) 2021-10-28
  • 1 回答
  • 0 關(guān)注
  • 168 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號