BLOB作为mybatis中过程调用的参数

时间:2013-08-07 05:21:07

标签: mybatis

这是ProductServices.xml

中的来电
<update id="resetPassword" parameterType="batchReport">
 { call user_account_mng.enc_reset_password(
       #{user_Id,jdbcType=VARCHAR,mode=IN},
   #{encrypted_password,jdbcType=VARCHAR,mode=IN},
   #{usr_id, dbcType=VARCHAR,mode=IN},
    #{salt,jdbcType=VARCHAR,mode=IN},
   #{ret_code,jdbcType=CHAR,mode=OUT},
   #{pgp_encrypted_password,jdbcType=BLOB,mode=IN}
)}

现在BatchReport是一个POJO: (我已经将它的别名声明为batchReport)

 public class BatchReport 
 {
private String user_Id;
private String encrypted_password;
private String usr_id;
private String salt;
private String ret_code;
private byte[] pgp_encrypted_password;
public String getUser_Id() {
    return user_Id;
}
public void setUser_Id(String user_Id) {
    this.user_Id = user_Id;
}
public String getEncrypted_password() {
    return encrypted_password;
}
public void setEncrypted_password(String encrypted_password) {
    this.encrypted_password = encrypted_password;
}
public String getUsr_id() {
    return usr_id;
}
public void setUsr_id(String usr_id) {
    this.usr_id = usr_id;
}
public String getSalt() {
    return salt;
}
public void setSalt(String salt) {
    this.salt = salt;
}
public String getRet_code() {
    return ret_code;
}
public void setRet_code(String ret_code) {
    this.ret_code = ret_code;
}
public byte[] getPgp_encrypted_password() {
    return pgp_encrypted_password;
}
public void setPgp_encrypted_password(byte[] pgp_encrypted_password) {
    this.pgp_encrypted_password = pgp_encrypted_password;
}

}

我的主要课程是这样的:

 <BatchReport batchReport = new BatchReport();
   byte[] byteArray =new byte[]{1,2,3};
   batchReport.setUser_Id("CHI");
   batchReport.setEncrypted_password("97D6B45"); 
   batchReport.setSalt("71L");
   batchReport.setPgp_encrypted_password(byteArray);
   String returnCode = productServiceObj.resetPassword(batchReport);

我收到以下错误: 设置空参数时出错。大多数JDBC驱动程序都要求必须为所有可为空的参数指定JdbcType。原因:java.sql.SQLException:列类型无效

该错误可能涉及com.example.services.ProductServices.resetPassword-Inline

ProductServices是一个声明方法resetPassword的类。 请帮我解决这个BLOB问题。 调用过程中的jdbcType应该是什么。 应该在这个pgp_encrypted_pa​​ssword中传递什么值。

1 个答案:

答案 0 :(得分:0)

好的,我现在找到问题的解决方案.xml文件中查询中的jdbcType保持不变,即BLOB。 接下来,为传入值而设置的类型是byte []。

所以一切都和我掩盖的一样。 实际上存在错误,因为.xml文件返回一个整数,表示查询中更改的行数,并且我已将函数返回类型赋予String,因此这里的问题解决方案应该是Object类型。

相关问题