错误:输入结束时出现语法错误,Java - Postgres

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23680629/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 00:39:32  来源:igfitidea点击:

ERROR: syntax error at end of input, Java - Postgres

javasqlpostgresql

提问by user3554506

I have used the next SQL statement but it fails in PostgreSQL.

我已经使用了下一个 SQL 语句,但它在 PostgreSQL 中失败了。

sentencia.execute("INSERT INTO \"Registros\" (accion,num_tarjeta,valor,fecha_accion_ano,fecha_accion_mes,fecha_accion_dia) VALUES ('recarga','" + num_tarjeta + "','" + valor_recargar + "','" + Calendar.getInstance().get(Calendar.YEAR) + "','" + Calendar.getInstance().get(Calendar.MONTH) + "','" + Calendar.getInstance().get(Calendar.DAY_OF_MONTH) + "'");

with this error:

出现此错误:

ERROR: syntax error at end of input

What's the problem? Thanks

有什么问题?谢谢

采纳答案by JasonSec

You're missing a )at the end of the statement and the table is surrounded with double quotes for no reason..

您在)语句末尾缺少 a并且该表无缘无故地用双引号括起来。

sentencia.execute("INSERT INTO Registros (accion,num_tarjeta,valor,fecha_accion_ano,fecha_accion_mes,fecha_accion_dia) VALUES ('recarga','','','','','')");

sentencia.execute("INSERT INTO Registros (accion,num_tarjeta,valor,fecha_accion_ano,fecha_accion_mes,fecha_accion_dia) VALUES ('recarga','','','','','')");