user3554506
user3554506

Reputation: 63

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

Upvotes: 6

Views: 33077

Answers (1)

JasonSec
JasonSec

Reputation: 634

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','','','','','')");

Upvotes: 13

Related Questions