gpt4 book ai didi

java - 插入mysql表时出现异常

转载 作者:行者123 更新时间:2023-11-30 22:51:45 25 4
gpt4 key购买 nike

<分区>

我已经从下面的脚本生成了一个 mysql 表

CREATE TABLE IF NOT EXISTS `Record` (
`RecordID` INT(11) NOT NULL AUTO_INCREMENT,
`URL` text NOT NULL,
PRIMARY KEY (`RecordID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

问题是我不能像这样向表中插入任何值

sql = "INSERT INTO  test.'Record' " + "('URL') VALUES " + "(?);";

要么这样

    sql = "INSERT INTO  'test'.'Record' values(?)";
PreparedStatement stmt = db.conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
stmt.setString(1, URL);
stmt.execute();

这是异常信息

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 ''test'.'Record' values

这样做的正确方法是什么。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com