user3554506 user3554506 - 15 days ago 5
SQL Question

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

Answer

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

Comments