No value specified for parameter 15排查过程

异常信息

org.springframework.jdbc.BadSqlGrammarException: 
### Error updating database.  Cause: java.sql.SQLException: No value specified for parameter 15
### The error may involve com.jr.identity.manage.dao.FlowConfigManageDao.addSceneConfigRel-Inline
### The error occurred while setting parameters
### SQL: INSERT INTO table(         flow_value,         flow_name,         flow_order,         flow_interval,         flow_parent,         flow_type,         flow_parent_name,         flow_record_sence,         flow_record_node,         app_id,         delete_flag,         raw_add_time,         raw_update_time,         recognized_flag,         time_interval,         flow_name_desc,         authorization_tip,         version,         agreements)         VALUES                        (             ?,             ?,             ?,             '1',             ?,             ?,             ?,             ?,             ?,             ?,             '0',             now(),             now(),             ?,             ?,             ?,             ?,             ?,             ?             )          ,              (             ?,             ?,             ?,             '1',             ?,             ?,             ?,             ?,             ?,             ?,             '0',             now(),             now(),             ?,             ?,             ?,             ?,             ?,             ?             )
### Cause: java.sql.SQLException: No value specified for parameter 15
; bad SQL grammar []; nested exception is java.sql.SQLException: No value specified for parameter 15

如果出现了 No value specified for parameter 15, 那一定是15(从0号开始)号位的参数缺失。

mybatis打印出的SQL的问号有30个,而下面的参数只有29个。确实是没对应上。

09-09 10:43:36.005 [http-nio-8080-exec-2][] DEBUG com.jr.identity.manage.dao.FlowConfigManageDao.addSceneConfigRel - ==>  Preparing: INSERT INTO table( flow_value, flow_name, flow_order, flow_interval, flow_parent, flow_type, flow_parent_name, flow_record_sence, flow_record_node, app_id, delete_flag, raw_add_time, raw_update_time, recognized_flag, time_interval, flow_name_desc, authorization_tip, version, agreements) VALUES ( ?, ?, ?, '1', ?, ?, ?, ?, ?, ?, '0', now(), now(), ?, ?, ?, ?, ?, ? ) , ( ?, ?, ?, '1', ?, ?, ?, ?, ?, ?, '0', now(), now(), ?, ?, ?, ?, ?, ? )
09-09 10:43:36.025 [http-nio-8080-exec-2][] DEBUG com.jr.identity.manage.dao.FlowConfigManageDao.addSceneConfigRel - ==> Parameters: enterprisefourelements(String), 企业四要素(String), 0(Integer), 138(String), 企业实名(String), 场景21-法人刷脸2(String), 274(String), 1738(String), zwj(String), 0(String), 0(String), 企业四要素(String), (String), 3(Integer), legalpersonface(String), 法人刷脸(String), 1(Integer), 138(String), 非个人与企业(String), 场景21-法人刷脸2(String), 274(String), 1731(String), zwj(String), 0(String), 0(String), 法人刷脸(String), 当前业务需要人脸识别验证您的身份信息,请确保为${enterpriseLegalName}本人操作(String), 3(Integer), [{"agreementId":36,"agreementName":"隐私协议2","flowValue":"legalpersonface","ossFileId":2603004}](String)

一次写两条记录,一条有值一条没值,再排查对应字段的typehandler

	@Override
	public void setNonNullParameter(PreparedStatement ps, int i, List<AgreementParam> parameter, JdbcType jdbcType) throws SQLException {
    
    
		if (CollectionUtils.isEmpty(parameter)) {
    
    
			return;
		}
		
		ps.setString(i, JSON.toJSONString(parameter));
	}

如果参数为空,直接return了。没有给PreparedStatement对应参数位设置值,即便是null也没有。所以问题在这里。

猜你喜欢

转载自blog.csdn.net/bruce128/article/details/126779120