Search in sources :

Example 6 with DbTypeConverter

use of com.haulmont.cuba.core.sys.persistence.DbTypeConverter in project cuba by cuba-platform.

the class ServerInfo method applicationStopped.

@Override
public void applicationStopped() {
    try {
        infoUpdateTimer.cancel();
        infoUpdateTimer.purge();
        log.trace("Updating server information in the database");
        DbTypeConverter types = persistence.getDbTypeConverter();
        Object tsObj = types.getSqlObject(timeSource.currentTimestamp());
        int tsType = types.getSqlType(Date.class);
        Object falseObj = types.getSqlObject(Boolean.FALSE);
        int boolType = types.getSqlType(Boolean.class);
        QueryRunner runner = new QueryRunner(persistence.getDataSource());
        runner.update("update SYS_SERVER set UPDATE_TS = ?, IS_RUNNING = ? where NAME = ?", new Object[] { tsObj, falseObj, getServerId() }, new int[] { tsType, boolType, Types.VARCHAR });
    } catch (Exception e) {
        log.error("Unable to update SYS_SERVER: {}", e);
    }
}
Also used : DbTypeConverter(com.haulmont.cuba.core.sys.persistence.DbTypeConverter) QueryRunner(com.haulmont.bali.db.QueryRunner) IOException(java.io.IOException)

Aggregations

QueryRunner (com.haulmont.bali.db.QueryRunner)6 DbTypeConverter (com.haulmont.cuba.core.sys.persistence.DbTypeConverter)6 SQLException (java.sql.SQLException)4 IOException (java.io.IOException)2 EntityManager (com.haulmont.cuba.core.EntityManager)1 Transaction (com.haulmont.cuba.core.Transaction)1 UserSession (com.haulmont.cuba.security.global.UserSession)1