java - MySQL error - incorrect DOUBLE value: 'chests' -


i trying add value specific user called chests when execute method:

public void addamm(player player, int amount, datatype type) {     try {         statement sql = mysql.getconnection().createstatement();         sql.executeupdate("update `playerinfo` set `chests`= '" + amount + "' + 'chests' username='" + player.getname() + "';");         sql.close();     } catch (sqlexception e) {         e.printstacktrace();     } } 

it gives me error:

[12:26:14 warn]: com.mysql.jdbc.mysqldatatruncation: data truncation: truncated
incorrect double value: 'chests'

let's assume amount 5 , player.getname() paul. is:

"update `playerinfo` set `chests`= '5' + 'chests' username='paul';" 

so assign '5' + 'chests' `chests`. if column of type double, assigned value has converted (truncated).

may wanted rather following:

"update `playerinfo` set `chests`= '5' + `chests` username='paul';"  

i.e.

"update `playerinfo` set `chests`= '" + amount                    + "' + `chests` username='" + player.getname() + "';" 

this adds amount value of column `chests` player paul.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -