SQL Syntax Error

Discussion in 'Plugin Development' started by dlange, Nov 14, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    dlange

    I'm having some trouble with an SQL syntax error in my plugin. Before I start, i'm telling you that i'm not a beginner with SQL, and this is probably just a rookie mistake i've made without realising, BUT this is my update:
    Code:
    UPDATE mutes SET muter='" + staff + "', SET duration='1', SET perm='1', SET time='" + System.currentTimeMillis() + "', SET reason='" + reason + "' WHERE uuid='" + p.getUniqueId().toString() + "';
    I used the same code for when i update mutes for temp which is this:
    Code:
    UPDATE mutes SET muter='" + staff + "', SET duration='" + duration + "', SET time='" + System.currentTimeMillis() + "', SET reason='" + reason + "' WHERE uuid='" + p.getUniqueId().toString() + "';
    The only difference i can see is setting perm to 1 (true) and duration to 1 (instead of the variable duration) which in my mind should not throw this error.
    Again, like i said, it's probs some silly mistake that i've done and can't see, but help is appreciated.

    Thanks
     
  2. Offline

    Abstract97

    @dlange could you please post the stack trace.
     
  3. Offline

    blablubbabc

    I don't know if your syntax exists, because I only know the version which looks like this: http://www.w3schools.com/sql/sql_update.asp (with only 1 time the 'SET' word and all columns only separated by comma, without additional 'SET''s)
     
    hexaan likes this.
  4. Offline

    dlange

    @Abstract97 Sure, can't access it now, but i will tomorrow (AEST time)

    @Abstract97 Here it is.
    Code:
    [17:13:17] [Server thread/WARN]: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SET duration='1', SET perm='1', SET time='1447654396774', SET reason='Test' WHER' at line 1
    [17:13:17] [Server thread/WARN]:     at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    [17:13:17] [Server thread/WARN]:     at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
    [17:13:17] [Server thread/WARN]:     at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
    [17:13:17] [Server thread/WARN]:     at java.lang.reflect.Constructor.newInstance(Unknown Source)
    [17:13:17] [Server thread/WARN]:     at com.mysql.jdbc.Util.handleNewInstance(Util.java:407)
    [17:13:17] [Server thread/WARN]:     at com.mysql.jdbc.Util.getInstance(Util.java:382)
    [17:13:17] [Server thread/WARN]:     at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1052)
    [17:13:17] [Server thread/WARN]:     at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3593)
    [17:13:17] [Server thread/WARN]:     at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3525)
    [17:13:17] [Server thread/WARN]:     at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1986)
    [17:13:17] [Server thread/WARN]:     at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2140)
    [17:13:17] [Server thread/WARN]:     at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2620)
    [17:13:17] [Server thread/WARN]:     at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1662)
    [17:13:17] [Server thread/WARN]:     at com.mysql.jdbc.StatementImpl.executeUpdate(StatementImpl.java:1581)
    [17:13:17] [Server thread/WARN]:     at net.venix.dev.core.database.MySQL.update(MySQL.java:88)
    [17:13:17] [Server thread/WARN]:     at net.venix.dev.core.database.bm.BanManager.mutePlayer(BanManager.java:213)
    [17:13:17] [Server thread/WARN]:     at net.venix.dev.core.database.bm.MuteCommand.onCommand(MuteCommand.java:65)
    [17:13:17] [Server thread/WARN]:     at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44)
    [17:13:17] [Server thread/WARN]:     at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:181)
    [17:13:17] [Server thread/WARN]:     at org.bukkit.craftbukkit.v1_7_R4.CraftServer.dispatchCommand(CraftServer.java:767)
    [17:13:17] [Server thread/WARN]:     at net.minecraft.server.v1_7_R4.PlayerConnection.handleCommand(PlayerConnection.java:1043)
    [17:13:17] [Server thread/WARN]:     at net.minecraft.server.v1_7_R4.PlayerConnection.a(PlayerConnection.java:880)
    [17:13:17] [Server thread/WARN]:     at net.minecraft.server.v1_7_R4.PacketPlayInChat.a(PacketPlayInChat.java:28)
    [17:13:17] [Server thread/WARN]:     at net.minecraft.server.v1_7_R4.PacketPlayInChat.handle(PacketPlayInChat.java:65)
    [17:13:17] [Server thread/WARN]:     at net.minecraft.server.v1_7_R4.NetworkManager.a(NetworkManager.java:186)
    [17:13:17] [Server thread/WARN]:     at net.minecraft.server.v1_7_R4.ServerConnection.c(ServerConnection.java:81)
    [17:13:17] [Server thread/WARN]:     at net.minecraft.server.v1_7_R4.MinecraftServer.v(MinecraftServer.java:734)
    [17:13:17] [Server thread/WARN]:     at net.minecraft.server.v1_7_R4.DedicatedServer.v(DedicatedServer.java:289)
    [17:13:17] [Server thread/WARN]:     at net.minecraft.server.v1_7_R4.MinecraftServer.u(MinecraftServer.java:584)
    [17:13:17] [Server thread/WARN]:     at net.minecraft.server.v1_7_R4.MinecraftServer.run(MinecraftServer.java:490)
    [17:13:17] [Server thread/WARN]:     at net.minecraft.server.v1_7_R4.ThreadServerApplication.run(SourceFile:628)
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Nov 15, 2015
  5. Offline

    dlange

  6. Offline

    mythbusterma

    @dlange

    They already told you what your error is.
     
  7. Offline

    dlange

  8. Offline

    mythbusterma

    @dlange

    Well, whatever syntax that is, its not SQL. Finx your syntax.
     
  9. Offline

    Scimiguy

    @dlange
    But it doesn't. Obviously.
     
  10. Offline

    dlange

    Do you know SQL?

    Why else would i be here? If you read the original post, i said i have used it before and it worked, but it isn't working now.
     
  11. Offline

    mythbusterma

    @dlange

    I should like to think I'm pretty good at SQL. That isn't statement you made doesn't follow the standard, so unless you're using some weird database (not MySQL) that won't work. Besides, it looks awful anyway. Use the canonical syntax, then it should work.
     
  12. Offline

    dlange

    @mythbusterma i know it's not the best, i'm reviving an old plugin of mine, and redoing most of it will take too long. I will change it to the normal syntax, message you back once tested.
     
Thread Status:
Not open for further replies.

Share This Page