I've been working on a plugin that uses SQLite to store information, and I keep getting the error: [SEVERE] java.sql.SQLExcetion: opening db: 'D:\PvP_KDR': Access is denied My code uses this line to connect: Code:java conn = DriverManager.getConnection(jdbc:sqlite:D:\\PvP_KDR"); This is the first time I've used SQLite, so I have no idea what I'm doing. How do I fix this?
That is not a database but a directory, hence why it denies access. I suggest using something among the lines of: Code: String dbPath = "jdbc:sqlite:" + plugin.getDir() + plugin.getSeparator() + "database.db"; this.con = DriverManager.getConnection(dbPath); What this does is the following, it creates a var holding the database path, which in this case would be plugins/[myplugin][/ or\ depending on system]database.db hope that helps!
Eclipse is giving me an error on both "plugin"s, saying it cannot be resolved. What should I do about that?
You need to make Plugin plugin a variable and initialize it. If this is in your main class just change them to "this"
I'm not quite sure how to initialize a Plugin variable, and since I'm in my main class, I tried replacing them with "this". Now it's giving me errors on "getDir()" and getSeparator()", saying that they're undefined for the type PvP_KDR (name of my main class). EDIT: I fixed the error on "getDir()" by changing it to "getDataFolder()", but I'm still trying to figure out how to fix the error on "getSeparator()".
Uhh woops, my mistake on those, the code I placed above comes right out of my own database driver system (really cool one, build it myself, doesn't even need you to know sql at all either ) But, getDir() returns getDataFolder() as you already figured out! And getSeperator() could actually be replaced with File.seperator as that is what it returns. Sorry for that inconvience I caused you there