Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3972469
  • 博文数量: 366
  • 博客积分: 9916
  • 博客等级: 中将
  • 技术积分: 7195
  • 用 户 组: 普通用户
  • 注册时间: 2011-05-29 23:27
个人简介

简单!

文章分类

全部博文(366)

文章存档

2013年(51)

2012年(269)

2011年(46)

分类: Mysql/postgreSQL

2012-11-13 17:38:43

1.错误信息

  1. # java -cp postgresql-9.2-1001.jdbc4.jar:. Prepared
  2. Nov 13, 2012 5:07:38 PM Prepared main
  3. SEVERE: ERROR: permission denied for relation authors
  4. org.postgresql.util.PSQLException: ERROR: permission denied for relation authors
  5. at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2157)
  6. at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1886)
  7. at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:255)
  8. at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:555)
  9. at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:417)
  10. at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:363)
  11. at Prepared.main(Prepared.java:29)



2.原因

该数据库用户没有相应的权限。
在代码中,我们使用用户名(user12)及密码(user12)去连接PostgreSQL数据库。
  1. String user = "user12";
  2. String password = "user12";
再看看,我们数据库中所建表的归属,如下:
  1. testdb=# \dt
  2. List of relations
  3. Schema | Name | Type | Owner
  4. --------+---------+-------+----------
  5. public | authors | table | postgres
  6. public | books | table | postgres
  7. public | images | table | postgres
  8. public | testing | table | postgres
  9. (4 rows)



3.解决方法

修改使用的数据库用户,或则更改表的所属者。

  1. String user = "user12";
  2. String password = "user12";

  1. testdb=# ALTER TABLE authors OWNER TO user12;



阅读(3980) | 评论(4) | 转发(0) |
给主人留下些什么吧!~~

txgc_wm2012-11-14 16:28:03

中国物讯网11: 支持下。。。.....
谢谢支持!

txgc_wm2012-11-14 16:26:58

hebingyue: 还以为pg数据库崩溃了呢。呵呵。.....
初次接触该数据库,还没处理过崩溃的问题呢!

中国物讯网112012-11-14 15:46:19

支持下。。。

hebingyue2012-11-14 14:42:00

还以为pg数据库崩溃了呢。呵呵。