Search in sources :

Example 56 with DatabaseAccessException

use of com.axway.ats.log.autodb.exceptions.DatabaseAccessException in project ats-framework by Axway.

the class AbstractDbAppender method activateOptions.

/* (non-Javadoc)
     * @see org.apache.log4j.AppenderSkeleton#activateOptions()
     */
@Override
public void activateOptions() {
    //check whether the configuration is valid first
    try {
        appenderConfig.validate();
    } catch (InvalidAppenderConfigurationException iace) {
        throw new DbAppenederException(iace);
    }
    //set the threshold if there is such
    appenderConfig.setLoggingThreshold(getThreshold());
    //the logging queue
    queue = new ArrayBlockingQueue<LogEventRequest>(getMaxNumberLogEvents());
    // enable batch mode at ATS Agent side only
    boolean isWorkingAtAgentSide = this instanceof PassiveDbAppender;
    boolean isBatchMode = false;
    if (isWorkingAtAgentSide) {
        isBatchMode = isBatchMode();
    }
    //create new event processor
    try {
        eventProcessor = new DbEventRequestProcessor(appenderConfig, layout, getEventRequestProcessorListener(), isBatchMode);
    } catch (DatabaseAccessException e) {
        throw new RuntimeException("Unable to create DB event processor", e);
    }
    //start the logging thread
    queueLogger = new QueueLoggerThread(queue, eventProcessor, isBatchMode);
    queueLogger.setDaemon(true);
    queueLogger.start();
}
Also used : DbAppenederException(com.axway.ats.log.autodb.exceptions.DbAppenederException) DbEventRequestProcessor(com.axway.ats.log.autodb.DbEventRequestProcessor) QueueLoggerThread(com.axway.ats.log.autodb.QueueLoggerThread) InvalidAppenderConfigurationException(com.axway.ats.log.autodb.exceptions.InvalidAppenderConfigurationException) LogEventRequest(com.axway.ats.log.autodb.LogEventRequest) DatabaseAccessException(com.axway.ats.log.autodb.exceptions.DatabaseAccessException)

Example 57 with DatabaseAccessException

use of com.axway.ats.log.autodb.exceptions.DatabaseAccessException in project ats-framework by Axway.

the class DbAccessFactory method getNewDbWriteAccessObject.

/**
     * Retrieves the DB info from the log4j system
     * and then creates a new instance for writing into the DB
     * 
     * @return
     * @throws DatabaseAccessException
     */
public DbWriteAccess getNewDbWriteAccessObject() throws DatabaseAccessException {
    // Our DB appender keeps the DB connection info
    ActiveDbAppender loggingAppender = ActiveDbAppender.getCurrentInstance();
    if (loggingAppender == null) {
        throw new DatabaseAccessException("Unable to initialize connection to the logging database as the ATS ActiveDbAppender is not attached to log4j system");
    }
    // Create DB connection based on the log4j system settings
    DbConnection dbConnection = new DbConnSQLServer(loggingAppender.getHost(), loggingAppender.getDatabase(), loggingAppender.getUser(), loggingAppender.getPassword());
    // Create the database access layer
    return new DbWriteAccess(dbConnection, false);
}
Also used : ActiveDbAppender(com.axway.ats.log.appenders.ActiveDbAppender) DbConnSQLServer(com.axway.ats.core.dbaccess.mssql.DbConnSQLServer) DatabaseAccessException(com.axway.ats.log.autodb.exceptions.DatabaseAccessException) DbConnection(com.axway.ats.core.dbaccess.DbConnection)

Aggregations

DatabaseAccessException (com.axway.ats.log.autodb.exceptions.DatabaseAccessException)57 SQLException (java.sql.SQLException)52 CallableStatement (java.sql.CallableStatement)45 DbConnection (com.axway.ats.core.dbaccess.DbConnection)35 Connection (java.sql.Connection)34 ResultSet (java.sql.ResultSet)28 Checkpoint (com.axway.ats.log.autodb.entities.Checkpoint)23 ArrayList (java.util.ArrayList)18 Timestamp (java.sql.Timestamp)14 PreparedStatement (java.sql.PreparedStatement)7 HashMap (java.util.HashMap)5 Statistic (com.axway.ats.log.autodb.entities.Statistic)4 Message (com.axway.ats.log.autodb.entities.Message)3 SimpleDateFormat (java.text.SimpleDateFormat)3 BackwardCompatibility (com.axway.ats.core.utils.BackwardCompatibility)2 Run (com.axway.ats.log.autodb.entities.Run)2 StatisticDescription (com.axway.ats.log.autodb.entities.StatisticDescription)2 Suite (com.axway.ats.log.autodb.entities.Suite)2 AgentException (com.axway.ats.agent.core.exceptions.AgentException)1 DbException (com.axway.ats.core.dbaccess.exceptions.DbException)1