0

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 );

database table in postgres

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.

Anshu Ashish
  • 111
  • 2
  • 6

3 Answers3

0

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?

Ravi Chandra
  • 677
  • 12
  • 24
0

Please Try to use: @GeneratedValue(strategy = GenerationType.IDENTITY) in your POJO class Id Field. This thing solved my error.

Raj Shukla
  • 442
  • 5
  • 9
0

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'

Procrastinator
  • 2,526
  • 30
  • 27
  • 36