Labels

Wednesday 27 November 2013

[POSTGRES] PSQLException: The column index is out of range: 1, number of columns: 0

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.

Solve:
The Problem was that I used ” ‘ ” inside of the sql string close to the “?”. After I removed the ” ‘ ” strings it worked perfectly.

2 comments:

  1. update query not working .i got same error in my project please find the solution

    ReplyDelete
  2. what is your final query. can you put it here :D

    ReplyDelete