我在我的客户端 - 服务器应用程序中使用了嵌入式数据库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)`
有没有办法实现这个目标?
答案 0 :(得分:2)
您必须向所创建的用户授予选择权。
GRANT SELECT ON TEST TO READONLY
更多信息:http://www.h2database.com/html/grammar.html#grant_right