MySQL 语法错误 - Java Bukkit / Spigot 插件
MySQL syntax error - Java Bukkit / Spigot plugin
当我尝试将我的 Java 插件连接到本地 MySQL 数据库时出现此错误:
[01:15:44 INFO]: [BetterStaff] Could not connect to database: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 ''Reportslog' ('SenderName' varchar(32), 'Message' string)' at line 1
我的插件代码是:
this.db.openConnection();
Statement statement = this.db.getConnection().createStatement();
statement.executeUpdate("CREATE TABLE IF NOT EXISTS 'Reportslog' ('SenderName' varchar(32), 'Message' string)");
你能帮助我或纠正我的 SQL 语法吗?
table 名称或字段中不允许使用引号:
String sql =
"CREATE TABLE IF NOT EXISTS Reportslog (SenderName varchar(32), Message varchar(32))";
PreparedStatement preparedStatement = conn.prepareStatement(sql);
preparedStatement.executeUpdate();
当我尝试将我的 Java 插件连接到本地 MySQL 数据库时出现此错误:
[01:15:44 INFO]: [BetterStaff] Could not connect to database: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 ''Reportslog' ('SenderName' varchar(32), 'Message' string)' at line 1
我的插件代码是:
this.db.openConnection();
Statement statement = this.db.getConnection().createStatement();
statement.executeUpdate("CREATE TABLE IF NOT EXISTS 'Reportslog' ('SenderName' varchar(32), 'Message' string)");
你能帮助我或纠正我的 SQL 语法吗?
table 名称或字段中不允许使用引号:
String sql =
"CREATE TABLE IF NOT EXISTS Reportslog (SenderName varchar(32), Message varchar(32))";
PreparedStatement preparedStatement = conn.prepareStatement(sql);
preparedStatement.executeUpdate();