无法在mac(权限)问题上创建SQLite数据库

时间:2014-05-20 16:10:06

标签: java macos sqlite permissions file-permissions

我正在尝试将应用程序文件夹添加到Mac上的 Application Support 文件夹中。它工作,但我不能写到该文件夹​​。当我对我得到的文件夹ls -l drwxr-xr-x时,db,但由于某种原因,我无法在那里创建String OS = (System.getProperty("os.name")).toUpperCase(); String location; if(OS.contains("WIN")){ location = "/" + System.getenv("APPDATA").replace("\\", "/") + "/Phantom"; }else{ location = System.getProperty("user.home"); location += "/Library/Application Support/Phantom"; } File f = new File(location); if(!f.isDirectory()){ f.mkdir(); } Class.forName("org.sqlite.JDBC"); conn = DriverManager.getConnection("jdbc:sqlite:" + location + "/phantom.db"); 文件。

Exception in Application start method
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:367)
        at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:305)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:483)
        at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: Exception in Application start method
        at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:894)
        at com.sun.javafx.application.LauncherImpl.access$000(LauncherImpl.java:56)
        at com.sun.javafx.application.LauncherImpl$1.run(LauncherImpl.java:158)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NoClassDefFoundError: org/sqlite/NativeDB
        at java.lang.ClassLoader$NativeLibrary.load(Native Method)
        at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1929)
        at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1814)
        at java.lang.Runtime.load0(Runtime.java:809)
        at java.lang.System.load(System.java:1083)
        at org.sqlite.SQLiteJDBCLoader.loadNativeLibrary(SQLiteJDBCLoader.java:200)
        at org.sqlite.SQLiteJDBCLoader.extractAndLoadLibraryFile(SQLiteJDBCLoader.java:148)
        at org.sqlite.SQLiteJDBCLoader.loadSQLiteNativeLibrary(SQLiteJDBCLoader.java:249)
        at org.sqlite.SQLiteJDBCLoader.initialize(SQLiteJDBCLoader.java:65)
        at org.sqlite.core.NativeDB.load(NativeDB.java:53)
        at org.sqlite.core.CoreConnection.open(CoreConnection.java:136)
        at org.sqlite.core.CoreConnection.<init>(CoreConnection.java:66)
        at org.sqlite.jdbc3.JDBC3Connection.<init>(JDBC3Connection.java:21)
        at org.sqlite.jdbc4.JDBC4Connection.<init>(JDBC4Connection.java:23)
        at org.sqlite.SQLiteConnection.<init>(SQLiteConnection.java:44)
        at org.sqlite.JDBC.createConnection(JDBC.java:113)
        at org.sqlite.JDBC.connect(JDBC.java:87)
        at java.sql.DriverManager.getConnection(DriverManager.java:664)
        at java.sql.DriverManager.getConnection(DriverManager.java:270)
        at phantom.SQLite.connect(SQLite.java:46)
        at phantom.SQLite.getUsers(SQLite.java:123)
        at phantom.Browser.loadCustomPage(Browser.java:194)
        at phantom.Main.start(Main.java:29)
        at com.sun.javafx.application.LauncherImpl$8.run(LauncherImpl.java:837)
        at com.sun.javafx.application.PlatformImpl$7.run(PlatformImpl.java:335)
        at com.sun.javafx.application.PlatformImpl$6$1.run(PlatformImpl.java:301)
        at com.sun.javafx.application.PlatformImpl$6$1.run(PlatformImpl.java:298)
        at java.security.AccessController.doPrivileged(Native Method)
        at com.sun.javafx.application.PlatformImpl$6.run(PlatformImpl.java:298)
        at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
Caused by: java.lang.ClassNotFoundException: org.sqlite.NativeDB
        at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 30 more
Exception running application phantom.Main

首先,这是在mac上存储此信息的正确位置吗?假设是这样,我该怎么做才能有效呢?

编辑跟踪:

{{1}}

1 个答案:

答案 0 :(得分:0)

您的堆栈跟踪显示......

NoClassDefFoundError: org/sqlite/NativeDB

我认为您可能已经下载了错误的jar,其中嵌入了错误的本机库。尝试一个here并遵循OSX指示(仅关于设置类路径)。