AceQL HTTP 10.0 Released – Support for Update Listeners

We are excited to announce the release of AceQL HTTP 9.0.

It introduces Update Listeners which allow to execute Java code after the completion of a successful database update.

Update Listeners may be viewed as a kind of TRIGGER executed after the completion of SQL updates. But all is coded in Good ‘Ol Java, which is much easier to write and maintain than the regular trigger implementation of SQL databases vendors. And it allows using the same centralized code for all your databases.

 

How to implement an Update Listener?

Just implement the UpdateListener interface in a new class and override the updateActionPerformed method:

				
					console.log( 'Code is Poetry' );
				
			
				
					 /**
     * Invoked when a SQL update event is successfully executed.
     * @param evt           the SQL update  event that is successfully processed
     * @param connection    the Connection in use for the SQL update event
     * 
     * @throws IOException  if an IOException occurs
     * @throws SQLException if a SQLException occurs
     */
    public void updateActionPerformed(SqlActionEvent evt, Connection connection) 
        throws IOException, SQLException;
				
			

 

The SqlAction instance contains all info on the last successful SQL update.

For example, this sample and naïve implementation would write main SQL info on stdout:

				
					/**
 * Prints all successful SQL updates main info on stdout
 */
@Override
public void updateActionPerformed(SqlActionEvent evt, Connection connection) 
    throws IOException, SQLException {

    System.out.println(new Date() 
        + " Client username: " + evt.getUsername() 
        + " Database: " + evt.getDatabase()
        + " SQL statement:  " + evt.getSql()
        + " Client IP address: " + evt.getIpAddress());
}
				
			

 

The JsonLoggerUpdateListener concrete implementation

AceQL 9.0 comes with the JsonLoggerUpdateListener concrete class that logs all SQL updates using the JSON format .


Chaining Update Listener

Multiple Update Listeners may be chained, just define the class names in the aceql-server.properties configuration file:

				
					# Logs all SQL updates using both JsonLoggerUpdateListener & MyUpdateListener
sampledb.updateListenerClassNames=JsonLoggerUpdateListener, com.mycompany.listener.MyUpdateListener
				
			

 

For more information

See the User Documentation.

AceQL HTTP
test IT now, it's free