I agree that it would be better to move this code out of the JSP. As for your error, it looks like you are connecting to the database and getting an error running the insert. There aren't braces around the column names in an insert. You can try running the SQL statement at the postgres command line to make sure it works.