调用此方法后,将调用存储过程(它将 1000 条新记录放入 db)。但是 bool 是假的,为什么?
public void loadTestData() throws SQLException {
CallableStatement cStmt = connection.prepareCall("{call loadTestData }");
boolean bool = cStmt.execute();
if (bool) System.out.println("test data is loaded");
else System.out.println("test data is not loaded!");
}
程序在这里:
CREATE DEFINER=`root`@`localhost` PROCEDURE `loadTestData`()
BEGIN
DECLARE x INT;
delete from user where id<5000;
SET x = 0;
WHILE x <= 100 DO
insert into user (name, description) VALUES(
concat("name", x),
concat("description", x)
);
SET x = x + 1;
END WHILE;
END