当我尝试将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语法?
答案 0 :(得分:0)
表名或字段中不允许引用:
String sql =
"CREATE TABLE IF NOT EXISTS Reportslog (SenderName varchar(32), Message varchar(32))";
PreparedStatement preparedStatement = conn.prepareStatement(sql);
preparedStatement.executeUpdate();