com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException | JAVA -
i want number of entries in table in java project.
this code:
int count = 0; statement st = mysql.con.createstatement(); resultset rs= st.executequery("select count(*) keys spieler =" +p.getname()); while (rs.next()){ count = rs.getint(1); }
i getting following sqlexception
:
com.mysql.jdbc.exceptions.jdbc4.mysqlsyntaxerrorexception: have error in sql syntax; check manual corresponds mysql server version right syntax use near 'keys spieler =pit910' @ line 1
what worng?
thanks!
keys
reserved mysql keyword needs escaped (either or alter table give different name). try this
preparedstatement preparedstatement = con.preparestatement("select count(*) `keys` spieler = ?"); preparedstatement.setstring(1, p.getname()); resultset rs= preparedstatement.executequery(); ...
Comments
Post a Comment