阅读(3225) (0)

鸿蒙OS ConnectionEventListener

2022-11-02 10:16:08 更新

ConnectionEventListener

public interface ConnectionEventListener
extends EventListener

注册以接收由 PooledConnection 对象生成的事件的通知的对象。

ConnectionEventListener 接口由连接池组件实现。 连接池组件通常由 JDBC 驱动程序供应商或其他系统软件供应商提供。 当应用程序使用侦听器注册的池连接完成时,JDBC 驱动程序会通知 ConnectionEventListener 对象。 在应用程序在其 PooledConnection 对象的表示上调用 close 方法后,将发生通知。 当由于 PooledConnection 不适合将来使用而发生连接错误时,也会通知 ConnectionEventListener ——例如,服务器已崩溃。 在驱动程序使用 PooledConnection 对象向应用程序抛出 SQLException 之前,JDBC 驱动程序会通知侦听器。

Since:

1.4

方法总结

修饰符和类型 方法 描述
void connectionClosed(ConnectionEvent event) 通知此 ConnectionEventListener 应用程序已在其表示的池连接上调用 close 方法。
void connectionErrorOccurred(ConnectionEvent event) 通知此 ConnectionEventListener 发生了致命错误并且无法再使用池连接。

方法详情

connectionClosed

void connectionClosed(ConnectionEvent event)

通知此 ConnectionEventListener 应用程序已在其表示的池连接上调用 close 方法。

参数:

参数名称 参数描述
event 描述事件源的事件对象

connectionErrorOccurred

void connectionErrorOccurred(ConnectionEvent event)

通知此 ConnectionEventListener 发生了致命错误并且无法再使用池连接。 驱动程序在向应用程序抛出给定 ConnectionEvent 对象中包含的 SQLException 之前发出此通知。

参数:

参数名称 参数描述
event 描述事件源并包含驱动程序即将抛出的 SQLException 的事件对象