statement.executeQuery 中的 NAME

NPE in statement.executeQuery

我对 statement.executeQuery 有疑问。每次我调用它时,我都会得到一个空指针异常,我真的不知道问题出在哪里。

这是我的 GitHub 代表的台词 GitHub Rep

这是 Stacktrace

[21:16:53 INFO]: Xearox issued server command: /ecweb register Xearox 12345 org.bukkit.command.CommandException: Unhandled exception executing command 'ecweb' in plugin xConomy v0.0.1 at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spigot-1.8.8.jar:git-Spigot-5f38d38-18fbb24] at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.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] at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:997) [spigot-1.8.8.jar:git-Spigot-5f38d38-18fbb24] at 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.jar:git-Spigot-5f38d38-18fbb24] at net.minecraft.server.v1_8_R3.PlayerConnectionUtils.run(SourceFile:13) [spigot-1.8.8.jar:git-Spigot-5f38d38-18fbb24] at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.7.0_79] at java.util.concurrent.FutureTask.run(Unknown Source) [?: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] Caused by: java.lang.NullPointerException at org.sqlite.Stmt.executeUpdate(Stmt.java:152) ~[spigot-1.8.8.jar:git-Spigot-5f38d38-18fbb24] at de.xearox.xconomy.utility.Database.createNewPlayer(Database.java:95) ~[?:?] at 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 more

正在创建数据库 table 工作正常。

也许你可以帮我解决这个问题我真的不知道我做错了什么:/

谢谢

空指针异常意味着返回空值。添加空检查

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