Why wont Mysql field update? - Java -
i trying write function in java updates description , title fields of mysql table when pass int variable 'urlid' nothing added. if change urlid variable (at end of query) int variable (for example int = 2) works fine. urlid makes things go wrong?
public void updatedescription( string desc, string title, int urlid ) throws sqlexception, ioexception { string cutdesc = desc.substring(0, 99); statement stat = connection.createstatement(); string query = "update urls set description = '"+cutdesc+"', title = '"+title+"' urlid =" + urlid; stat.executeupdate( query ); stat.close(); }
i guess miss quotes ,
"update urls set description = '"+cutdesc+"', title = '"+title+"' urlid ='"+ urlid+"'";
hope helps !!
note: use prepared statements avoid sql injection . see here
Comments
Post a Comment