java.sql.SQLException: The user specified as a definer ('userxxx'@'%') does not exist


java.sql.SQLException: The user specified as a definer ('userxxx'@'%') does not exist

 

Java接口在執行查詢的時候報錯如下:

java.sql.SQLException: The user specified as a definer ('userxxx'@'%') does not exist

錯誤詳情:

2019-12-24 14:18:44 [ ERROR ]  [DUBBO] Got unchecked and undeclared exception which called by 10.11.22.2. service: com.imodule.report.service.report.workflow.ReportService, method: queryNewSingleCase, exception: org.springframework.jdbc.UncategorizedSQLException: SqlMapClient operation; uncategorized SQLException for SQL []; SQL state [HY000]; error code [1449];   
--- The error occurred in com/imodule/report/dao/sqlmap/kpiRptnwf.xml.  
--- The error occurred while applying a parameter map.  
--- Check the kpiRptnwf.queryNewSingleCase-InlineParameterMap.  
--- Check the statement (query failed).  
--- Cause: java.sql.SQLException: The user specified as a definer ('userxxx'@'%') does not exist; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:   
--- The error occurred in com/imodule/report/dao/sqlmap/kpiRptnwf.xml.  
--- The error occurred while applying a parameter map.  
--- Check the kpiRptnwf.queryNewSingleCase-InlineParameterMap.  
--- Check the statement (query failed).  
--- Cause: java.sql.SQLException: The user specified as a definer ('userxxx'@'%') does not exist, dubbo version: 2.4.9, current host: 10.11.22.2
org.springframework.jdbc.UncategorizedSQLException: SqlMapClient operation; uncategorized SQLException for SQL []; SQL state [HY000]; error code [1449];   
--- The error occurred in com/imodule/report/dao/sqlmap/kpiRptnwf.xml.  
--- The error occurred while applying a parameter map.  
--- Check the kpiRptnwf.queryNewSingleCase-InlineParameterMap.  
--- Check the statement (query failed).  
--- Cause: java.sql.SQLException: The user specified as a definer ('userxxx'@'%') does not exist; nested exception is com.ibatis.common.jdbc.exception.NestedSQLException:   
--- The error occurred in com/imodule/report/dao/sqlmap/kpiRptnwf.xml.  
--- The error occurred while applying a parameter map.  
--- Check the kpiRptnwf.queryNewSingleCase-InlineParameterMap.  
--- Check the statement (query failed).  
--- Cause: java.sql.SQLException: The user specified as a definer ('userxxx'@'%') does not exist
        at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:84)
        at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
        at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:81)
        at com.imodule.frame.dao.ClioSqlMapClient.execute(ClioSqlMapClient.java:153)
        at com.imodule.frame.dao.ClioSqlMapClient.queryForList(ClioSqlMapClient.java:247)
        at com.imodule.report.dao.impl.KPIRptnwfDao.queryNewSingleCase(KPIRptnwfDao.java:174)
        at com.imodule.report.service.report.workflow.ReportServiceImpl.queryNewSingleCase(ReportServiceImpl.java:1035)
        at com.alibaba.dubbo.common.bytecode.Wrapper10.invokeMethod(Wrapper10.java)
        at com.alibaba.dubbo.rpc.proxy.javassist.JavassistProxyFactory$1.doInvoke(JavassistProxyFactory.java:46)
        at com.alibaba.dubbo.rpc.proxy.AbstractProxyInvoker.invoke(AbstractProxyInvoker.java:72)
        at com.alibaba.dubbo.rpc.protocol.InvokerWrapper.invoke(InvokerWrapper.java:53)
        at com.alibaba.dubbo.rpc.filter.ExceptionFilter.invoke(ExceptionFilter.java:64)
        at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
        at com.alibaba.dubbo.monitor.support.MonitorFilter.invoke(MonitorFilter.java:75)
        at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
        at com.alibaba.dubbo.rpc.filter.TimeoutFilter.invoke(TimeoutFilter.java:42)
        at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
        at com.jd.bdp.hydra.dubbo.HydraFilter.invoke(HydraFilter.java:75)
        at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
        at com.alibaba.dubbo.rpc.protocol.dubbo.filter.TraceFilter.invoke(TraceFilter.java:78)
        at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
        at com.alibaba.dubbo.rpc.filter.ExecuteLimitFilter.invoke(ExecuteLimitFilter.java:50)
        at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
        at com.alibaba.dubbo.rpc.filter.ContextFilter.invoke(ContextFilter.java:60)
        at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
        at com.alibaba.dubbo.rpc.filter.GenericFilter.invoke(GenericFilter.java:112)
        at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
        at com.alibaba.dubbo.rpc.filter.ClassLoaderFilter.invoke(ClassLoaderFilter.java:38)
        at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
        at com.alibaba.dubbo.rpc.filter.EchoFilter.invoke(EchoFilter.java:38)
        at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper$1.invoke(ProtocolFilterWrapper.java:91)
        at com.alibaba.dubbo.rpc.protocol.dubbo.DubboProtocol$1.reply(DubboProtocol.java:108)
        at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.handleRequest(HeaderExchangeHandler.java:84)
        at com.alibaba.dubbo.remoting.exchange.support.header.HeaderExchangeHandler.received(HeaderExchangeHandler.java:170)
        at com.alibaba.dubbo.remoting.transport.DecodeHandler.received(DecodeHandler.java:52)
        at com.alibaba.dubbo.remoting.transport.dispather.ChannelEventRunnable.run(ChannelEventRunnable.java:82)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: com.ibatis.common.jdbc.exception.NestedSQLException:   
--- The error occurred in com/imodule/report/dao/sqlmap/kpiRptnwf.xml.  
--- The error occurred while applying a parameter map.  
--- Check the kpiRptnwf.queryNewSingleCase-InlineParameterMap.  
--- Check the statement (query failed).  
--- Cause: java.sql.SQLException: The user specified as a definer ('userxxx'@'%') does not exist
        at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryWithCallback(MappedStatement.java:201)
        at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryForList(MappedStatement.java:139)
        at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:567)
        at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForList(SqlMapExecutorDelegate.java:541)
        at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForList(SqlMapSessionImpl.java:118)
        at com.imodule.frame.dao.ClioSqlMapClient$3.doInSqlMapClient(ClioSqlMapClient.java:249)
        at com.imodule.frame.dao.ClioSqlMapClient$3.doInSqlMapClient(ClioSqlMapClient.java:247)
        at com.imodule.frame.dao.ClioSqlMapClient.execute(ClioSqlMapClient.java:150)
        ... 35 more
Caused by: java.sql.SQLException: The user specified as a definer ('userxxx'@'%') does not exist
        at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:957)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3878)
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3814)
        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2478)
        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2625)
        at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2551)
        at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1861)
        at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1192)
        at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.execute(NewProxyPreparedStatement.java:989)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at com.ibatis.common.jdbc.logging.PreparedStatementLogProxy.invoke(PreparedStatementLogProxy.java:62)
        at com.sun.proxy.$Proxy17.execute(Unknown Source)
        at com.ibatis.sqlmap.engine.execution.SqlExecutor.executeQuery(SqlExecutor.java:185)
        at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.sqlExecuteQuery(MappedStatement.java:221)
        at com.ibatis.sqlmap.engine.mapping.statement.MappedStatement.executeQueryWithCallback(MappedStatement.java:189)
        ... 42 more

一開始是懷疑當前接口調用的sql腳本里面是不是包含了函數(存儲過程之類的),仔細檢查后發現當前接口的sql里面沒有類似的調用呀.....

然后才發現是數據庫用戶名變更,在定義的函數里面沒有變更對應的數據庫用戶名

eg: 原來數據庫中的用戶是 useryyy ,定義函數的時候也是用的 useryyy ;后來數據庫變更,將用戶useryyy改為了userxxx,但是函數的定義用戶沒有更改,還是原來的用戶 useryyy。

 

解決方案:

使用root用戶登錄數據庫,將對應的函數定義者更改為 新的用戶即可。(useryyy --> userxxx)

參考下圖: (將下圖的定義者更改為當前登錄數據庫(需要從數據庫中查詢數據的用戶)的用戶即可)

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM