3

我在我的客户端-服务器应用程序中使用嵌入式数据库 H2。

对于某些用途,我需要创建用户,该用户只能查看表而无权更改它们。我认为创建非管理员用户对于我的情况就足够了。但是我在尝试执行查询时遇到以下异常SELECT * FROM ADDRESS

org.h2.jdbc.JdbcSQLException: Недостаточно прав на объект "PUBLIC.ADDRESS"
Not enough rights for object "PUBLIC.ADDRESS"; SQL statement:
SELECT * FROM ADDRESS [90096-164] 
at org.h2.message.DbException.getJdbcSQLException(DbException.java:329) 
at org.h2.message.DbException.get(DbException.java:169) 
at org.h2.message.DbException.get(DbException.java:146) 
at org.h2.engine.User.checkRight(User.java:98) 
at org.h2.table.TableFilter.<init>(TableFilter.java:122) 
at org.h2.command.Parser.readTableFilter(Parser.java:1084) 
at org.h2.command.Parser.parseSelectSimpleFromPart(Parser.java:1686) 
at org.h2.command.Parser.parseSelectSimple(Parser.java:1793) 
at org.h2.command.Parser.parseSelectSub(Parser.java:1680) 
at org.h2.command.Parser.parseSelectUnion(Parser.java:1523) 
at org.h2.command.Parser.parseSelect(Parser.java:1511) 
at org.h2.command.Parser.parsePrepared(Parser.java:405) 
at org.h2.command.Parser.parse(Parser.java:279) 
at org.h2.command.Parser.parse(Parser.java:251) 
at org.h2.command.Parser.prepareCommand(Parser.java:217) 
at org.h2.engine.Session.prepareLocal(Session.java:415) 
at org.h2.server.TcpServerThread.process(TcpServerThread.java:250) 
at org.h2.server.TcpServerThread.run(TcpServerThread.java:146) 
at java.lang.Thread.run(Unknown Source) 

at org.h2.engine.SessionRemote.done(SessionRemote.java:565) 
at org.h2.command.CommandRemote.prepare(CommandRemote.java:67) 
at org.h2.command.CommandRemote.<init>(CommandRemote.java:46) 
at org.h2.engine.SessionRemote.prepareCommand(SessionRemote.java:437) 
at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1121) 
at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:164) 
at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:152) 
at org.h2.server.web.WebApp.getResult(WebApp.java:1311) 
at org.h2.server.web.WebApp.query(WebApp.java:1001) 
at org.h2.server.web.WebApp$1.next(WebApp.java:964) 
at org.h2.server.web.WebApp$1.next(WebApp.java:967) 
at org.h2.server.web.WebThread.process(WebThread.java:166) 
at org.h2.server.web.WebThread.run(WebThread.java:93) 
at java.lang.Thread.run(Unknown Source)`

有什么方法可以实现目标吗?

4

1 回答 1

4

您必须将选择权限授予创建的用户。

GRANT SELECT ON TEST TO READONLY

更多信息:http ://www.h2database.com/html/grammar.html#grant_right

于 2012-04-18T06:13:11.017 回答