Caused By Org.postgresql.util.psqlexception Error Syntax Error At End Of Input
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss syntax error at end of input postgres the workings and policies of this site About Us Learn more about syntax error at the end of input c Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow syntax error at end of input redshift Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each
Org.postgresql.util.psqlexception: Error: Syntax Error At Or Near "$1"
other. Join them; it only takes a minute: Sign up ERROR: syntax error at end of input, Java - Postgres up vote 0 down vote favorite 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) + sql state: 42601 "','" + Calendar.getInstance().get(Calendar.DAY_OF_MONTH) + "'"); with this error: ERROR: syntax error at end of input What's the problem? Thanks java sql postgresql share|improve this question asked May 15 '14 at 14:06 user3554506 314 2 The main problem is that you're specifying a value directly in SQL. Don't do that. Use parameterized SQL instead, to separate the code from the data. Once you've fixed that, you'll see the syntax error much more easily... as well as not being vulnerable to SQL injection attacks. Additionally, you're calling Calendar.getInstance() multiple times, which means you could be using multiple different values. Imagine if you're executing this right at the end of the year... you could end up with the "old" year but the "new" month and day values. Ick. –Jon Skeet May 15 '14 at 14:10 add a comment| 1 Answer 1 active oldest votes up vote 2 down vote accepted You're missing a ) at the end of the statement and the table is surrounded with double quotes for no reason.. INSERT INTO Registros (accion,num_tarjeta,valor,fecha_accion_ano,fecha_accio
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies postgres insert of this site About Us Learn more about Stack Overflow the company
Postgres Create Table
Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: http://stackoverflow.com/questions/23680629/error-syntax-error-at-end-of-input-java-postgres Sign up org.postgresql.util.PSQLException: ERROR: syntax error near «,» in Java up vote 0 down vote favorite 1 The below is the query generate by a prepareStatement in Java: insert into schema.table(cedula, actividad, mercado, venta_mensual, fortalezas, crecer, financiamiento, monto, patente, contador, regimen_tri, problemas, bn_servicios, cursos ) values ('val', 'GAM', 'GAM', '0', 'Calidad', 'Sí', 'Sí', '122', 'Sí', 'Sí', 'ddd', 'aaa','ccc', 'bbb' ) The Java http://stackoverflow.com/questions/19073542/org-postgresql-util-psqlexception-error-syntax-error-near-in-java code is: try { PreparedStatement pstmt = conexion.prepareStatement(query); pstmt.setString(1, n.getCedula()); //the rest of the sets of the statement continue here from 1 to 13 pstmt.executeUpdate(); conexion.createStatement().execute(query); return true } catch (SQLException e) { e.printStackTrace(); // This error return false; } The query is executed int the try statement and insert the values properly in the DB, BUT it also throws the below exception, at line 192: here 'val': org.postgresql.util.PSQLException: ERROR: error de sintaxis en o cerca de «,» org.postgresql.util.PSQLException: ERROR: syntax error near ',' java The error trace relate to postgres is here: at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2102) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1835) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257) at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:500) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:374) at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:366) By the way, the table has a bigserial value and all the others values showed in the query. Thanks in advance! java postgresql jdbc share|improve this question edited Sep 29 '13 at 2:50 asked Sep 29 '13 at 1:36 Diego Quirós 3231417 2 Post your Java code and the stacktrace. –Luiggi Mendoza Sep 29 '13 at 1:38 And use query.setString for your parameters. Don't just put them into the SQL statement. –Thilo Sep 29 '13 at
Regional lists Associations User groups Project lists pgadmin-hackers pgadmin-support pgsql-jdbc https://www.postgresql.org/message-id/CAPvh4w31szZNu1b9dEJPge22Tw81YHPfs7ThnHjxU=2K-0-BaA@mail.gmail.com pgsql-odbc pgsql-pkg-debian pgsql-pkg-yum psycopg Inactive lists IRC Local https://samebug.io/exceptions/134144/org.postgresql.util.PSQLException/error-syntax-error-at-end-of-input User Groups Featured Users International Sites Propaganda Resources Weekly News JDBC syntax error at end of input From: Hans Vasquez-Gross
help others org.postgresql.util.PSQLException: ERROR: syntax error at end of input Position: 495 Stack Overflow | Amareswar | 3 years ago 0 mark Getting syntax error at the end of the input while executing a query using postgres java driver Stack Overflow | 3 years ago | Amareswar org.postgresql.util.PSQLException: ERROR: syntax error at end of input Position: 495 find similars PostgreSQL JDBC Driver com.cnetchannel.ics 0 0 mark JDBC syntax error at end of input postgresql.org | 5 months ago org.postgresql.util.PSQLException: ERROR: syntax error at end of input Position: 400 at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2103) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1836) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257) at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:512) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:374) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:254) at edu.dendrome.sswap.QueryWithConfig.queryChromatSeqsByAmplicon(QueryWithConfig.java:380) at edu.dendrome.sswap.AmpliconMultiFastaService.initializeRequest(AmpliconMultiFastaService.java:88) at info.sswap.api.servlet.SimpleSSWAPServlet.handleRequest(SimpleSSWAPServlet.java:125) at info.sswap.api.servlet.AbstractSSWAPServlet.doPost(AbstractSSWAPServlet.java:658) find similars JavaServlet 0 0 mark Bug: DBSession#execute does not work with PostgreSQL GitHub | 4 years ago | seratch org.postgresql.util.PSQLException: ERROR: syntax error at or near "RETURNING" Position: 96 find similars PostgreSQL JDBC Driver 0 Speed up your debug routine! Automated exception search integrated into your IDE Test Samebug Integration for IntelliJ IDEA 0 mark Several close placeholders in postgres prepared statem