java.sql.SQLException:preparestatement 发生索引::4 处缺少 IN 或 OUT 参数错误
strInsertQuery="INSERT INTO SYNPACKAGEFREEUSAGEMAPPING (PACKAGEID,SERVICEID,PRIORITY,MAPPINGID,ATTRIBUTEVALUE,FREEUSAGE,UOM,PARAMSTR1,UNITCREDITPOLICYDETAILID) VALUES (?,?,?,?,?,?,?,?,?)";
newPstmt=newCon.prepareStatement(strInsertQuery);
newPstmt.setString(1,strProductId);
newPstmt.setString(2,strUPGServiceId);
newPstmt.setInt(3,0);
if(FieldMappingrs.next())
{
newPstmt.setLong(4,FieldMappingrs.getLong(1));
}
newPstmt.setString(5,ucpDetailData.getCreditattributevalue());
for(Iterator itrColUnitCreditDetail=ucpData.iterator();itrColUnitCreditDetail.hasNext();)
{
unitCreditData = (UnitCreditDetailData)itrColUnitCreditDetail.next();
if(ucpDetailData.getUnitcreditpolicydetailid().equals(unitCreditData.getUnitcreditpolicydetailid()))
{
debugLog(PackageConstant.PACKAGE_MODULE_NAME,"ServicePackageSessionBean:createFreeUsageServiceDetails() unitCreditData "+ unitCreditData);
newPstmt.setDouble(6,unitCreditData.getEndvalue());
}
debugLog(PackageConstant.PACKAGE_MODULE_NAME,"Insert record successfull"+ ucpDetailData);
}
newPstmt.setString(7,ucpDetailData.getUom());
newPstmt.setString(8,ucpDetailData.getCreditattribute());
newPstmt.setString(9,ucpDetailData.getUnitcreditpolicydetailid());
newPstmt.executeUpdate();
strInsertQuery="INSERT INTO SYNPACKAGEFREEUSAGEMAPPING (PACKAGEID,SERVICEID,PRIORITY,MAPPINGID,ATTRIBUTEVALUE,FREEUSAGE,UOM,PARAMSTR1,UNITCREDITPOLICYDETAILID) VALUES (?,?,?,?,?,?,?,?,?)";
newPstmt=newCon.prepareStatement(strInsertQuery);
newPstmt.setString(1,strProductId);
newPstmt.setString(2,strUPGServiceId);
newPstmt.setInt(3,0);
if(FieldMappingrs.next())
{
newPstmt.setLong(4,FieldMappingrs.getLong(1));
}
newPstmt.setString(5,ucpDetailData.getCreditattributevalue());
for(Iterator itrColUnitCreditDetail=ucpData.iterator();itrColUnitCreditDetail.hasNext();)
{
unitCreditData = (UnitCreditDetailData)itrColUnitCreditDetail.next();
if(ucpDetailData.getUnitcreditpolicydetailid().equals(unitCreditData.getUnitcreditpolicydetailid()))
{
debugLog(PackageConstant.PACKAGE_MODULE_NAME,"ServicePackageSessionBean:createFreeUsageServiceDetails() unitCreditData "+ unitCreditData);
newPstmt.setDouble(6,unitCreditData.getEndvalue());
}
debugLog(PackageConstant.PACKAGE_MODULE_NAME,"Insert record successfull"+ ucpDetailData);
}
newPstmt.setString(7,ucpDetailData.getUom());
newPstmt.setString(8,ucpDetailData.getCreditattribute());
newPstmt.setString(9,ucpDetailData.getUnitcreditpolicydetailid());
newPstmt.executeUpdate();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,看看这个:
所以您有条件地设置参数 4。
如果
FieldMappingsrs.next()
返回 false,您想要插入什么? (我怀疑这就是正在发生的情况。)尝试在else
块中将其设置为适当的值。Well, look at this:
So you're conditionally setting parameter 4.
What do you want to insert if
FieldMappingsrs.next()
returns false? (I suspect this is what is happening.) Try setting it to an appropriate value in anelse
block.你的问题就在这个块上,
正如你所看到的,如果
.next()
返回false
,你将不会在index
4处传递参数。我建议,如果您可以传递给该表 0 而不是 null,请使用 this
或者如果它是必需值,则只需抛出一个
异常
。Your problem is just at this block
As you see if
.next()
returnsfalse
you won't be passing the parameter atindex
4.I suggest to, if you can pass to that table 0 instead of null use this
Or if it is required value, just throw an
exception
.