Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mariadb/MySQL JAVA准备语句语法错误_Mysql_Sql_Mariadb - Fatal编程技术网

Mariadb/MySQL JAVA准备语句语法错误

Mariadb/MySQL JAVA准备语句语法错误,mysql,sql,mariadb,Mysql,Sql,Mariadb,我真的不明白我做错了什么来得到这个错误 printline的输出是 // Attempt to get 1 transaction String sqlQuery = "INSERT INTO '" + this.crawlPageTableName + "' (url, status) VALUES (?, 'added')";

我真的不明白我做错了什么来得到这个错误

printline的输出是

               // Attempt to get 1 transaction
                String sqlQuery = "INSERT INTO '" + this.crawlPageTableName
                        + "' (url, status) VALUES (?, 'added')";

                PreparedStatement prest = connect.prepareStatement(sqlQuery);
                prest.setString(1, this.url);
                
                System.out.println("Querying with: " + sqlQuery);

                // Result set get the result of the SQL query
                this.resultSet = prest.executeQuery();
                

我在这里真的很迷茫,因为来自打印行的同一查询通过phpMyAdmin直接在MariaDB服务器上工作。

我认为不应该用任何单引号括住表名:

Querying with: INSERT INTO 'crawlPage' (url, status) VALUES (?, 'added')


java.sql.SQLSyntaxErrorException: (conn=1877278) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''crawlPage' (url, status) VALUES ('

我认为您不应该在表名中使用任何单引号:

Querying with: INSERT INTO 'crawlPage' (url, status) VALUES (?, 'added')


java.sql.SQLSyntaxErrorException: (conn=1877278) You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''crawlPage' (url, status) VALUES ('

如果表名需要转义,它们应该用反勾号括起来,而不是单引号。如果表名需要转义,它们应该用反勾号括起来,而不是单引号。