未找到Derby嵌入式数据库'APPDATA'文件夹,尝试创建OS X应用程序.app [英] Derby embedded database 'APPDATA' folder not found, Trying to create OS X application .app

查看:221
本文介绍了未找到Derby嵌入式数据库'APPDATA'文件夹,尝试创建OS X应用程序.app的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从java desktopos.jar创建一个Mac OS X应用程序,其中我的应用程序.jar文件使用derby嵌入式数据库APPDATA。当我正在创建Mac OS X应用程序时会产生问题.app

I am trying to create a Mac OS X application from java desktopos.jar, where my application .jar file using derby embedded database APPDATA. It creates problem when, I'm createing a Mac OS X application .app

这是我在java上的连接方法(已经在.exe和setup-Windows& Linux)

Here is my connection method on java(Already working on .exe and setup-Windows & Linux)

public static Connection getdataconnet() {
        Connection connect = null;
        try {
            Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
            connect = DriverManager.getConnection("jdbc:derby:APPDATA", "xxxx", "xxxxxxxxxxxxxxx");
         } catch (ClassNotFoundException ex) {
            globalData.GlobalDataSetGet.OLD_USER = -1;
            ////JOptionPane.showMessageDialog(null, "1"+ex);
        } catch (SQLException ex) {
            globalData.GlobalDataSetGet.OLD_USER = -1;
            ////JOptionPane.showMessageDialog(null, "2"+ex);
        }
        return connect;
    }

Mac OS X应用程序架构.app

创建Mac OS X应用程序后,.jar找不到APPDATA .app

使用CWD ..

Connection connect = null;
    Path currentRelativePath = Paths.get("");
    String s = currentRelativePath.toAbsolutePath().toString();
    try {//DriverManager.getConnection("jdbc:derby:"+System.getProperty("user.dir")+"/APPDATA", "#####", "#############");
       connect = DriverManager.getConnection("jdbc:derby:"+s+"/APPDATA", "#####", "#############");

    } catch (ClassNotFoundException ex) {
        globalData.GlobalDataSetGet.OLD_USER = -1;
        JOptionPane.showMessageDialog(null, "1"+ex);
    } catch (SQLException ex) {
        globalData.GlobalDataSetGet.OLD_USER = -1;
        JOptionPane.showMessageDialog(null, "2"+ex);
    }


需要开发者帮助,谢谢!

Need dev help,Thanks!

推荐答案

JDBC连接URL jdbc:derby:APPDATA 表示在应用程序的当前工作目录(CWD)中查找名为APPDATA的文件夹。

The JDBC Connection URL jdbc:derby:APPDATA says to look for the folder named APPDATA in the current working directory (CWD) of your application.

你需要弄清楚推出应用程序时你的CWD是什么,也许是通过查看这个问题的答案:使用Java获取当前工作目录

You need to figure out what your CWD is when your app is launched, perhaps by looking at the answers to this question: Getting the Current Working Directory in Java

然后


  1. 安排让您的CWD成为存储APPDATA的地方,或

  2. 允许用户告诉您的应用存储APPDATA的位置并将其放入您的JDBC连接URL。

这篇关于未找到Derby嵌入式数据库'APPDATA'文件夹,尝试创建OS X应用程序.app的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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