首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >对于使用maven连接到内存中SQLite的java应用程序,找不到适用于"jdbc:sqlite:myDB.sqlite“的驱动程序

对于使用maven连接到内存中SQLite的java应用程序,找不到适用于"jdbc:sqlite:myDB.sqlite“的驱动程序
EN

Stack Overflow用户
提问于 2018-10-05 04:49:57
回答 1查看 868关注 0票数 0

当我运行该程序时,我得到以下错误:

谢谢!

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);
        }
    }
}
}

我的文件依赖关系是:

  <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>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <version>2.4</version>
            <configuration>
                <archive>
                    <manifest>
                        <mainClass>path-to-mainclass-Application</mainClass>
                    </manifest>
                </archive>
            </configuration>
        </plugin>
    </plugins>
</build>

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52654954

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档