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

SQLJ - DefaultContext Synchornization

Hello

I have just found this advice on the net:
http://www.share.org/proceedings/sh98/data/S1326.PDF

I'm interested mainly in page 19:
Use explicit connection context objects
If connection context object is omitted
a default connection context object is used
default connection context is not thread-safe
can create throughput bottleneck
Example of explicit connection context
// Connection context declaration
#sql context ctx;
...
//get context
myconn=new ctx(Conn1);
...
//use context in SQL
#sql [myconn] {set transaction isolation level read committed};
...
#sql [myconn] cursor001 = {SELECT FKEY,FSMALLINT,FINT
FROM WRKTB01 WHERE FKEY >= :wfkey};
...
//close context but keep database connection
myconn.close(ConnectionContext.KEEP_CONNECTION);
According to the introduction, this advice is just intended for z/OS.
But I thought it may be applicable to DB on Linux or Windows also.

Until now I have written stored procedures like this:
ConnectionContext context = DefaultContext.getDefaultContext();
Connection con = context.getConnection();
#sql{ static sql here};


Looking at the precompiler output, I see that the operations on the
ExecutionContext are in a synchronized codeblock.

If I change my code to use an explicit context, the call to
sqlj.runtime.ref.DefaultContext.getDefaultContext( ); isn't made
anymore, but the rest of the code stays the same (and also the
synchronized codeblock for the ExecutionContext).

So I expect no performance gain because the synchronization overhead
is done anyway (which shouldn't be because I assume I needn't thread
safety for my explicit context object)?

Maybe anyone is able to provide further information on this subject?
Thank you.
Nov 12 '05 #1
2 3497
For db2 unix/windows you MUST use an explicit context in version 8 if
you're running your sqlj routines threadsafe (this is the default for
java in v8). If you don't create an expclit context, different threads
can end up closing each others cursors etc.

Almund Sebi wrote:
Hello

I have just found this advice on the net:
http://www.share.org/proceedings/sh98/data/S1326.PDF

I'm interested mainly in page 19:

Use explicit connection context objects
If connection context object is omitted
a default connection context object is used
default connection context is not thread-safe
can create throughput bottleneck
Example of explicit connection context
// Connection context declaration
#sql context ctx;
...
//get context
myconn=new ctx(Conn1);
...
//use context in SQL
#sql [myconn] {set transaction isolation level read committed};
...
#sql [myconn] cursor001 = {SELECT FKEY,FSMALLINT,FINT
FROM WRKTB01 WHERE FKEY >= :wfkey};
...
//close context but keep database connection
myconn.close(ConnectionContext.KEEP_CONNECTION );

According to the introduction, this advice is just intended for z/OS.
But I thought it may be applicable to DB on Linux or Windows also.

Until now I have written stored procedures like this:

ConnectionContext context = DefaultContext.getDefaultContext();
Connection con = context.getConnection();
#sql{ static sql here};

Looking at the precompiler output, I see that the operations on the
ExecutionContext are in a synchronized codeblock.

If I change my code to use an explicit context, the call to
sqlj.runtime.ref.DefaultContext.getDefaultContext( ); isn't made
anymore, but the rest of the code stays the same (and also the
synchronized codeblock for the ExecutionContext).

So I expect no performance gain because the synchronization overhead
is done anyway (which shouldn't be because I assume I needn't thread
safety for my explicit context object)?

Maybe anyone is able to provide further information on this subject?
Thank you.


Nov 12 '05 #2
Sean McKeough <mc******@nospam.ca.ibm.com> wrote in message news:<bo**********@hanover.torolab.ibm.com>...
For db2 unix/windows you MUST use an explicit context in version 8 if
you're running your sqlj routines threadsafe (this is the default for
java in v8). If you don't create an expclit context, different threads
can end up closing each others cursors etc.


I see. Thank you.
I'm using 7.1 currently, but maybe I'll upgrade soon.
Nov 12 '05 #3

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

Similar topics

0
by: Bernard Dhooghe | last post by:
DB2 UDB V8.1 Fixpak 4 AIX 5.1 CLASSPATH: /usr/opt/db2_08_01/java/db2jcc.jar:/usr/opt/db2_08_01/java/db2jcc_license_cu.jar:/usr/opt/db2_08_01/java/sqlj.zip:/usr/java131/jre/lib/rt.jar: Program:...
9
by: Janick | last post by:
With DB2 7.2 we used to call methods from other SQLJ Stored Procedures, as it was not possible to call SPs via the SQL Call-statement from within SPs. So we always had a method like this: ...
0
by: Raquel | last post by:
ok, this is a SQL program program that runs fine. What does it mean to have iterator declared outside the class declaration (from a Java perspective, what are we doing here??)...I was under the...
10
by: Raquel | last post by:
UDB PE 8.1 on Win XP. ok, this function caused a lot of grief today. My stored procedures are java stored procedures, all FENCED and directly placed in \sqllib\function directory (not built into...
5
by: Raquel | last post by:
This is a very simple DB2 SQLJ stored procedure. The problem is that it seems to run fine but returns NOTHING. I mean..as if nothing has happened..not resultset is returned. I am passing value...
12
by: Rhino | last post by:
I am having an odd problem: the sqlj command on my system doesn't work. I am running DB2 (LUW) V8 (FP8) on WinXP. I haven't done an sqlj program since Version 6 of DB2 (LUW) so I checked the...
7
by: Jean-Marc Blaise | last post by:
Hi, The dev center calls sqlj.DB2_UPDATEJARINFO ('JMARC.JMB','JMB','file:JMB.sqlj') to update the sqlj routine source. I tried in CLP from the directory containing jar and sqlj files (Windows...
0
by: shibubaby | last post by:
Hi All, I am trying to compile some embedded SQL using the SQLJ in DB2 environment. My setup is as follows. 1) Fedora Core 5 2)IBM DB2 V8.2 I installed both the client/admin tools in the DB2...
1
by: vasilip | last post by:
I'm trying to insert large polygon data via sql statement. since the data was over 32k I had to use sqlj to insert my data. I made a class that inserts the data. ran sqlj, generated the .java...
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...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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...

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.