Code: 14:14:54 [INFO] [iZone : 6.6] Error at SQL INSERT Query: java.sql.SQLExce [SQLITE_ERROR] SQL error or missing database (near "flag": syntax error) What does that error mean? Sorry, i'm new to SQL stuff.
Code: public iZone plugin; public String dbLocation; public String dbName; private DatabaseHandler manageDB; public sqlCore(iZone instance, String dbName, String dbLocation) { this.plugin = instance; this.dbName = dbName; this.dbLocation = dbLocation; } public Boolean initialize() { File dbFolder = new File(dbLocation); if (dbName.contains("/") || dbName.contains("\\") || dbName.endsWith(".db")) { this.writeError("The database name can not contain: /, \\, or .db", true); return false; } if (!dbFolder.exists()) { dbFolder.mkdir(); } File SQLFile = new File(dbFolder.getAbsolutePath() + "/" + dbName); this.manageDB = new DatabaseHandler(this, SQLFile); return this.manageDB.initialize(); } This is the this.manageDB.initialize(); method: Code: public Boolean initialize() { try { Class.forName("org.sqlite.JDBC"); connection = DriverManager.getConnection("jdbc:sqlite:" + SQLFile.getAbsolutePath()); return true; } catch (SQLException ex) { core.writeError("SQLite exception on initialize " + ex, true); } catch (ClassNotFoundException ex) { core.writeError("You need the SQLite library " + ex, true); } return false; }
Your error means that the database you're trying to access does not exist or there is an error with your statement. Post your query and I'll check it
Your loading the database file, not the database itself. Create a database first. Hmm look at https://github.com/Hretsam/ThunderG...sam/thunderghast/handlers/SqlLiteManager.java Its an old project of mine, but the SQLLite manager might give you some insight how it works.
Code: String flags = "protection BOOL,pvp BOOL,monsters BOOL,animal BOOL,"; String query = "CREATE TABLE "+DB_Table+" (" + "name VARCHAR(32)," + "world VARCHAR(32)," + "welcome VARCHAR(50)," + "farewell VARCHAR(50)," + "mix INT, miy INT, miz INT," + "max INT, may INT, maz INT," + flags+"" + "allowed TEXT" + ");"; manageSQLite = new sqlCore(plug, DB_Name, dataFolder); manageSQLite.initialize(); try{ if(!manageSQLite.checkTable(DB_Table)){ manageSQLite.createTable(query); } }catch(Exception e){ e.printStackTrace(); }