473,386 Members | 1,745 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.

My ConnectionEventListener is not called.

Hello,

I have a DB2 v7.2 server running on a Linux machine and a Java client on
another linux machine.

I'm using pooled connection. I have implemented my own
ConnectionEventListener, I register it onto each PoolConnection I obtain
from the JDBC driver, but the problem is that this listener is never called.

At the end of this mail, I attach the Java code I use for testing this problem.

Here is the output of this Java code.

Product name: DB2/LINUX
Product version: 07.02.0000
Driver name: IBM DB2 JDBC 2.0 Type 3
Driver version: 07.02.0000

Is it a know problem ? Do you have a solution for this problem ? I need to be
notified when a connection is closed to manage my connection pool...

Any help is appreciated... Thanks in advance,

Jacques-Olivier Haenni
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.DatabaseMetaData;

import javax.sql.ConnectionEventListener;
import javax.sql.PooledConnection;
import javax.sql.ConnectionEvent;

import COM.ibm.db2.jdbc.DB2ConnectionPoolDataSource;

public class DB2Pooling implements ConnectionEventListener {

private static final String DB_NAME = "leaf2";
private static final String DB_SERVER = "leaffy";
private static final String DB_USER = "db2leaf";
private static final String DB_PASSWORD = "leafdb2";

public static void main(String[] args) throws SQLException {
new DB2Pooling().test();
}

public void test() throws SQLException {
DB2ConnectionPoolDataSource db2ConnectionPoolDataSource
= new DB2ConnectionPoolDataSource();
db2ConnectionPoolDataSource.setDatabaseName(DB_NAM E);
db2ConnectionPoolDataSource.setServerName(DB_SERVE R);

PooledConnection pc
= db2ConnectionPoolDataSource.getPooledConnection(DB _USER,
DB_PASSWORD);
pc.addConnectionEventListener(this);

Connection c = pc.getConnection();
DatabaseMetaData metaData = c.getMetaData();
System.out.println("Product name: "
+ metaData.getDatabaseProductName());
System.out.println("Product version: "
+ metaData.getDatabaseProductVersion());
System.out.println("Driver name: "
+ metaData.getDriverName());
System.out.println("Driver version: "
+ metaData.getDriverVersion());
c.close();

try {
java.lang.Thread.sleep(5000);
} catch (InterruptedException ie) {
}
}

public void connectionClosed(ConnectionEvent event) {
System.out.println("connectionClosed method called.");
}

public void connectionErrorOccurred(ConnectionEvent event) {
System.out.println("connectionClosed method called.");
}
}

Nov 12 '05 #1
0 1506

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

Similar topics

0
by: beveled edges | last post by:
I'm using the XML functions in PHP 5. The callback function I set for namespace declarations doesn't get called. Can anyone help me out? The code is: $xml = '<addressbook...
0
by: Jacques-Olivier Haenni | last post by:
Hello, I have a DB2 v7.2 server running on a Linux machine and a Java client on another linux machine. I'm using pooled connection. I have implemented my own ConnectionEventListener, I...
20
by: Charles Law | last post by:
I have an application that creates a class. The class has unmanaged resources, so must end gracefully. How can I guarantee that the unmanaged resources are freed? I have looked at IDisposable,...
35
by: Peter Oliphant | last post by:
I'm programming in VS C++.NET 2005 using cli:/pure syntax. In my code I have a class derived from Form that creates an instance of one of my custom classes via gcnew and stores the pointer in a...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
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.