473,398 Members | 2,125 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

CallableStatement.executeBatch() problem

Hi, I'm still having problems with use of executeBatch with stored
procedures. I've tried the following code out against DB2 V7 for OS/390
and V8 for NT; the same problem exists either way; only the insert goes
on the table and the rest do not appear, despite an apparently
successful commit.

Can anyone help please? Is there anything wrong with my code?

I'm using the type 2 driver, JDBC 2 (db2java.zip), but it's been against
as I say different versions of DB2 and different stored procedures
written in different languages (COBOL and SQL PL), so it seems likely
(although not impossible) that these aren't the issue.

Many thanks in advance.

Keith.

public static void main(String[] args) throws Exception {

Connection connection = DriverManager.getConnection("jdbc:db2:SAMPLE");
connection.setAutoCommit(false);

short i = 1;

CallableStatement cs = connection.prepareCall("{CALL
KEITH.INSERTSTAFF(?)}");

for (int x=1; x<100; x++) {
cs.setShort(1, i);
i++;
cs.addBatch();
}

int[] results = cs.executeBatch();

connection.commit();

}
The procedure itself is trivial:

CREATE PROCEDURE KEITH.INSERTSTAFF (IN ID SMALLINT)

DYNAMIC RESULT SETS 0
MODIFIES SQL DATA

P1: BEGIN

INSERT INTO STAFF VALUES (ID, 'Keith', 20, 'Mgr', 5, 30000.00, 100.00);

END P1

Nov 12 '05 #1
1 3093
To answer my own question for future reference, it looks as though the
type 2 driver doesn't support it.

I would have preferred it if some exception were thrown rather than
continuing successfully but only committing one of the changes!

Turns out we need to look into using the type 4 driver.

Keith.
Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Prashant Kumar | last post by:
Hi: I get the following exception from oracle. It seems to be happening during a rollback of a transaction, while doing an executeBatch() Has anyone seen this before ? Thanks much!...
8
by: Javauser | last post by:
Hi there we are getting the following db2 error on executeBatch() method that inserts n rows on a table (where n is between 50 and 200). SQL0911N The current transaction has been rolled...
0
by: Keith Watson | last post by:
Hi, we are having some difficulty using the JDBC CallableStatement.executeBatch() method to call SQL stored procedures hosted on DB2 V7 for z/os. The problem exists calling COBOL stored procedures...
2
by: Kent Lewandowski | last post by:
hi all, Recently I wrote some stored procedures using java jdbc code (admittedly my first stab) and then tried to implement the same within java packages (for code reuse). I encountered...
4
by: technocrat | last post by:
I am trying to update a million rows in a table and doing this reading from a file which has the record pkids and constructing a preparedstatemtn with that pkid and adding it to the batch......
0
by: mattynott | last post by:
Hi I've got a section of code that needs to run a few queries. I'm trying to run the addBatch and executeBatch methods as shown below: conn6 = ods.getConnection(); stmt6 =...
3
by: jynxxxed | last post by:
I've been reviewing some of the threads here and applying some of the advice and still getting the same error. 15:50:26,935 INFO java.sql.SQLException: Could not find stored procedure...
1
by: kandi | last post by:
Hi, I have added 10 sql queries in a statement using addBatch method, when i go for executing them using executeBatch method, if i stops java server and the executeBatch method has not...
7
by: Otto Carl Marte | last post by:
Hi, When using a CallableStatement with the IBM DB2 Universal JDBC Driver the executeUpdate and getUpdateCount() methods on CallableStatement always return -1. According to the JDBC...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.