java.sql.SQLException: Opening db:'DB-NAME.sqlite' : Permission denied

余生长醉 提交于 2019-12-13 02:36:19

问题


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.

I had packaged it by following instruction in this link

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.

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"

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

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

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

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

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.


回答1:


Change this jdbc:sqlite:JavaApp3DB.sqlite to this jdbc:sqlite:JavaApp3DB.db

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.



来源:https://stackoverflow.com/questions/46237315/java-sql-sqlexception-opening-dbdb-name-sqlite-permission-denied

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!