- All Superinterfaces:
AttachmentProperties,AutoCloseable,BaseProperties
- All Known Implementing Classes:
FBEventManager
EventListener instances to listen for database events.- Author:
- Gabriel Reid, Mark Rotteveel
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddEventListener(String eventName, EventListener listener) Register an EventListener that will be called when an event occurs.voidclose()If connected, disconnects, otherwise does nothing.voidconnect()Make a connection with a database to listen for events.voidClose the connection to the database.Get the database name.longGet the poll timeout in milliseconds of the async thread to check whether it was stopped or not.Get the wire encryption level.booleanvoidremoveEventListener(String eventName, EventListener listener) Remove an EventListener for a given event.voidsetDatabaseName(String databaseName) Set the database name.voidsetWaitTimeout(long waitTimeout) Set the poll timeout in milliseconds of the async thread to check whether it was stopped or not.voidsetWireCryptAsEnum(WireCrypt wireCrypt) Set the wire encryption level.intwaitForEvent(String eventName) Wait for the one-time occurrence of an event.intwaitForEvent(String eventName, int timeout) Wait for the one-time occurrence of an event.Methods inherited from interface org.firebirdsql.jaybird.props.AttachmentProperties
getAuthPlugins, getCharSet, getConnectTimeout, getDbCryptConfig, getEnableProtocol, getEncoding, getParallelWorkers, getPassword, getPortNumber, getProcessId, getProcessName, getRoleName, getServerName, getSocketBufferSize, getSocketFactory, getSoTimeout, getType, getUser, getWireCrypt, isWireCompression, setAuthPlugins, setCharSet, setConnectTimeout, setDbCryptConfig, setEnableProtocol, setEncoding, setParallelWorkers, setPassword, setPortNumber, setProcessId, setProcessName, setRoleName, setServerName, setSocketBufferSize, setSocketFactory, setSoTimeout, setType, setUser, setWireCompression, setWireCryptMethods inherited from interface org.firebirdsql.jaybird.props.BaseProperties
connectionPropertyValues, getBooleanProperty, getBooleanProperty, getIntProperty, getIntProperty, getProperty, getProperty, setBooleanProperty, setIntProperty, setProperty
-
Method Details
-
connect
Make a connection with a database to listen for events.- Throws:
SQLException- If a database communication error occursIllegalStateException- If already connected
-
close
If connected, disconnects, otherwise does nothing.Contrary to
disconnect(), this method does not throwIllegalStateExceptionwhen not connected.- Specified by:
closein interfaceAutoCloseable- Throws:
SQLException- For errors during disconnect- Since:
- 3.0.7
-
disconnect
Close the connection to the database.- Throws:
SQLException- If a database communication error occursIllegalStateException- If not currently connected- See Also:
-
isConnected
boolean isConnected()- Returns:
truewhen connected and able to listen for events- See Also:
-
getDatabaseName
String getDatabaseName()Get the database name.See
DatabaseConnectionProperties.getDatabaseName()for details.- Returns:
- database name
- Since:
- 5
-
setDatabaseName
Set the database name.See
DatabaseConnectionProperties.setDatabaseName(String)for details.- Parameters:
databaseName- database name- Since:
- 5
-
getWireCryptAsEnum
WireCrypt getWireCryptAsEnum()Get the wire encryption level.- Returns:
- Wire encryption level
- Since:
- 5
-
setWireCryptAsEnum
Set the wire encryption level.- Parameters:
wireCrypt- Wire encryption level (nullnot allowed)- Since:
- 5
-
getWaitTimeout
long getWaitTimeout()Get the poll timeout in milliseconds of the async thread to check whether it was stopped or not.Default value is 1000 (1 second).
- Returns:
- wait timeout in milliseconds
-
setWaitTimeout
void setWaitTimeout(long waitTimeout) Set the poll timeout in milliseconds of the async thread to check whether it was stopped or not.Default value is 1000 (1 second).
- Parameters:
waitTimeout- wait timeout in milliseconds
-
addEventListener
Register an EventListener that will be called when an event occurs.- Parameters:
eventName- The name of the event for which the listener will be notifiedlistener- The EventListener that will be called when the given event occurs- Throws:
SQLException- If a database access error occurs
-
removeEventListener
Remove an EventListener for a given event.- Parameters:
eventName- The name of the event for which the listener will be unregistered.listener- The EventListener that is to be unregistered- Throws:
SQLException- If a database access error occurs
-
waitForEvent
Wait for the one-time occurrence of an event.This method blocks indefinitely until the event identified by the value of
eventNameoccurs. The return value is the number of occurrences of the requested event.- Parameters:
eventName- The name of the event to wait for- Returns:
- The number of occurences of the requested event
- Throws:
InterruptedException- If interrupted while waitingSQLException- If a database access error occurs
-
waitForEvent
Wait for the one-time occurrence of an event.This method blocks for a maximum of
timeoutmilliseconds, waiting for the event identified byeventNameto occur. A timeout value of0means wait indefinitely.The return value is the number of occurences of the event in question, or
-1if the call timed out.- Parameters:
eventName- The name of the event to wait fortimeout- The maximum number of milliseconds to wait- Returns:
- The number of occurrences of the requested event, or
1if the call timed out - Throws:
InterruptedException- If interrupted while waitingSQLException- If a database access error occurs
-