连接PG库的时候,进行数据库操作,结果报错:
org.postgresql.util.PSQLException: ERROR: relation "auth_user" does not exist
明明数据库里面有表,为何找不到???
原来,PG库用户登录后,默认搜索的schema名字为search_path = '"$user", public',而我操作的schema恰恰不是当前用户,所以如果使用的不同用户连接不同的schema时,配置连接url,需要指定当前需要访问的schema名,如下:
jdbc:postgresql://localhost:5432/cmpdb?useUnicode=true&characterEncoding=utf8¤tSchema=xxxxx
问题得到解决!!!