I'm trying to use an INSERT
statement to add data from a form in Spring application front end to a PostgreSQL table. The form includes mainly text values but I also include an input requirement for times in the format of HH:MM
. On a side note I also include a requirement for a date in the form of DD/MM/YYYY
, and the text in the form can include commas, periods, and apostrophes. Depending on the data entered into the form (e.g names, biography, addresses etc) I get the following error pointing to different positions of the data.
org.postgresql.util.PSQLException: ERROR: syntax error at or near "blank"
Position: x
Therefore I cannot pinpoint the exact root of the problem but any experience I've had with this type of error there was an issue with a symbol of some description.
I use an executeUpdate
to create the insert statement in a java class like so:
int rs = stmt.executeUpdate( "INSERT INTO events VALUES
(nextval('reviews_id_seq'::regclass), '" + eventname +" '," +description+","
+address+", '"+starttime+"', '"+endtime+"',
'"+username+"','"+attendees+"');");
Any ideas?