Solved Invalid value for getInt() SQL

Discussion in 'Plugin Development' started by RFUDEO9EH, May 11, 2020.

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

    RFUDEO9EH

    Hello I have a big problem with this code:

    https://pastebin.com/8vkKqQ7V

    can you help me, the sql is connected and the error is at this line:

    int integer = res.getInt(name);
     
    Last edited: May 11, 2020
  2. Offline

    timtower Administrator Administrator Moderator

    @RFUDEO9EH What is the type of the value in the database?
     
  3. Offline

    RFUDEO9EH

    @timtower it's an integer

    and it's not an error from the variable "name"
     
    Last edited: May 11, 2020
  4. Offline

    timtower Administrator Administrator Moderator

    @RFUDEO9EH Can you try printing the columns and their types?
     
  5. Offline

    RFUDEO9EH

    Attached Files:

    Last edited: May 11, 2020
  6. Offline

    timtower Administrator Administrator Moderator

    @RFUDEO9EH Print the string value to the console
     
  7. Offline

    RFUDEO9EH

    @timtower the string "nomdelacolonne"

    error:

    [09:14:57] [Server thread/WARN]: java.sql.SQLException: Invalid value for getInt() - 'elo_combosumoelo1v1'
    [09:14:57] [Server thread/WARN]: at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
    [09:14:57] [Server thread/WARN]: at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:987)
    [09:14:57] [Server thread/WARN]: at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:982)
    [09:14:57] [Server thread/WARN]: at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:927)
    [09:14:57] [Server thread/WARN]: at com.mysql.jdbc.ResultSetImpl.getInt(ResultSetImpl.java:2788)
    [09:14:57] [Server thread/WARN]: at com.mysql.jdbc.ResultSetImpl.getInt(ResultSetImpl.java:2813)
    [09:14:57] [Server thread/WARN]: at eu.bzjeq.funpvp.SqlConnection.getEloGuild(SqlConnection.java:396)
    [09:14:57] [Server thread/WARN]: at eu.bzjeq.funpvp.Utils.UpdateTimer.run(UpdateTimer.java:69)
    [09:14:57] [Server thread/WARN]: at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftTask.run(CraftTask.java:71)
    [09:14:57] [Server thread/WARN]: at org.bukkit.craftbukkit.v1_8_R3.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:350)
    [09:14:57] [Server thread/WARN]: at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:723)
    [09:14:57] [Server thread/WARN]: at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374)
    [09:14:57] [Server thread/WARN]: at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654)
    [09:14:57] [Server thread/WARN]: at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557)
    [09:14:57] [Server thread/WARN]: at java.lang.Thread.run(Unknown Source)
     

    Attached Files:

    • 1.PNG
      1.PNG
      File size:
      3.6 KB
      Views:
      2
    Last edited: May 12, 2020
  8. Offline

    timtower Administrator Administrator Moderator

    @RFUDEO9EH What does getString(name) give?
    Or can you show the value in the database?
     
  9. Offline

    RFUDEO9EH

    I use :

    String valeur = res.getString(nomdelacolonne);
    Bukkit.broadcastMessage("get string : " + valeur);

    Console:

    @timtower
    [09:27:37] [Server thread/INFO]: player : bzjeq
    [09:27:37] [Server thread/INFO]: size : 1 player [CraftOfflinePlayer[UUID=f71599d9-c388-3a82-bf18-46d7955d8725]]
    [09:27:37] [Server thread/INFO]: The string is : elo_rushelo1v1
    [09:27:37] [Server thread/INFO]: get string : elo_rushelo1v1

    full database: (I only use in my sql line who strart with "elo_")
     

    Attached Files:

    Last edited: May 12, 2020
  10. Offline

    timtower Administrator Administrator Moderator

    @RFUDEO9EH That should not return elo_rushelo1v1.
    Could you post the values that you are trying to get from the database?
    Just the entire database row for your UUID
     
  11. Offline

    RFUDEO9EH

    Attached Files:

  12. Offline

    timtower Administrator Administrator Moderator

    @RFUDEO9EH I don't see why this is going wrong, should be able to get the value without issues.
    I really don't know why your code is getting the column name.
     
  13. Offline

    RFUDEO9EH

  14. Offline

    timtower Administrator Administrator Moderator

    @RFUDEO9EH You just changed the preparedstatment right? Weird that this does work.
     
  15. Offline

    RFUDEO9EH

    @timtower yes and I have do some change with the uuid
     
Thread Status:
Not open for further replies.

Share This Page