以下是由 Java 中的 prepareStatement 生成的查询:
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' )
Java代码是:
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;
}
查询在 try 语句中执行并将值正确插入数据库中,但它还在第 192 行抛出以下异常:此处为“val”:
org.postgresql.util.PSQLException: ERROR: error de sintaxis en o cerca de «,»
org.postgresql.util.PSQLException: ERROR: syntax error near ',' java
与 postgres 相关的错误跟踪在这里:
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)
顺便说一句,该表有一个 bigserial 值,所有其他值都显示在查询中。提前致谢!