我有一个statement.executeQuery的问题。每次我打电话给我都会得到一个空指针异常,我真的不知道问题是什么。
这是我的GitHub Rep上的一行 GitHub Rep
这是Stacktrace
[21:16:53 INFO]:Xearox发出服务器命令:/ ecweb register Xearox 12345 org.bukkit.command.CommandException:插件xConomy v0.0.1中执行命令'ecweb'的未处理异常 在org.bukkit.command.PluginCommand.execute(PluginCommand.java:46)〜[spigot-1.8.8.jar:git-Spigot-5f38d38-18fbb24] 在org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141)〜[spigot-1.8.8.jar:git-Spigot-5f38d38-18fbb24] 在org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641)~ [spigot-1.8.8.jar:git-Spigot-5f38d38-18fbb24] 在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 $ 1.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] 在java.lang.Thread.run(未知来源)[?:1.7.0_79] 引起:java.lang.NullPointerException 在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)〜[?:?] 在de.xearox.xconomy.XConomy.onCommand(XConomy.java:241)〜[?:?] 在org.bukkit.command.PluginCommand.execute(PluginCommand.java:44)〜[spigot-1.8.8.jar:git-Spigot-5f38d38-18fbb24] ......还有15个
创建数据库表工作正常。
也许你可以帮助我在这里我真的不知道我在这里做错了什么:/
谢谢
答案 0 :(得分:1)
空指针异常意味着返回null。添加空检查
if(!sql == null){
//Not null
statement.executeUpdate(sql);
}
else{//Its null do whatever}