0

我试图从 mysql 过程中发送一个整数值,该值必须由 Java 类接收。我已经完成了

CREATE DEFINER=`root`@`localhost` PROCEDURE `updateCountry`(o_name varchar(35), u_name varchar(50),m_by varchar(35),out msg int)
BEGIN
if not exists (select country from country where country = u_name) then        
    UPDATE country SET country= u_name, modify_date=now(), modify_by=m_by where country = o_name;    

end if;
if  exists (select country from country where country = u_name) then 
set msg := '1';
end if;
END  

我的java类是:

public void modifyCountry(String mod, String real, String crby)throws Exception {
    Date d = new Date(System.currentTimeMillis());
    System.out.print(d);
    CallableStatement cs = conn
            .prepareCall("{ call updateCountry(?,?,?,?)}");
    cs.setString(1, real);
    cs.setString(2, mod);
//  cs.setDate(3, d);
    cs.setString(3, crby);
    cs.registerOutParameter(4, Types.INTEGER);
    int check = cs.getInt(4);
    System.out.print(check);
    cs.execute();
}

这是我得到的错误

No output parameters returned by procedure.
4

1 回答 1

4

尝试先执行语句然后读取输出参数

于 2013-06-14T10:56:33.020 回答