Search code examples
javapostgresqlweblogicsql2o

PSQLException: ERROR: relation "folder" does not exist


I am using Java, Weblogic, postgressql, and sql2o.

I am selecting from a table named folder.

select * from folder

works fine in pgadmin, however, every variation I try from Java gives me the following exception: Caused by: org.postgresql.util.PSQLException: ERROR: relation "folder" does not exist

I've tried every variation: public.folder, "folder", folder, and "public"."folder"... nothing works.

here is my code:

public Folder get(long folderId) {
        String sql = "select * from \"public\".\"folder\" where folder_id = 1";
        try (Connection connection = helper.open()) {
            Query query = connection.createQuery(sql); 
            return populate(query.executeAndFetchFirst(Folder.class));            
        }
    }

EDIT: Here is the create script

CREATE TABLE public.folder
(
  folder_id bigint NOT NULL,
[...]
CONSTRAINT folder_pkey PRIMARY KEY (folder_id)
)
WITH (
  OIDS=FALSE
);
ALTER TABLE public.folder
  OWNER TO postgres;

Any insight into what I am doing wrong?


Solution

  • This was a misleading error message. The root of the problem was that in the datasource in weblogic, the database name was listed as xxx instead of xxxdb.

    Recreating the datasource with the correct DB name fixed this issue.