【发布时间】:2012-10-05 20:14:20
【问题描述】:
尝试从 Java 向 Mysql 插入一些值时出现语法错误。
我的代码如下所示:
date = new SimpleDateFormat("yyyy-MM-dd").parse(nextLine[0]);
java.sql.Timestamp sqlDate = new java.sql.Timestamp(date.getTime());
st.executeUpdate("INSERT INTO " + tick + "(day, open, high, low, close, volume) VALUES (" + sqlDate + ", " + nextLine[1] + ", " + nextLine[2] + ", " + nextLine[3] + ", " + nextLine[4] + ", " + nextLine[5] + ")");
我的例外:
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: 你有一个 SQL 语法错误;检查与您对应的手册 MySQL 服务器版本,用于在 '00:00:00.0 附近使用正确的语法, 128.40, 128.50, 127.30, 128.20, 1415200)' 在第 1 行
很高兴得到任何帮助:)
【问题讨论】:
-
请显示您发送到数据库的查询
标签: java mysql syntax insert timestamp