java - Why do I get a "MySQLSyntaxErrorException:" error? -


syntax error, can't seem find it. i'm new databases.

error:

com.mysql.jdbc.exceptions.jdbc4.mysqlsyntaxerrorexception: have error in sql syntax; check manual corresponds mysql server version right syntax use near 'database ( id integer not null, question varchar(100) not null, answer varchar(5' @ line 1 

code:

public void createtable(connection conn) {     try {         string createstring = "create table " + this.tablename + " ( "                 + "id integer not null, "                 + "question varchar(100) not null, "                 + "answer varchar(500) not null, " + "primary key (id))";          this.sendupdate(conn, createstring); //this part works intended         system.out.println("created table called " + this.tablename);     } catch (sqlexception e) {         system.out.println("error: not create table");         e.printstacktrace();         return;     } } 

database mysql reserved word. use different name table


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -