[英]how procedure return out parameter in mysql to java
Iam trying to send an integer value from mysql Procedure which must be recieved by Java class. 我试图从mysql Procedure发送一个整数值,Java类必须接收该整数值。 this i'hv done
我完成了
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
and my java class is : 我的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();
}
And this is the error which im getting 这是我正在得到的错误
No output parameters returned by procedure.
尝试先执行该语句,然后读取输出参数
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.