Java 为什么我会得到一个“;MySQLSyntaxErrorException:“;错误?
语法错误,我似乎找不到它。我不熟悉数据库 错误:Java 为什么我会得到一个“;MySQLSyntaxErrorException:“;错误?,java,mysql,sql,syntax,Java,Mysql,Sql,Syntax,语法错误,我似乎找不到它。我不熟悉数据库 错误: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 'database ( ID INTEGER NOT NULL,
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 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 'database ( ID INTEGER NOT NULL, QUESTION varchar(100) NOT NULL, ANSWER varchar(5' at line 1
代码:
数据库
是一个。为表使用不同的名称数据库
是一个数据库。为表使用不同的名称数据库
是一个数据库。为表使用不同的名称数据库
是一个数据库。为表使用其他名称数据库
是保留字。给你的桌子起个别的名字<代码>数据库是保留字。给你的桌子起个别的名字<代码>数据库是保留字。给你的桌子起个别的名字<代码>数据库是保留字。给你的桌子起个别的名字。
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 definitely works as intended
System.out.println("Created a table called " + this.tableName);
} catch (SQLException e) {
System.out.println("ERROR: Could not create the table");
e.printStackTrace();
return;
}
}