开发者

Sybase stored procedure insert limit with JDBC driver

开发者 https://www.devze.com 2023-03-28 09:01 出处:网络
I\'m having issues with stored procedures that have a lot of insert statements when using Sybase\'s jdbc driver. After 50-60 inserts, the stored procedure stops execution and returns. See code below.

I'm having issues with stored procedures that have a lot of insert statements when using Sybase's jdbc driver. After 50-60 inserts, the stored procedure stops execution and returns. See code below.

I'm using Sybase Anywhere 10 and their jconn2.jar, but have also tried jconn3.jar.

java code:

String sp = "sp_test";
Statement stmt = con.createStatement();
stmt.execute(sp);
stmt.close();

stored procedure:

create procedure dba.sp_test()
as
begin
  declare @lnCount integer
  select @lnCount = 1
  while (@lnCount <= 1000 )
    begin
      insert into tableTest (pk) values (@lnCount)
      select @lnCount = @lnCount + 开发者_运维问答1
    end
end

After 58 inserts the procedure returns. Doing a select count(*) from tableTest afterward returns a count of 58. There are not SQLExceptions being thrown. I tried putting a begin/commit transaction around the insert, but it didn't make a difference. I've also tried the jodbc driver and it works fine, but I'm not able to use this as a solution because I've had other issues with it.


Using executeUpdate solved the problem:

String sp = "sp_test";
Statement stmt = con.createStatement();
stmt.executeUpdate(sp);
stmt.close();


I believe if you insert con.commit() immediately after stmt.execute() would work too.

0

精彩评论

暂无评论...
验证码 换一张
取 消