473,387 Members | 1,897 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,387 software developers and data experts.

Using JDBC batch

Hi,

(V8.1 Fp2)
Our application uses JDBC batch to execute mutiple insert statements
and we saw a strange thing this morning.

There were 4 SQL Insert statements in the batch, and we know the 2nd
would have
violated a Unique Constraint and failed, but the SQL error returned
was related to the 3rd statement (which had a FK dependent on the 2nd
statement).

This has raised some fundamental questions about DB2 JDBC Dtriver
batch processing.

1. Is it possible the 3rd statement was executed before the 2nd
statement?
2. Do we 'Have' to include BEGIN ATOMIC in the batch statements ?
3. Is there some other explanation why we saw the 3rd statement error
returned
and not the 2nd statement?

Any insight/pointers on this or more generally using JDBC batch
greatly
appreciated.

Paul.
Nov 12 '05 #1
2 6538
Hi,
I am reposting this as we have just witnessed it again, and I just
want
to check if anyone believes this is working as designed/configurable
before I open a formal PMR with IBM.

Thanks.

Paul.

pa**@abacus.co.uk (Paul Reddin) wrote in message news:<1f**************************@posting.google. com>...
Hi,

(V8.1 Fp2)
Our application uses JDBC batch to execute mutiple insert statements
and we saw a strange thing this morning.

There were 4 SQL Insert statements in the batch, and we know the 2nd
would have
violated a Unique Constraint and failed, but the SQL error returned
was related to the 3rd statement (which had a FK dependent on the 2nd
statement).

This has raised some fundamental questions about DB2 JDBC Driver
batch processing.

1. Is it possible the 3rd statement was executed before the 2nd
statement?
2. Do we 'Have' to include BEGIN ATOMIC in the batch statements ?
3. Is there some other explanation why we saw the 3rd statement error
returned
and not the 2nd statement?

Any insight/pointers on this or more generally using JDBC batch
greatly
appreciated.

Paul.

Nov 12 '05 #2
I don't have the answer but i think it would help to know the
driver used? (db2java, db2jcc)
type-2/3, universal/jcc type 4, ...
(to be sure it's supported)

Also verify how the error handling is coded.
What is used in the program.
You trap any BatchUpdateException() ? (SQLException)

Handling an SQLException under the DB2 Universal JDBC Driver
http://www-3.ibm.com/software/data/d...d/cjvjcerr.htm

Behavioral Differences Between the Legacy JDBC Drivers and the Universal
JDBC Drivers
http://publib.boulder.ibm.com/infoce...d/c0010280.htm
see PreparedStatement.executeBatch, Compound SQL, etc.

Batched Update Considerations When Using the Universal JDBC Driver
http://publib.boulder.ibm.com/infoce...d/c0010280.htm
snip. universal JDBC driver always batches nonatomically

Online doc link :
http://java.sun.com/j2se/1.3/docs/api/
http://java.sun.com/j2se/1.4.1/docs/api/
see java.sql

public class BatchUpdateException
extends SQLException
An exception thrown when an error occurs during a batch update operation. In
addition to the information provided by SQLException, a BatchUpdateException
provides the update counts for all commands that were executed successfully
during the batch update, that is, all commands that were executed before the
error occurred. The order of elements in an array of update counts
corresponds to the order in which commands were added to the batch.

After a command in a batch update fails to execute properly and a
BatchUpdateException is thrown, the driver may or may not continue to
process the remaining commands in the batch. If the driver continues
processing after a failure, the array returned by the method
BatchUpdateException.getUpdateCounts will have an element for every command
in the batch rather than only elements for the commands that executed
successfully before the error. In the case where the driver continues
processing commands, the array element for any command that failed is -3.

I remember seeing that the ibm db2 drivers sometimes uses -2, -3 values.
I guess it's the kind of driver that continues processing on error...
although i'm not sure.

PM
Nov 12 '05 #3

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

Similar topics

0
by: mdh | last post by:
I am trying to learn the basics of MVC applications using a Tomcat infrastructure. I'm starting by building a simple application with: * a login.jsp page for a basic login form with a action...
1
by: Howie Goodell | last post by:
Hello -- I am trying to optimise a JDBC connection and an Oracle 9i database for reading millions of records at a time to a 1 Gig PC running Win2K or XP. Two questions: 1. Does anyone have...
5
by: Steve | last post by:
Hi; I went to the microsoft site to try to find a guide to the error messages that the jdbc drivers give ( for sqlserver 2000 ). I had no luck. Does anyone know if there is such a guide? ...
1
by: bogachkov | last post by:
Hello Joe Over the past several years, I have found your responses to jdbc usage/driver related issues to be extremely helpful. I am sure that you're very busy so I will make my question as...
4
by: Dani | last post by:
Hi everyone Description of the problem: Using a PreparedStatement to write down an integer (int) plus a timestamp for testing purposes. When read out again the integer looks very different. We...
3
by: r_stringer66 | last post by:
Hi, I am trying to connect to a db2 database via a jdbc application and this is the following error I get: Exception : CLI0615E Error receiving from socket, server is not responding....
0
by: usenet | last post by:
Hi. I have a DB2 stored procedure that I call using JDBC. Now I'm trying to batch the call. This is done by the book: stmt = connection.prepareCall(" ... "); stmt.setString(1, "foo");...
3
by: Klint Gore | last post by:
Does anyone know of a mailing list for application developers using postgres? It'd probably be more relevant than pgsql-general for my question. Failing that, what do people use to generate...
1
by: kommaraju | last post by:
iam a starter to db2 & jdbc.i have a servlet program which connects to ibm db2 using jdbc.when i run this using apache tomcat 4.1.34 , it is showing a error message of HTTP STATUS 500 my jdbc...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.