java - sql2o无法在Oracle DB上删除

标签 java oracle sql2o

我正在尝试在项目中使用sq2o。它在MSSQL下运行良好,但是在切换到Oracle DB 12c时存在删除问题

public void delete(final String x, final String y) {
        final String query = "DELETE FROM XXX WHERE columnx = :x AND columny = :y";
        try (final Connection con = sql2o.beginTransaction();
             final Query q = con.createQuery(query)) {
            q.addParameter("x", x);
            q.addParameter("y", y);
            q.executeUpdate();
            con.commit();
        }
    }


当我使用这种方法时,我会得到一些神秘的日志:


  不允许的操作org.sql2o.Sql2oException:错误
  executeUpdate,不允许进行以下操作
  org.sql2o.Query.executeUpdate(Query.java:527)在
  com.fusionrisk.authorisation.impl.AuthorisationRoleDao.delete(AuthorisationRoleDao.java:55)
    在
  com.fusionrisk.authorisation.impl.AuthorisationService.deleteUserRole(AuthorisationService.java:43)
    在
  fusionrisk.rest.AuthorisationResource.deleteRole(AuthorisationResource.java:59)
    在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处
  sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    在
  sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    在java.lang.reflect.Method.invoke(Method.java:498)在
  org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory $ 1.invoke(ResourceMethodInvocationHandlerFactory.java:81)
    在
  org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher $ 1.run(AbstractJavaResourceMethodDispatcher.java:151)
    在
  org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:171)
    在
  org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider $ ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:152)
    在
  org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:104)
    在
  org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:387)
    在
  org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:331)
    在
  org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:103)
    在
  org.glassfish.jersey.server.ServerRuntime $ 1.run(ServerRuntime.java:271)
    在org.glassfish.jersey.internal.Errors $ 1.call(Errors.java:271)处
  org.glassfish.jersey.internal.Errors $ 1.call(Errors.java:267)在
  org.glassfish.jersey.internal.Errors.process(Errors.java:315)在
  org.glassfish.jersey.internal.Errors.process(Errors.java:297)在
  org.glassfish.jersey.internal.Errors.process(Errors.java:267)在
  org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:297)
    在
  org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:254)
    在
  org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:1028)
    在
  org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:372)
    在
  org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:381)
    在
  org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:344)
    在
  org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:221)
    在
  org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:800)
    在
  org.eclipse.jetty.servlet.ServletHandler $ CachedChain.doFilter(ServletHandler.java:1669)
    在
  org.eclipse.jetty.servlets.UserAgentFilter.doFilter(UserAgentFilter.java:83)
    在
  org.eclipse.jetty.servlets.GzipFilter.doFilter(GzipFilter.java:300)
    在
  org.eclipse.jetty.servlet.ServletHandler $ CachedChain.doFilter(ServletHandler.java:1652)
    在
  org.eclipse.jetty.websocket.server.WebSocketUpgradeFilter.doFilter(WebSocketUpgradeFilter.java:224)
    在
  org.eclipse.jetty.servlet.ServletHandler $ CachedChain.doFilter(ServletHandler.java:1652)
  
  在
  com.trmsys.cargo.shield.web.filter.PrincipalShiroFilter.doFilter(PrincipalShiroFilter.java:228)
    在
  org.eclipse.jetty.servlet.ServletHandler $ CachedChain.doFilter(ServletHandler.java:1652)
    在
  org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
    在
  com.trmsys.cargo.shield.shiro.web.ShieldFilter.access $ 100(ShieldFilter.java:34)
    在
  com.trmsys.cargo.shield.shiro.web.ShieldFilter $ 1.call(ShieldFilter.java:99)
    在
  org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
    在
  org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
    在
  org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
    在
  com.trmsys.cargo.shield.shiro.web.ShieldFilter.doFilterInternal(ShieldFilter.java:95)
    在
  org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
    在
  org.eclipse.jetty.servlet.ServletHandler $ CachedChain.doFilter(ServletHandler.java:1652)
    在
  com.trmsys.cargo.security.cors.impl.CorsFilter.handleSimpleCORS(CorsFilter.java:345)
    在
  com.trmsys.cargo.security.cors.impl.CorsFilter.doFilter(CorsFilter.java:188)
    在
  org.eclipse.jetty.servlet.ServletHandler $ CachedChain.doFilter(ServletHandler.java:1652)
    在
  com.trmsys.cargo.rs.shared.impl.http.RequestLogFilter.doFilter(RequestLogFilter.java:59)
    在
  org.eclipse.jetty.servlet.ServletHandler $ CachedChain.doFilter(ServletHandler.java:1652)
    在
  org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:585)
    在
  org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:221)
    在
  org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1125)
    在
  org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:515)
    在
  org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:185)
    在
  org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1059)
    在
  org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
    在
  org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:215)
    在
  org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:97)
    在org.eclipse.jetty.server.Server.handle(Server.java:497)处
  org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:310)在
  org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:248)
    在
  org.eclipse.jetty.io.AbstractConnection $ 2.run(AbstractConnection.java:540)
    在
  org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:620)
    在
  org.eclipse.jetty.util.thread.QueuedThreadPool $ 3.run(QueuedThreadPool.java:540)
    在java.lang.Thread.run(Thread.java:745)造成原因:
  java.sql.SQLException:不允许在以下位置进行操作
  oracle.jdbc.driver.OracleStatement.getGeneratedKeys(OracleStatement.java:5174)
    在
  oracle.jdbc.driver.OracleStatementWrapper.getGeneratedKeys(OracleStatementWrapper.java:352)
    在
  org.apache.commons.dbcp.DelegatingStatement.getGeneratedKeys(DelegatingStatement.java:315)
    在
  org.apache.commons.dbcp.DelegatingStatement.getGeneratedKeys(DelegatingStatement.java:315)
    在org.sql2o.Query.executeUpdate(Query.java:522)... 67常见
  框架省略


它仅用于删除。插入和检索运行良好。

我正在搜索这个问题,但唯一的结果是解决了封闭的resulSet问题,这里不是这种情况。

最佳答案

根据错误

operation not allowed org.sql2o.Sql2oException: Error in executeUpdate, operation not allowed at org.sql2o.Query.executeUpdate(Query.java:527) at

我会说删除权限丢失了。将其授予用户,然后重试。

本文翻译自 https://stackoverflow.com/questions/46579558/

网站遵循 CC BY-SA 4.0 协议,转载或引用请注明出处。


相关文章:

java - Spring-MVC:需要最简单的表单处理,绑定和验证示例

java - 着色器Java OpenGL代码内部没有错误,但窗口内部未呈现任何内容

java - YouTube API V3-如何检索标记为垃圾邮件的评论(使用Java)

java - 如何使用Hibernate或JPA动态生成实体集合?

sql - 使用条件更新单个sql查询中的多个列

mysql - 为什么银行或金融公司比其他RDBMS更喜欢Oracle的“核心”系统? [关闭]

sql - Oracle SQL Developer逐步复制数据库

java - 不同OracleDB Connections之间的共享事务

java - 带postgres的Sql2o,查询未返回结果

java - 无法将JDBC-Hikari连接到我的Micronaut应用程序