473,387 Members | 1,925 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.

DB2 connection Pooling

Does COM.ibm.db2.jdbc.DB2DataSource, (which supports connection
pooling) need to be run within a J2EE container environment before the
connection pooling facility is actually available to a user?

Thanks John
Nov 12 '05 #1
5 12698
COM.ibm.db2.jdbc.DB2DataSource is an implementation of the Type 2
connection driver. This driver goes through the (UDB) client code
installed on the system where the application is running.

As far as I know, any connection pooler that sits between applications
and the CLI code should work.

Connection pooling is usually not considered to be "available to the
user". It's an interfacing layer for performance that lies outside the
application; which should have no access to it. The presence or absence
of connection pooling shouldn't make any difference to the application code.
Phil Sherman

John wrote:
Does COM.ibm.db2.jdbc.DB2DataSource, (which supports connection
pooling) need to be run within a J2EE container environment before the
connection pooling facility is actually available to a user?

Thanks John


Nov 12 '05 #2
aka
Hi John,

perhaps you want to try something like this:

COM.ibm.db2.jdbc.DB2ConnectionPoolDataSource ds = new
COM.ibm.db2.jdbc.DB2ConnectionPoolDataSource();
ds.setDatabaseName(...);
ds.setUser(...);
ds.setPassword(...);

javax.sql.PooledConnection c = null;
c = ds.getPooledConnection(...)

I dont't know which connection type this is, but I would think this is type
2...

Regards aka.
"John" wrote in message
news:e5**************************@posting.google.c om...
Does COM.ibm.db2.jdbc.DB2DataSource, (which supports connection
pooling) need to be run within a J2EE container environment before the
connection pooling facility is actually available to a user?

Thanks John

Nov 12 '05 #3
Phil,

The problem - I have 'working' JDBC code that makes use of data source
and pooling, called as follows (its happens to be as aka's post
described.) I use DB2 UDB 7 fix (pack 12). The problem is it takes
600msec to get a connection - I suspect pooling is not 'turned on'.
The crux is I'm running outside of a container - What am I doing
wrong? DB2Java.zip facilitates a developer creating your own pooling -
but I dont want to do that!

dsource = new COM.ibm.db2.jdbc.DB2DataSource();
Context ctx = null;
Hashtable env = new Hashtable(5);
env.put ("java.naming.factory.initial",
"COM.ibm.db2.jndi.DB2InitialContextFactory");
ctx = new InitialContext(env);
ctx.bind(dataSourceName, dsource);
ds = (DataSource) ctx.lookup(dataSourceName);
conn = ds.getConnection(datasourceUser, datasourcePassword);
Nov 12 '05 #4
aka

"John" wrote in message
news:e5**************************@posting.google.c om...
Phil,

The problem - I have 'working' JDBC code that makes use of data source
and pooling, called as follows (its happens to be as aka's post
described.) I use DB2 UDB 7 fix (pack 12). The problem is it takes
600msec to get a connection - I suspect pooling is not 'turned on'.
The crux is I'm running outside of a container - What am I doing
wrong? DB2Java.zip facilitates a developer creating your own pooling -
but I dont want to do that!

dsource = new COM.ibm.db2.jdbc.DB2DataSource();
Context ctx = null;
Hashtable env = new Hashtable(5);
env.put ("java.naming.factory.initial",
"COM.ibm.db2.jndi.DB2InitialContextFactory");
ctx = new InitialContext(env);
ctx.bind(dataSourceName, dsource);
ds = (DataSource) ctx.lookup(dataSourceName);
conn = ds.getConnection(datasourceUser, datasourcePassword);


if you say that the last line of your code takes 600ms on subsequent calls,
then this could be some problem (depending on your environment, machine,
network and so on), if you mean all of the above lines take 600ms that
should be a reasonable time, in particular if it is for your first
connection. one other thing that could speed things up is to set the userid
and password on the data source rather then doing authentication every time
when getting a connection from the pool (or context), if this is applicable
in your case. if you mean application server when speeking of j2ee
container, then the app server will most likely do the connection pooling
stuff, if you run your code outside then you have to do the work by
yourself...in the above example you create a new connection capable of
pooling every time you run it.
by only getting the connection i achieve typically about 31ms or even 0ms
(due to the bad granularity of timer updates about 1/17sec) on my Wintel box
with local db, but the first connection takes notably longer, espacially if
it is the first connection to the db at all.

maybe i didn't get your problem?

Regards aka.
Nov 12 '05 #5
Thanks for the response(s),

Its the last line that takes ages & I am running it outside of a J2EE
container. I get the impression that you believe it needs to run
within a container to get the benefit of pooling?

My problem is compounded in that I have to port it to Oracle. Since I
made use of DB2Java.zip '.jndi.DB2InitialContextFactory' and an
equivelent is not available withon Oracles classes12.zip. I will have
to resort to using JDBC and forget DataSources. Since I only need a
single connection per process - I'l hold it open passing it forward
for the next client user.

Thanks John
Nov 12 '05 #6

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

Similar topics

18
by: Rob Nicholson | last post by:
We're getting an occasional occurrence of the following error when two users try and open the same record in our ASP.NET app: "There is already an open DataReader associated with this Connection...
1
by: Lenny Shprekher | last post by:
Hi, I am getting issues that Oracle collecting opened sessions (connections) from my webservice using regular System.Data.OleDb.OleDbConnection object. I am guessing that this is connection...
7
by: Mrinal Kamboj | last post by:
Hi , I am using OracleConnection object from Oracle ODP.net provider and following is the behaviour which i am finding bit strange : To start with my argument is based on followings facts : ...
3
by: Martin B | last post by:
Hallo! I'm working with C# .NET 2.0, implementing Client/Server Applications which are connecting via Network to SQL-Server or Oracle Databases. To stay independent from the underlaying Database...
2
by: JimLad | last post by:
Hi, In an existing ASP/ASP.NET 1.1 app running on IIS 6, I need to RELIABLY pass the logged in username through to the SQL Server 2000 database for auditing purposes. The current method is...
16
by: crbd98 | last post by:
Hello All, Some time ago, I implemented a data access layer that included a simple connectin pool. At the time, I did it all by myself: I created N connections, each connection associated with...
20
by: fniles | last post by:
I am using VS2003 and connecting to MS Access database. When using a connection pooling (every time I open the OLEDBCONNECTION I use the exact matching connection string), 1. how can I know how...
3
by: fniles | last post by:
In the Windows application (using VB.NET 2005) I use connection pooling like the following: In the main form load I open a connection using a connection string that I stored in a global variable...
0
viswarajan
by: viswarajan | last post by:
Introduction This article is to go in deep in dome key features in the ADO.NET 2 which was shipped with VS 2005. In this article I will go trough one of the key features which is the Connection...
15
by: Sylvie | last post by:
I have a static function in a class, everytime I call this function, I am creating a SQLconnection, open it, use it, and null it, All my functions and application logic is like this, Every...
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
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
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
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
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.