java.sql.SQLException:正在打开db:"DB-NAME.sqlite":权限被拒绝 [英] java.sql.SQLException: Opening db:'DB-NAME.sqlite' : Permission denied

查看:270
本文介绍了java.sql.SQLException:正在打开db:"DB-NAME.sqlite":权限被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Ubuntu14上使用Netbeans IDE 8.2开发了一个Java应用程序项目.如何使用Netbeans IDE(.deb)本机打包为Linux系统安装安装程序.

I had developed a Java Application Project using Netbeans IDE 8.2 on Ubuntu14. How can I have its installers for Linux Systems using Netbeans IDE(.deb) Native Packaging.

我已经按照链接

但是,教程是Windows中的NetBeans 7.4本机打包.但是我在Ubuntu(我的系统)的Netbeans8.2中遵循了本教程.而且我在上述教程的指定文件夹中获得了.deb文件.

But, this tutorial above mentioned is NetBeans 7.4 native packaging in Windows. But I followed this tutorial in Netbeans8.2 in Ubuntu(my system). And I got .deb file in specified folder in the tutorial mentioned above.

Project-name-1.0.deb文件可以成功安装在我的Ubuntu系统中,但是在运行此已安装的应用程序时,它显示错误:"java.sql.SQLException:打开db:'DB-NAME.sqlite':权限否认"

The Project-name-1.0.deb file could be successfully installed in my Ubuntu System, but while running this installed application it shows error: "java.sql.SQLException: Opening db:'DB-NAME.sqlite' : Permission denied"

我的项目使用sqlite DB进行数据存储.我已经将JAR sqlite-JDBC-3.19.3.jar用于其库.

My project uses sqlite DB for data storage. I had used JAR sqlite-JDBC-3.19.3.jar for its Library.

我曾在Ubuntu中使用过Netbeans IDE 8.2,并在其中创建了新的Java应用程序项目.

I had used Netbeans IDE 8.2 in Ubuntu and created the new Java Application Project in it.

现在,如何打包此Java应用程序项目以获取Linux(.deb)的安装程序,而不会出现此权限被拒绝的错误

Now, how can I package this Java Application project to get its installer for Linux(.deb) without this Permission denied error

java Connect.java类如下

The java Connect.java class is as follows

import java.sql.*;

import javax.swing.JOptionPane;

public class Connect {

    Connection con = null;
    Statement stmt = null;

    public static Statement ConnectDB() {
        try {
            Connection conn = null;
            Statement stmt = null;

            Class.forName("org.sqlite.JDBC");
            conn = DriverManager.getConnection("jdbc:sqlite:JavaApp3DB.sqlite");

            stmt = conn.createStatement();

            return stmt;
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, e);
        }
        return null;
    }
}

应用程序在NetBeans中成功执行,没有任何权限被拒绝的错误.但是,当在Ubuntu中安装并执行打包(.deb)安装程序时,它会显示错误.

The application execute successfully in NetBeans without any permission denied error. But, it shows the error when the Packaged (.deb) installer when installed and executed in Ubuntu.

推荐答案

更改此jdbc:sqlite:JavaApp3DB.sqlite 对此jdbc:sqlite:JavaApp3DB.db

当您要连接到数据库时,需要一个地址,这个地址在文件中提到,我们称为database.db而不是.sqlite.

When you want to connect to your database you need an address and this address mention to a file we call database.db not .sqlite.

这篇关于java.sql.SQLException:正在打开db:"DB-NAME.sqlite":权限被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆