I tried to write a insert statement with Spring JDB Template for an PostgreSQL Database. My insert string looked like this:
final String sql = "INSERT INTO products (prod_name, prod_key, artifact_id, group_id, link, src, prod_type) VALUES ('?','?','?','?','?','?','?')";
And I got this Exception:
PreparedStatementCallback; SQL ; The column index is out of range: 1, number of columns: 0.; nested exception is org.postgresql.util.PSQLException: The column index is out of range: 1, number of columns: 0.
The Problem was that I used ” ‘ ” inside of the sql string close to the “?”. After I removed the ” ‘ ” strings it worked perfectly.
4 thoughts on “PSQLException: The column index is out of range: 1, number of columns: 0”
Same! I would have punched something. 🙂
I’m having the same error but without using “‘” just like this:
append(” C007.C007_CODIGO_EVENTO > ? “).
append(” ORDER BY C007.C007_CODIGO_EVENTO “).
append(” LIMIT 1000 “);
Thank you so much, that isn’t my solution but gave me a way to solve my problem.