0

调用此方法后,将调用存储过程(它将 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
4

1 回答 1

1

如果您的过程的第一个结果不是ResultSet,则返回值为false.

PreparedStatement.execute()

于 2013-02-17T22:43:19.287 回答