The user specified as a definer ('gw_db_user'@'%') does not exist异常分析

来源:互联网 发布:网络养老管理系统 编辑:程序博客网 时间:2024/05/08 21:44

异常信息如下:

2017-02-07 15:25:38,679 DEBUG java.sql.Connection - {conn-103263} Preparing Statement:       SELECT FUNC_GETCHARGE(?,?) as money from dual     

2017-02-07 15:25:38,679 DEBUG java.sql.PreparedStatement - {pstm-103264} Executing Statement:       SELECT FUNC_GETCHARGE(?,?) as money from dual     
2017-02-07 15:25:38,679 DEBUG java.sql.PreparedStatement - {pstm-103264} Parameters: [assure, 30000.0]
2017-02-07 15:25:38,679 DEBUG java.sql.PreparedStatement - {pstm-103264} Types: [java.lang.String, java.math.BigDecimal]
com.ibatis.common.jdbc.exception.NestedSQLException:   
--- The error occurred in sqlmap/mysql/chargeset.xml.  
--- The error occurred while applying a parameter map.  
--- Check the Charge.getChargeMoney-InlineParameterMap.  
--- Check the statement (query failed).  
--- Cause: java.sql.SQLException: The user specified as a definer ('gw_db_user'@'%') does not exist
    at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryWithCallback(GeneralStatement.java:185)
    at com.ibatis.sqlmap.engine.mapping.statement.GeneralStatement.executeQueryForObject(GeneralStatement.java:104)
    at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:566)
    at com.ibatis.sqlmap.engine.impl.SqlMapExecutorDelegate.queryForObject(SqlMapExecutorDelegate.java:541)
    at com.ibatis.sqlmap.engine.impl.SqlMapSessionImpl.queryForObject(SqlMapSessionImpl.java:106)

    at com.ibatis.sqlmap.engine.impl.SqlMapClientImpl.queryForObject(SqlMapClientImpl.java:83)


当时出现这个问题的时候很困惑,自己排查了一会儿,无果,找了DBA询问了下原因,结果恍然大悟。

首先数据库连接正常,其他表的查询正常,只有涉及到该函数时才抛出异常。

其次数据库中函数FUNC_GETCHARGE存在,去除因函数不存在原因导致异常。


问题的原因是:

建立该函数的数据库用户被删除了,执行该函数时,函数找不到创建它的用户,就抛出以上异常。


解决方法:

创建一个用户名为 gw_db_user 的用户,就能解决问题。

0 0
原创粉丝点击