473,320 Members | 1,949 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,320 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 1500

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: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.