MySQL存储过程返回false

时间:2013-02-17 22:37:52

标签: mysql stored-procedures jdbc

调用此方法后,将调用存储过程(它将1000条新记录放入db)。但布尔是假的,为什么?

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

1 个答案:

答案 0 :(得分:1)

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

<强> PreparedStatement.execute()