
Possible JDBC Issue - no such column - Unreproducible in other languages
aurorapar opened this issue ยท 1 comments
I keep getting the same exception, java.sql.SQLException: no such column:
, despite being able to run the same query from a Python interpreter on the same database and the result is as expected and no exception is thrown.
[00:23:18] [Netty Local Client IO #1/INFO] [ne.mi.ne.NetworkHooks/]: Connected to a modded server.
[00:23:18] [Server thread/INFO] [ne.sp.co.CommunityRpg/]:
[00:23:18] [Server thread/INFO] [ne.sp.co.CommunityRpg/]: CREATE TABLE PlayerXp (PlayerKey TEXT PRIMARY KEY, RpgClassXp INTEGER, RpgRaceId INTEGER, RpgClassId INTEGER, FOREIGN KEY(RpgRaceId) REFERENCES RpgRace(RpgRaceId), FOREIGN KEY(RpgClassId) REFERENCES RpgClass(RpgClassId))
[00:23:18] [Server thread/ERROR] [ne.sp.co.CommunityRpg/]:
Player exists statement failed
SELECT 1 FROM PlayerXp WHERE PlayerKey='380df991-f603-344c-a090-369bad2a924a'
java.sql.SQLException: no such column: 'PlayerKey'
at TRANSFORMER/[email protected]+20211227/org.sqlite.jdbc3.JDBC3ResultSet.findColumn(JDBC3ResultSet.java:49)
at TRANSFORMER/[email protected]+20211227/org.sqlite.jdbc3.JDBC3ResultSet.getString(JDBC3ResultSet.java:446)
at TRANSFORMER/[email protected]/net.spawningpool.communityrpg.custom.sql.SqlEvents.PlayerEntryExists(SqlEvents.java:50)
at TRANSFORMER/[email protected]/net.spawningpool.communityrpg.custom.sql.SqlEvents.CreatePlayer(SqlEvents.java:18)
at TRANSFORMER/[email protected]/net.spawningpool.communityrpg.event.ModClientEvents$ClientForgeEvents.LoadFromFile(ModClientEvents.java:38)
at TRANSFORMER/[email protected]/net.spawningpool.communityrpg.event.__ClientForgeEvents_LoadFromFile_LoadFromFile.invoke(.dynamic)
at MC-BOOTSTRAP/net.minecraftforge.eventbus/net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:73)
at MC-BOOTSTRAP/net.minecraftforge.eventbus/net.minecraftforge.eventbus.EventBus.post(EventBus.java:315)
at MC-BOOTSTRAP/net.minecraftforge.eventbus/net.minecraftforge.eventbus.EventBus.post(EventBus.java:296)
at TRANSFORMER/[email protected]/net.minecraftforge.event.ForgeEventFactory.firePlayerLoadingEvent(ForgeEventFactory.java:422)
at TRANSFORMER/[email protected]/net.minecraft.server.players.PlayerList.load(PlayerList.java:326)
at TRANSFORMER/[email protected]/net.minecraft.server.players.PlayerList.placeNewPlayer(PlayerList.java:158)
at TRANSFORMER/[email protected]/net.minecraft.server.network.ServerLoginPacketListenerImpl.placeNewPlayer(ServerLoginPacketListenerImpl.java:140)
at TRANSFORMER/[email protected]/net.minecraft.server.network.ServerLoginPacketListenerImpl.handleAcceptedLogin(ServerLoginPacketListenerImpl.java:127)
at TRANSFORMER/[email protected]/net.minecraft.server.network.ServerLoginPacketListenerImpl.tick(ServerLoginPacketListenerImpl.java:71)
at TRANSFORMER/[email protected]/net.minecraft.network.Connection.tick(Connection.java:289)
at TRANSFORMER/[email protected]/net.minecraft.server.network.ServerConnectionListener.tick(ServerConnectionListener.java:159)
at TRANSFORMER/[email protected]/net.minecraft.server.MinecraftServer.tickChildren(MinecraftServer.java:950)
at TRANSFORMER/[email protected]/net.minecraft.server.MinecraftServer.tickServer(MinecraftServer.java:857)
at TRANSFORMER/[email protected]/net.minecraft.client.server.IntegratedServer.tickServer(IntegratedServer.java:95)
at TRANSFORMER/[email protected]/net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:679)
at TRANSFORMER/[email protected]/net.minecraft.server.MinecraftServer.lambda$spin$2(MinecraftServer.java:251)
at java.base/java.lang.Thread.run(Thread.java:1583)
[00:23:18] [Server thread/INFO] [ne.sp.co.CommunityRpg/]:
Creating entry for player 380df991-f603-344c-a090-369bad2a924a
[00:23:18] [Server thread/ERROR] [ne.sp.co.CommunityRpg/]:
Player create statement failed
INSERT INTO PlayerXp (PlayerKey, RpgClassXp) VALUES ('380df991-f603-344c-a090-369bad2a924a', 0)
org.sqlite.SQLiteException: [SQLITE_CONSTRAINT_PRIMARYKEY] A PRIMARY KEY constraint failed (UNIQUE constraint failed: PlayerXp.PlayerKey)
[00:23:18] [Server thread/INFO] [minecraft/PlayerList]: Dev[local:E:5aafc61e] logged in with entity id 404 at (17.284945175298816, 96.0, 0.30000001192092896)
>>> conn = sqlite3.connect('sample.db')
>>> cursor = conn.cursor()
>>> print(cursor.execute("SELECT 1 FROM PlayerXp WHERE PlayerKey='380df991-f603-344c-a090-369bad2a924a'").fetchall())
[(1,)]
>>> conn.close()
>>>
The code that I am using to generate the tables and perform the query, as well as an attempted insert, is viewable here https://gist.github.com/aurorapar/84a71cf81e9c94d96c9fca69f804d984
SqlEvents#CreatePlayer
is called by a hooked PlayerEvent#LoadFromFile
method.