Fw: how to resolve org.postgresql.util.PSQLException: ERROR: operator does not exist: text = integer?

From: Karen Goh <karenworld(at)yahoo(dot)com>
To: pgsql-sql(at)lists(dot)postgresql(dot)org
Subject: Fw: how to resolve org.postgresql.util.PSQLException: ERROR: operator does not exist: text = integer?
Date: 2019-07-14 03:39:58
Message-ID: 1846547624.530883.1563075598322@mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


re-send. Kindly assist. Thanks.

----- Forwarded Message ----- From: Karen Goh <karenworld(at)yahoo(dot)com>To: "pgsql-sql(at)lists(dot)postgresql(dot)or" <pgsql-sql(at)lists(dot)postgresql(dot)or>Sent: Sunday, July 14, 2019, 11:36:01 AM GMT+8Subject: how to resolve org.postgresql.util.PSQLException: ERROR: operator does not exist: text = integer?
Hi,

This is a continuation of my last problem - not sure if I should write from there cos the first part was solved with the help from this group.

I was trying to get the matching tutor_id with the parameter values which is in this case subject_names from a table which contains both the tutor_id and the subject_names.

Here's the error message:

org.postgresql.util.PSQLException: ERROR: operator does not exist: text = integer
  Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts.
  Position: 69
    at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2433)
    at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2178)
    at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:306)
    at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441)
    at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365)
    at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:155)
    at org.postgresql.jdbc.PgPreparedStatement.executeQuery(PgPreparedStatement.java:118)
    at Controller.searchController.doPost(searchController.java:108)

Here's the code snippet which I do not know where I had gone wrong:

            String sql1 = "select tutor_id, subject_name from tutor_subject where subject_name in ("
                    + builder.deleteCharAt(builder.length() - 1).toString() + ")";

            PreparedStatement ps2 = connection.prepareStatement(sql1);
HashMap<Integer, ArrayList<String>> tutorSubject = new HashMap<Integer, ArrayList<String>>();           
for(String item : subjs) {
            int tutor_id = tutor.getTutor_id();
            ps2.setInt(1, tutor_id);           
            if (item != null) {
                subjs.add(item);
            ps2.setString(2, item);   
            }                         
            ps2.executeQuery();
        while (rs.next()) {
                    tutor_id = rs.getInt("tutor_id"); 
                    subjs.add(rs.getString("subject_name"));
                                           
                        tutorSubject.put(tutor_id, subjs);   
                        System.out.println(tutorSubject);
                        }
           
            System.out.println("tutor ID=" + rs.getInt("tutor_id") + ", subjectName=" + rs.getString("subject_name"));

Hope someone could point out my mistake.

Thanks.

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Andrew Gierth 2019-07-14 08:10:01 Re: Fw: how to resolve org.postgresql.util.PSQLException: ERROR: operator does not exist: text = integer?
Previous Message Ed Behn 2019-07-12 15:34:36 Re: Error: rows returned by function are not all of the same row type