'PSQLException: ERROR: column does not exist Position: 8
org.postgresql.util.PSQLException: ERROR: column "feedbackid" does not exist Position: 8
I am getting this error but unable to understand what the reason behind this. It shows:- **
org.postgresql.util.PSQLException: ERROR: column "feedbackid" does not exist Hint: Perhaps you meant to reference the column "feedback.feedbackId". Position: 8
**
Database table in postgres:
create table `company`.`feedback` (
feedbackId int(10) NOT NULL,
feedbackActionId int(12) NOT NULL,
description varchar(200) DEFAULT NULL,
feedbackText varchar(2000) DEFAULT NULL,
email varchar(100) NOT NULL,
createdDate date NOT NULL
);

public Feedback getFeedbackById(int id) throws SQLException, ClassNotFoundException {
conn = DBConnection.setDBConnection();
String sqlQuery = "select feedbackId, feedbackActionId, description, feedbackText, email, createdDate" +
"from feedback " +
" where feedbackId = " + id ;
DBConnection dbConn = new DBConnection();
ResultSet resultSet = dbConn.getResultSet(sqlQuery, conn);
int feedbackId = resultSet.getInt("feedbackId");
int feedbackActionId = resultSet.getInt("feedbackActionId");
String description = resultSet.getString("description");
String feedbackText = resultSet.getString("feedbackText");
String email = resultSet.getString("email");
Date createdDate = resultSet.getDate("createdDate");
feedback = new Feedback(feedbackId, feedbackActionId, description, feedbackText, email, createdDate);
resultSet.close();
return feedback;
}
Thanks in advance.
Solution 1:[1]
This question might help you. Looks like Postgres is case senstive towards column names. You might need to include field name in quotes. Are PostgreSQL column names case-sensitive?
Solution 2:[2]
Please Try to use: @GeneratedValue(strategy = GenerationType.IDENTITY) in your POJO class Id Field. This thing solved my error.
Solution 3:[3]
sometimes occurs when you use double quotes instead of single quotes for strings
replace where user_id="random_id" with where user_id='random_id'
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Ravi Chandra |
| Solution 2 | Raj Shukla |
| Solution 3 | procrastinator |
