user1663856
user1663856

Reputation: 1

MySQL Syntax Error - Java

$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 'null, null, null, 98-4B-E1-A9-C5-82, null)' at line 1$

Error that i got when this is executing

st.executeUpdate("INSERT INTO gameservers" + "VALUES (null, null, null, "+macAddress+", null)");

And my 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?

Upvotes: 0

Views: 105

Answers (2)

Matthew Farwell
Matthew Farwell

Reputation: 61705

You need a space after gameservers and you need to put macAddress in quotes. At least.

"INSERT INTO gameservers " + "VALUES (null, null, null, '"+macAddress+"', null)"

Upvotes: 2

kosa
kosa

Reputation: 66637

macAddress is varchar, so it should be wrapped in single quote.

"VALUES (null, null, null, '"+macAddress+"', null)"

Upvotes: 1

Related Questions