473,555 Members | 2,336 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

UDB 8.1 and multiple connections

Hi all,

I believe I'm seeing a bug in DB2 UDB 8.1, or in any case
a behaviour different from DB2 UDB 7.1.

I have a small C program, containing a mixture of ESQLC and CLI
calls, that opens two separate connections to the same database.
On connection 1, I insert a row in table ENT1.
On connection 2, I insert a row in table ENT2.
On connection 1, I do a commit.

===> At this point, connection 2 has also seen a commit,
===> because the row in ENT2 can be selected from another process.

As I'm using default isolation level, this should not happen, right ?

However, when I compile and run the same program against a DB2
7.1 client (that connects to the same 8.1 database), it works as
expected !!! That is, when connection 1 has been committed, table ENT2
locked. Only when a rollback has been sent to connection2, table
ENT2 can be accessed from another process, and it does not contain the
inserted row.

Additionally, with UDB 8.1 I get a crash when trying to disconnect
connection 2 ( ret = SQLDisconnect(h Dbc2); ). With UDB 7.1 this does
not produce a crash or error.

Any ideas would be most appreciated. The C code and precompile command
is attached.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sqlenv.h>
#include <sqlda.h>
#include <sqlcli1.h>

char* D1 = "worktodo";
char* U1 = "db2admin";
char* P1 = "db2admin";

char* D2 = "worktodo";
char* U2 = "db2admin";
char* P2 = "db2admin";


main ()
SQLHANDLE hEnv1 = 0;
SQLHANDLE hEnv2 = 0;
SQLHANDLE hDbc1 = 0;
SQLHANDLE hDbc2 = 0;
int ret;

Environment/connection 1
ret = SQLAllocHandle( SQL_HANDLE_ENV, SQL_NULL_HANDLE , &hEnv1);
ret = SQLSetEnvAttr(h Env1, SQL_CONNECTTYPE ,
ret = SQLSetEnvAttr(h Env1, SQL_ATTR_SYNC_P OINT,
ret = SQLSetEnvAttr(h Env1, SQL_ATTR_MAXCON N, (SQLPOINTER) 0, 0);
ret = SQLAllocHandle( SQL_HANDLE_DBC, hEnv1, &hDbc1);
ret = SQLConnect (hDbc1, D1, (short)strlen(D 1), U1,
(short)strlen(U 1), P1, (short)strlen(P 1));
Environment/connection 2

ret = SQLAllocHandle( SQL_HANDLE_ENV, SQL_NULL_HANDLE , &hEnv2);
ret = SQLSetEnvAttr(h Env2, SQL_CONNECTTYPE ,
ret = SQLSetEnvAttr(h Env2, SQL_ATTR_SYNC_P OINT,
ret = SQLSetEnvAttr(h Env2, SQL_ATTR_MAXCON N, (SQLPOINTER) 0, 0);
ret = SQLAllocHandle( SQL_HANDLE_DBC, hEnv2, &hDbc2);
ret = SQLConnect (hDbc2, D2, (short)strlen(D 2), U2,
(short)strlen(U 2), P2, (short)strlen(P 2));
Switch to environment 1 and insert a row in table ENT1
ret = SQLSetConnectio n(hDbc1);

Switch to environment 2 and insert a row in table ENT2
ret = SQLSetConnectio n(hDbc2);

Switch to environment 1 and issue COMMIT
ret = SQLSetConnectio n(hDbc1);
ret = SQLTransact(hEn v1, hDbc1, SQL_COMMIT);
/*************** *************** *************** *************** ***************
At this point, the row inserted via path 2 has also been committed !
Is that a bug, or what ?
*************** *************** *************** *************** ***************/

Switch to environment 2 and issue ROLLBACK
ret = SQLSetConnectio n(hDbc2);
ret = SQLTransact(hEn v2, hDbc2, SQL_ROLLBACK);

/* Clean up */

ret = SQLDisconnect(h Dbc1);
ret = SQLDisconnect(h Dbc2); /* This crashes with UDB 8.1 but not
with UDB 7.1 */
ret = SQLFreeConnect( hDbc1);
ret = SQLFreeConnect( hDbc2);
ret = SQLFreeEnv(hEnv 1);
ret = SQLFreeEnv(hEnv 2);
Precompile command:

set DB2_HOME=d:\dat abase\db2
set BAT=db2tmp.bat

echo set DB2_HOME=d:\dat abase\db2 > %BAT%
echo SET PATH=%DB2_HOME% \bin;$%PATH% >> %BAT%
echo @echo on >> %BAT%
echo db2 connect to worktodo user db2admin using db2admin >> %BAT%
echo db2 prep db2paths.sqc OUTPUT db2paths.c BINDFILE USING
echo db2 bind db2paths.bnd ISOLATION CS GRANT PUBLIC >> %BAT%

%DB2_HOME%\bin\ db2cmd -c -w -i %BAT%
Nov 12 '05 #1
0 1499

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

Similar topics

by: noah | last post by:
Does PHP have a feature to associate Cookie sessions with a persistent database connection that will allow a single transaction across multiple HTTP requests? Here is how I imagine my process: I have an series of interactive HTML forms. The user begins a Cookie session. A database connection is opened and a transaction is begun. After the...
by: Gabriel Jiva | last post by:
I have a Python app, spam.py, that uses a C shared library, eggs.so. This shared library is an interface that makes connections to another system (Ham), and among other things uses callback functions. Therefore, if I want to make multiple connections to Ham, I need eggs.so to be instantiated in memory multiple times so that everything works...
by: Paul A. Steckler | last post by:
I need to write a TCP/IP server in C# that can handle multiple connections. My first try was to use TCPListener instances in multiple .NET threads. Of course, I got an exception from System.Net.Sockets about multiple sockets on the same port. This happens even with a single listener in multiple Win32 processes. Will I get better results...
by: Quiet Man | last post by:
Hi all, I'm designing a fairly simple service that will run on W2K/SP4 and W2K3 servers. It's job is to be a very specialized database server that listens on a given IP address / TCP port and handles multiple connections. Client programs will make a connection and pass text strings to the service, which will then return a value for each of...
by: Abhishek Srivastava | last post by:
Hello All, In IIS 6.0 We have a concept of worker processes and application pools. As I understand it, we can have multiple worker process per appliction pool. Each worker process is dedicated to a pool. If I assign only one application to a applicaton pool and have multiple worker processes assigned to that pool. Will my application be...
by: jasonsgeiger | last post by:
From: "Factor" <jasonsgeiger@gmail.com> Newsgroups: microsoft.public.in.csharp Subject: Multiple Clients, One port Date: Wed, 19 Apr 2006 09:36:02 -0700 I'm been working with sockets for a short while now using a server program a former coworker started. The program listens on a port for incomming connections. When a valid connection is...
by: Yelena Varshal via AccessMonster.com | last post by:
Hello, What are the pre-requisites / conditions for the ability to create multiple connections to MS ACCESS database and what is the precedence of its application? adModeShareDenyNone in the code, Exclusive checkbox in the ODBC source, Tools->Options->Advanced->Shared in the Database Options, what else? I have a problem when multiple...
by: D. Yates | last post by:
Hi, I'm about to embark on a project that will both send and receive information to/from our client computers in the field. The area that I still need to finalize is the method of communication and
by: sracherla | last post by:
I am trying to write a simple windows service that accepts an incoming request; receives a string input and sends a string output. I need this connection to stay alive until the client closes it. Also, I need the service to accept multiple incoming requests. Here is the code: public void Listen() { #region Commented Code
by: keerthyragavendran | last post by:
hi i'm downloading a single file using multiple threads... how can i specify a particular range of bytes alone from a single large file... for example say if i need only bytes ranging from 500000 to 3200000 of a file whose size is say 20MB... how do i request a download which starts directly at 500000th byte... thank u cheers
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.