try (PreparedStatement statement = connection.prepareStatement("/*#mycat: sql=SELECT 1 FROM travelrecord where id=1 */set @out='2222222222',@id='111111111111'; call pro_2 (@id,@out);select @out")) {
statement.execute();
ResultSet resultSet = statement.getResultSet();
while (resultSet.next()){
String string = resultSet.getString(1);
System.out.println(string+":"+string);
}
}
/*#mycat: sql=SELECT 1 FROM travelrecord where id=1 */set @out='2222222222',@id='111111111111'; call pro_2 (@id,@out);select @out";
sql=SELECT 1 FROM travelrecord where id=1
用于计算路由
如果是写操作,请开启事务或者
Update travelrecord set id = 1 where id=1
使用更新语句、删除语句等指定路由
set @out='2222222222',@id='111111111111';
设置参数变量
语法符合mysql中的set语法,值的类型就是该变量的值类型(无论是in或者out)
支持整型,浮点,字段串类型
call pro_2 (@id,@out);
调用存储过程
select @out;
返回值
当set @out='2222222222',@id='111111111111';中的变量名在select语句中的时候,则会自动变成out变量,反之,就是in变量
一个变量不能同时为in和out