Search in sources :

Example 21 with ExtendedJdbcTemplate

use of com.serotonin.db.spring.ExtendedJdbcTemplate in project ma-core-public by infiniteautomation.

the class MailingListDao method saveMailingList.

public void saveMailingList(final MailingList ml) {
    final ExtendedJdbcTemplate ejt2 = ejt;
    getTransactionTemplate().execute(new TransactionCallbackWithoutResult() {

        @SuppressWarnings("synthetic-access")
        @Override
        protected void doInTransactionWithoutResult(TransactionStatus status) {
            if (ml.getId() == Common.NEW_ID) {
                ml.setId(doInsert(MAILING_LIST_INSERT, new Object[] { ml.getXid(), ml.getName(), ml.getReceiveAlarmEmails() }));
                countMonitor.increment();
            } else
                ejt2.update(MAILING_LIST_UPDATE, new Object[] { ml.getXid(), ml.getName(), ml.getReceiveAlarmEmails(), ml.getId() });
            saveRelationalData(ml);
        }
    });
}
Also used : ExtendedJdbcTemplate(com.serotonin.db.spring.ExtendedJdbcTemplate) TransactionStatus(org.springframework.transaction.TransactionStatus) TransactionCallbackWithoutResult(org.springframework.transaction.support.TransactionCallbackWithoutResult)

Example 22 with ExtendedJdbcTemplate

use of com.serotonin.db.spring.ExtendedJdbcTemplate in project ma-core-public by infiniteautomation.

the class MySQLProxy method getDataDirectory.

@Override
public File getDataDirectory() {
    ExtendedJdbcTemplate ejt = new ExtendedJdbcTemplate();
    ejt.setDataSource(this.getDataSource());
    String dataDir = ejt.queryForObject("select @@DATADIR", new Object[] {}, String.class, null);
    if (dataDir == null)
        return null;
    return new File(dataDir);
}
Also used : ExtendedJdbcTemplate(com.serotonin.db.spring.ExtendedJdbcTemplate) File(java.io.File)

Aggregations

ExtendedJdbcTemplate (com.serotonin.db.spring.ExtendedJdbcTemplate)22 TransactionStatus (org.springframework.transaction.TransactionStatus)12 TransactionCallbackWithoutResult (org.springframework.transaction.support.TransactionCallbackWithoutResult)8 DatabaseSchemaDefinition (com.serotonin.m2m2.module.DatabaseSchemaDefinition)3 User (com.serotonin.m2m2.vo.User)3 File (java.io.File)3 DefaultDataPointPropertiesTemplateFactory (com.serotonin.m2m2.vo.template.DefaultDataPointPropertiesTemplateFactory)2 IOException (java.io.IOException)2 SQLException (java.sql.SQLException)2 DataSourceTransactionManager (org.springframework.jdbc.datasource.DataSourceTransactionManager)2 ShouldNeverHappenException (com.serotonin.ShouldNeverHappenException)1 IMangoLifecycle (com.serotonin.m2m2.IMangoLifecycle)1 CompoundEventDetectorVO (com.serotonin.m2m2.vo.event.CompoundEventDetectorVO)1 PointFolder (com.serotonin.m2m2.vo.hierarchy.PointFolder)1 PointHierarchy (com.serotonin.m2m2.vo.hierarchy.PointHierarchy)1 DirectoryInfo (com.serotonin.util.DirectoryInfo)1 FileNotFoundException (java.io.FileNotFoundException)1 ArrayList (java.util.ArrayList)1 MissingResourceException (java.util.MissingResourceException)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1