Java 和数据库查询?
使用Derby作为我的数据库驱动程序并通过java执行SQL查询, 当尝试执行此特定查询时遇到错误
stmt.executeQuery("insert into " + "TEST " + "values (" + dataTimeRev + ", "
+ dataType + "," + obj + ")" );
这里 dataTimeRev、dataType 和 obj 是带有数据的变量。
所说的错误是这样的
java.sql.SQLSyntaxErrorException: VALUES clause must contain at least one element. Empty elements are not allowed.
Using Derby as my data base driver and tying to execute SQL query through java,
there was a error that was encounter, when tried to execute this particular query
stmt.executeQuery("insert into " + "TEST " + "values (" + dataTimeRev + ", "
+ dataType + "," + obj + ")" );
Here dataTimeRev, dataType and obj are variables with data.
The error that was stated was like this
java.sql.SQLSyntaxErrorException: VALUES clause must contain at least one element. Empty elements are not allowed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果列数据类型是 VARCHAR,则必须在 qoutes 中传递值,例如
'value'
,您应该执行以下操作if the column data type is VARCHAR you will have to pass the value in qoutes like
'value'
for that you should do as below试试这个:
Try this:
导致此错误的原因之一是尝试插入不是字符串的类型(日期、双精度型、整数等,并用单引号括起来
''
例如,我的表是这样声明的:
所以我正在做:
而不是:
One of the causes of this error is trying to insert a Type that isn't a String (Date, Double, Integer e.t.c, surrounded by the single quotation mark
''
For example my table was declared like this:
So I was doing:
instead of: