Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have used the next SQL statement but it fails in 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

like image 474
user3554506 Avatar asked May 15 '14 14:05

user3554506


1 Answers

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

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

like image 147
JasonSec Avatar answered Oct 25 '22 10:10

JasonSec