2016-01-07 60 views
0

我有一個statement.executeQuery的問題。每次我調用這個函數,我都會得到一個空指針異常(Null Pointer Exception),我不知道問題是什麼。NPE in statement.executeQuery

這裏是我的GitHub衆議員 GitHub Rep

行這裏是堆棧跟蹤

[21時16分53秒INFO]:Xearox發出服務器命令:/ ecweb註冊Xearox 12345 組織.bukkit.command.CommandException:未處理的異常執行命令'ecweb'插件xConomy v0.0.1 at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46)〜[spigot-1.8.8.jar:git-承插式5f38d38-18fbb24] 在org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandM ap.java:141)〜[spigot-1.8.8.jar:git-Spigot-5f38d38-18fbb24] at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641)〜[spigot-1.8。 8.jar:git-Spigot-5f38d38-18fbb24] at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1162)[spigot-1.8.8.jar:git-Spigot-5f38d38-18fbb24] 在net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:997)[插口1.8.8.jar:GIT-插口5f38d38-18fbb24] 在net.minecraft.server.v1_8_R3.PacketPlayInChat.a( PacketPlayInChat.java:45)[spigot-1.8.8.jar:git-Spigot-5f38d38-18fbb24] at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:1)[spigot-1.8.8。罐子:GIT-插口5f38d38-18fbb24] 在net.minecraft.server.v1_8_R3.PlayerConnectionUtils $ 1.run(的SourceFile:13)[插口1.8.8.jar:GIT-SP IGOT-5f38d38-18fbb24] 在java.util.concurrent.Executors $ RunnableAdapter.call(未知來源):1.7.0_79] 在java.util.concurrent.FutureTask.run(來源不明):1.7。 0_79] at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44)[spigot-1.8.8.jar:git-Spigot-5f38d38-18fbb24] at net.minecraft.server.v1_8_R3.MinecraftServer.B (MinecraftServer.java:715)[spigot-1.8.8.jar:git-Spigot-5f38d38-18fbb24] at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374)[spigot-1.8.8 .jar:git-Spigot-5f38d38-18fbb24] at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654)[spigot-1.8.8.jar:git-Spigot-5f38d38-18fbb24] at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557)[spigot-1.8.8.jar:git-Spigot-5f38d38- 18fbb24] at java.lang.Thread.run(Unknown Source)[?:1.7.0_79] 由org.sqlite.Stmt.executeUpdate(Stmt.java:152)〜[spigot]導致:java.lang.NullPointerException -1.8.8.jar:GIT-插口5f38d38-18fbb24] 在de.xearox.xconomy.utility.Database.createNewPlayer(Database.java:95)〜[:?] 在de.xearox.xconomy.XConomy .onCommand(XConomy.java:241)〜[?:?] at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44)〜[spigot-1.8.8.jar:git-Spigot-5f38d38-18fbb24 ] ... 15更多

數據庫表的創建工作正常。

也許你能幫助我在這裏,我真的不知道我錯在這裏做的:/

謝謝

+1

郵政代碼在這裏,而不是添加一個空檢查你的問題,但您的查詢是不正確的:在*值*也需要逗號在'VALUES分離('‘+ UUID + playerName +用戶名+密碼+’ ');' –

+0

使用PreparedStatement而不是普通的Statement。 – 11thdimension

回答

1

一個空指針異常意味着什麼時返回null。

if(!sql == null){ 
    //Not null 
    statement.executeUpdate(sql); 
} 
else{//Its null do whatever}