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 error syntax error at end of input postgresql 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 6.2 million programmers, just like you, helping each
Error: Syntax Error At End Of Input Position
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) + org.postgresql.util.psqlexception: error: syntax error at or near "$1" "','" + 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_
here for a quick overview of the site Help Center Detailed answers
Sql State: 42601
to any questions you might have Meta Discuss the workings
Postgres Insert
and policies of this site About Us Learn more about Stack Overflow the company Business postgres create table 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 http://stackoverflow.com/questions/23680629/error-syntax-error-at-end-of-input-java-postgres Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: 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 http://stackoverflow.com/questions/19073542/org-postgresql-util-psqlexception-error-syntax-error-near-in-java 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 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
Regional lists Associations User groups Project lists pgadmin-hackers pgadmin-support pgsql-jdbc pgsql-odbc pgsql-pkg-debian pgsql-pkg-yum psycopg Inactive https://www.postgresql.org/message-id/CAPvh4w31szZNu1b9dEJPge22Tw81YHPfs7ThnHjxU%3D2K-0-BaA@mail.gmail.com lists IRC Local User Groups Featured Users International Sites Propaganda Resources Weekly News JDBC syntax error at end of input From: Hans http://forum.liquibase.org/topic/getting-error-syntax-error-at-or-near-end-while-using-the-generatechagelog-in-liquibase Vasquez-Gross
in the picture below. Send Cancel From : guestTo : Subject : Content : Type the characters you see in the picture below. Send Update CancelFeedbackEmail IDSubject : Comments : Send CancelPrivate MessageType the characters you see in the picture below. Type the characters you see in the picture below. Attach files Desktop Zoho Docs Google Docs Each Attachment size should not exceed 0 Bytes. Max no of attachments : 1Loading User Profile... guest Response titleThis is preview!Attachments Publish Back to edit Cancel ()Sign InYou can also use the below options to loginLogin with FacebookLogin with GoogleLogin with Yahoo New to this Portal? Click on Join Now to Sign UpJoin Now Help Feedback Sign In Liquibase Forums Recent Topics All Forums Search AllTagsAuthorAdvanced SearchSearch New Topic Move this topicForum : Liquibase UsersLiquibase Development Sub forum : Move this topic Cancel Liquibase Users smishra11 Getting ERROR: syntax error at or near "end" while using the GenerateChageLog in liquibase. in Liquibase Users • 5 years ago Hi, I am getting the liquibase.exception.DatabaseException: org.postgresql.util.PSQLException: ERROR: syntax error at or near "end" while using the generateChangeLog ant task. I am trying generate the changelog files from an existing DB... Here is what the error shows: liquibase.exception.DatabaseException: org.postgresql.util.PSQLException: ERROR: syntax error at or near "end" at liquibase.snapshot.jvm.JdbcDatabaseSnapshotGenerator.createSnapshot(JdbcDatabaseSnapshotGenerator.java:251) at liquibase.snapshot.DatabaseSnapshotGeneratorFactory.createSnapshot(DatabaseSnapshotGeneratorFactory.java:69) at liquibase.diff.Diff.compare(Diff.java:63) at liquibase.integration.ant.GenerateChangeLogTask.execute(GenerateChangeLogTask.java:51) at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291) at sun.reflect.G