[英]MySQL Syntax Error - Java
$You have an error in your SQL syntax; $您的SQL语法有误; check the manual that corresponds to your MySQL server version for the right syntax to use near 'null, null, null, 98-4B-E1-A9-C5-82, null)' at line 1$ 检查与您的MySQL服务器版本对应的手册以获取正确的语法,以在第1行的'null,null,null,98-4B-E1-A9-C5-82,null)附近使用
Error that i got when this is executing 执行此操作时出现的错误
st.executeUpdate("INSERT INTO gameservers" + "VALUES (null, null, null, "+macAddress+", null)");
And my sql: 和我的SQL:
CREATE TABLE IF NOT EXISTS `gameservers` (
`server_id` int(11) NOT NULL default '0',
`hexid` varchar(50) NOT NULL default '',
`host` varchar(50) NOT NULL default '',
`macAddress` varchar(50) NOT NULL default '',
`firstTime` int(1) NOT NULL default '0',
PRIMARY KEY (`server_id`)
) ;
Any idea? 任何想法?
You need a space after gameservers and you need to put macAddress in quotes. 游戏服务器后需要一个空格,并且需要在macAddress中加上引号。 At least. 至少。
"INSERT INTO gameservers " + "VALUES (null, null, null, '"+macAddress+"', null)"
macAddress是varchar,因此应将其包装在单引号中 。
"VALUES (null, null, null, '"+macAddress+"', null)"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.