Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sqlite/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java SQLite JDBC驱动程序在Win7和Ubuntu中不工作_Java_Sqlite_Netbeans_Jar - Fatal编程技术网

Java SQLite JDBC驱动程序在Win7和Ubuntu中不工作

Java SQLite JDBC驱动程序在Win7和Ubuntu中不工作,java,sqlite,netbeans,jar,Java,Sqlite,Netbeans,Jar,我正试图为我的项目构建一个包含所有其他库(数据库驱动程序等)的jar文件。构建过程运行良好,我能够创建jar。我正在使用Netbeans IDE实现同样的功能 我的问题: 当我在Windows7或Ubuntu中双击jar文件直接运行该文件时,jdbc(sqlite)驱动程序无法工作。虽然当我从命令行使用 java-jarmyproject.jar,它运行良好。在Windows8和Mac操作系统中,通过双击,它也可以正常工作 下面是build.xml中用于制作单个jar的部分: <targe

我正试图为我的项目构建一个包含所有其他库(数据库驱动程序等)的jar文件。构建过程运行良好,我能够创建jar。我正在使用Netbeans IDE实现同样的功能

我的问题: 当我在Windows7或Ubuntu中双击jar文件直接运行该文件时,jdbc(sqlite)驱动程序无法工作。虽然当我从命令行使用
java-jarmyproject.jar
,它运行良好。在Windows8和Mac操作系统中,通过双击,它也可以正常工作

下面是build.xml中用于制作单个jar的部分:

<target name="-post-jar">
<property name="store.jar.name" value="myproject"/>
<property name="store.dir" value="dist"/>
<property name="store.jar" value="${store.dir}/${store.jar.name}.jar"/>
<echo message="Packaging ${application.title} into a single JAR at ${store.jar}"/>
<jar destfile="${store.dir}/temp_final.jar" filesetmanifest="skip">
    <zipgroupfileset dir="dist" includes="*.jar"/>
    <zipgroupfileset dir="dist/lib" includes="*.jar"/>
    <manifest>
        <attribute name="Main-Class" value="${main.class}"/>
    </manifest>
</jar>
<zip destfile="${store.jar}">
    <zipfileset src="${store.dir}/temp_final.jar"
    excludes="META-INF/*.SF, META-INF/*.DSA, META-INF/*.RSA"/>
</zip>
<delete file="${store.dir}/temp_final.jar"/>
</target>
ErrorLog类将错误写入文件。 另外请注意,此部分位于try-catch块中。在catch块中,我再次使用ErrorLog写入文件


我已将数据库文件与jar文件放在同一文件夹中。

“当我通过双击直接运行jar文件时,jdbc(sqlite)驱动程序无法工作。”
什么不起作用?我的应用程序中有一个表,在应用程序启动时从数据库中填充。因此,如果我直接运行jar,该表是空的。您是否尝试在数据库写入之前和之后放置print语句?当你双击罐子时,到底发生了什么?我怀疑它是否被执行。是的,我试过这么做。我的连接已经建立好了。它们是一样的。我试图通过将语句打印到错误日志文件来解决这个问题。
“当我双击jar文件直接运行它时,jdbc(sqlite)驱动程序不工作。”
什么不起作用?我的应用程序中有一个表,在应用程序启动时从数据库中填充。因此,如果我直接运行jar,该表是空的。您是否尝试在数据库写入之前和之后放置print语句?当你双击罐子时,到底发生了什么?我怀疑它是否被执行。是的,我试过这么做。我的连接已经建立好了。它们是一样的。我正试图通过将语句打印到错误日志文件来解决这个问题。
        Class.forName("org.sqlite.JDBC");            
        SQLiteConfig config = new SQLiteConfig();  
        config.enforceForeignKeys(true);  
        System.out.println(config.toProperties());
        ErrorLog.write_to_file("fetching connection");            
        Connection conn = DriverManager.getConnection("jdbc:sqlite:Data.db",config.toProperties());
        Statement stmt=conn.createStatement();
        ErrorLog.write_to_file("connected");