2021年2月5日星期五

Mariadb / MySQL JAVA Prepared Statement Syntax Error

               // 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();                    

I am really not getting what I am doing wrong here to get this error.

The output of printline is

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 ('  

I am really lost here as the same query from the printline works directly on the MariaDB server through phpMyAdmin.

https://stackoverflow.com/questions/66073463/mariadb-mysql-java-prepared-statement-syntax-error February 06, 2021 at 12:04PM

没有评论:

发表评论