"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.