No value specified for parameter 15 troubleshooting process

exception information

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

If No value specified for parameter 15 appears , it must be that the parameter number 15 (starting from 0) is missing.

The SQL printed by mybatis has 30 question marks, while the following parameters only have 29. It really didn't match up.

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)

Write two records at a time, one has value and the other has no value, and then check the typehandler of the corresponding field

	@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));
	}

If the parameter is empty, return directly. No value is set for the corresponding parameter bit of PreparedStatement, even if it is null . So the problem is here.

Guess you like

Origin blog.csdn.net/bruce128/article/details/126779120