java - What is wrong with my database code? -
i'm trying check if string key in netflix column.
public boolean checkserial(string key){     boolean isvalid = false;     sql = "select * keys netflix=?";     try{         ps = con.preparestatement(sql);         ps.setstring(1, key);         rs = ps.executequery();         if(rs.next())             isvalid = true;     }catch(sqlexception e){         system.out.println(e);     }     return isvalid; } com.mysql.jdbc.exceptions.jdbc4.mysqlsyntaxerrorexception: have error in sql syntax; check manual corresponds mariadb server version right syntax use near 'keys netflix='ipman'' @ line 1
keys mysql reserved keyword. possibly you'll error if there's nothing wrong query.
either you've avoid using mysql reserved keywords, can found at
https://dev.mysql.com/doc/refman/5.0/en/reserved-words.html
or
use appropriate quotes keywords if don't want change existing table. like,
select * `keys` netflix=? note: it's not single quote, it's symbol present along tilde symbol below escape button (it's called backtick according comment).
Comments
Post a Comment