Example usage for java.sql SQLException getClass

List of usage examples for java.sql SQLException getClass

Introduction

In this page you can find the example usage for java.sql SQLException getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:shnakkydoodle.measuring.provider.MetricsProviderSQLServer.java

/**
 * Add MetricSlaAlarmState//from w  w w. java  2s.  c o m
 * 
 * @param metricSlaId
 * @param alarmStateId
 */
@Override
public void addMetricSlaAlarmStatus(Integer metricSlaId, Integer alarmStateId) {
    Connection conn = null;
    CallableStatement stmt = null;

    try {
        Class.forName("net.sourceforge.jtds.jdbc.Driver");
        conn = DriverManager.getConnection(this.host + ";user=" + this.username + ";password=" + this.password);

        // create new MetricSlaAlarmStatus
        stmt = conn.prepareCall("uspMetricSlaAlarmStatus_Insert(?,?)");
        stmt.setInt(1, metricSlaId);
        stmt.setInt(2, alarmStateId);
        stmt.execute();
    } catch (SQLException e) {
        this.loggingManager.LogError("Error : " + e.getClass().getName(), e.getMessage());
        e.printStackTrace();
    } catch (ClassNotFoundException e) {
        this.loggingManager.LogError("Error : " + e.getClass().getName(), e.getMessage());
        e.printStackTrace();
    } finally {
        DbUtils.closeQuietly(stmt);
        DbUtils.closeQuietly(conn);
    }
}

From source file:shnakkydoodle.measuring.provider.MetricsProviderSQLServer.java

/**
 * Delete alarm by id/* w  ww.  ja  v a 2 s .  c o m*/
 * 
 * @param metricAlarmId
 * @rowsDeleted
 */
@Override
public Integer deleteAlarm(Integer metricAlarmId) {
    Connection conn = null;
    CallableStatement stmt = null;
    Integer rowsDeleted = 0;

    try {
        Class.forName("net.sourceforge.jtds.jdbc.Driver");
        conn = DriverManager.getConnection(this.host + ";user=" + this.username + ";password=" + this.password);

        // delete alarm
        stmt = conn.prepareCall("uspMetricAlarm_Delete(?)");
        stmt.setInt(1, metricAlarmId);
        rowsDeleted = stmt.executeUpdate();
    } catch (SQLException e) {
        this.loggingManager.LogError("Error : " + e.getClass().getName(), e.getMessage());
        e.printStackTrace();
    } catch (ClassNotFoundException e) {
        this.loggingManager.LogError("Error : " + e.getClass().getName(), e.getMessage());
        e.printStackTrace();
    } finally {
        DbUtils.closeQuietly(stmt);
        DbUtils.closeQuietly(conn);
    }

    return rowsDeleted;
}

From source file:shnakkydoodle.measuring.provider.MetricsProviderSQLServer.java

/**
 * Delete metric sla exclusion times/*  ww w .j a v  a  2  s .c  o m*/
 * 
 * @param metricSlaId
 * @return rowsDeleted
 */
public Integer deleteMetricSlaExclusionTimes(Integer metricSlaId) {
    Connection conn = null;
    CallableStatement stmt = null;
    Integer rowsDeleted = 0;

    try {
        Class.forName("net.sourceforge.jtds.jdbc.Driver");
        conn = DriverManager.getConnection(this.host + ";user=" + this.username + ";password=" + this.password);

        // Delete metric sla exclusion time
        stmt = conn.prepareCall("uspMetricSlaExclusionTime_Delete(?)");
        stmt.setInt(1, metricSlaId);

        rowsDeleted = stmt.executeUpdate();
    } catch (SQLException e) {
        this.loggingManager.LogError("Error : " + e.getClass().getName(), e.getMessage());
        e.printStackTrace();
    } catch (ClassNotFoundException e) {
        this.loggingManager.LogError("Error : " + e.getClass().getName(), e.getMessage());
        e.printStackTrace();
    } finally {
        DbUtils.closeQuietly(stmt);
        DbUtils.closeQuietly(conn);
    }

    return rowsDeleted;
}

From source file:shnakkydoodle.measuring.provider.MetricsProviderSQLServer.java

/**
 * Add metric alarm history item//  w w w  .j a  va 2  s  . c o  m
 * 
 * @param alarmMetricAlarmId
 * @param stateReason
 * @param stateReasonData
 * @param alarmState
 */
@Override
public void addMetricAlarmHistory(Integer alarmMetricAlarmId, String stateReason, String stateReasonData,
        AlarmState alarmState) {
    Connection conn = null;
    CallableStatement stmt = null;

    try {
        Class.forName("net.sourceforge.jtds.jdbc.Driver");
        conn = DriverManager.getConnection(this.host + ";user=" + this.username + ";password=" + this.password);

        // create new MetricAlarmHistoryItem
        stmt = conn.prepareCall("uspMetricAlarmHistoryItem_Insert(?,?,?,?)");
        stmt.setInt(1, alarmMetricAlarmId);
        stmt.setString(2, stateReason);
        stmt.setString(3, stateReasonData);
        stmt.setInt(4, alarmState.getValue());
        stmt.execute();
    } catch (SQLException e) {
        this.loggingManager.LogError("Error : " + e.getClass().getName(), e.getMessage());
        e.printStackTrace();
    } catch (ClassNotFoundException e) {
        this.loggingManager.LogError("Error : " + e.getClass().getName(), e.getMessage());
        e.printStackTrace();
    } finally {
        DbUtils.closeQuietly(stmt);
        DbUtils.closeQuietly(conn);
    }
}

From source file:shnakkydoodle.measuring.provider.MetricsProviderSQLServer.java

/**
 * Add MetricSLAExclusionTime/*  ww w  .  j  a  v  a2s.  c o m*/
 * 
 * @param metricSlaId
 * @param dayOfWeek
 * @param startTime
 * @param endTime
 */
@Override
public void addMetricSlaExclusionTime(Integer metricSlaId, DayOfWeek dayOfWeek, String startTime,
        String endTime) {
    Connection conn = null;
    CallableStatement stmt = null;

    try {
        Class.forName("net.sourceforge.jtds.jdbc.Driver");
        conn = DriverManager.getConnection(this.host + ";user=" + this.username + ";password=" + this.password);

        // create new MetricSLAExclusionTime
        stmt = conn.prepareCall("uspMetricSlaExclusionTime_Insert(?,?,?,?)");
        stmt.setInt(1, metricSlaId);
        stmt.setInt(2, dayOfWeek.getValue());
        stmt.setString(3, startTime);
        stmt.setString(4, endTime);
        stmt.execute();
    } catch (SQLException e) {
        this.loggingManager.LogError("Error : " + e.getClass().getName(), e.getMessage());
        e.printStackTrace();
    } catch (ClassNotFoundException e) {
        this.loggingManager.LogError("Error : " + e.getClass().getName(), e.getMessage());
        e.printStackTrace();
    } finally {
        DbUtils.closeQuietly(stmt);
        DbUtils.closeQuietly(conn);
    }
}

From source file:shnakkydoodle.measuring.provider.MetricsProviderSQLServer.java

/**
 * Delete alarms history items for an alarm
 * /* w  ww .  j  av  a2  s .c  o m*/
 * @param metricAlarmId
 * @return rowsDeleted
 */
@Override
public Integer deleteAlarmHistoryItems(Integer metricAlarmId) {

    Connection conn = null;
    CallableStatement stmt = null;
    Integer rowsDeleted = 0;

    try {
        Class.forName("net.sourceforge.jtds.jdbc.Driver");
        conn = DriverManager.getConnection(this.host + ";user=" + this.username + ";password=" + this.password);

        // delete alarm history
        stmt = conn.prepareCall("uspMetricAlarmHistoryItem_Delete(?)");
        stmt.setInt(1, metricAlarmId);
        rowsDeleted = stmt.executeUpdate();
    } catch (SQLException e) {
        this.loggingManager.LogError("Error : " + e.getClass().getName(), e.getMessage());
        e.printStackTrace();
    } catch (ClassNotFoundException e) {
        this.loggingManager.LogError("Error : " + e.getClass().getName(), e.getMessage());
        e.printStackTrace();
    } finally {
        DbUtils.closeQuietly(stmt);
        DbUtils.closeQuietly(conn);
    }

    return rowsDeleted;
}

From source file:shnakkydoodle.measuring.provider.MetricsProviderSQLServer.java

/**
 * Delete metric data by Metric namespace and metric name (if metric name = null
 * then delete all records for metric namespace
 * //from  w w  w . j  a  v a 2s  .  c o  m
 * @param metricNamespace
 * @param metricName
 */
@Override
public void deleteMetricData(String metricNamespace, String metricName) {
    Connection conn = null;
    CallableStatement stmt = null;

    try {
        Class.forName("net.sourceforge.jtds.jdbc.Driver");
        conn = DriverManager.getConnection(this.host + ";user=" + this.username + ";password=" + this.password);

        // Delete metric data
        stmt = conn.prepareCall("uspMetricData_Delete(?,?,?,?)");
        stmt.setString(1, metricNamespace);
        stmt.setString(2, metricName);
        stmt.setString(3, null);
        stmt.setString(4, null);

        stmt.execute();
    } catch (SQLException e) {
        this.loggingManager.LogError("Error : " + e.getClass().getName(), e.getMessage());
        e.printStackTrace();
    } catch (ClassNotFoundException e) {
        this.loggingManager.LogError("Error : " + e.getClass().getName(), e.getMessage());
        e.printStackTrace();
    } finally {
        DbUtils.closeQuietly(stmt);
        DbUtils.closeQuietly(conn);
    }
}

From source file:shnakkydoodle.measuring.provider.MetricsProviderSQLServer.java

/**
 * Delete metric sla//from   w w  w .j  a  v a 2s. c  o m
 * 
 * @param metricSlaId
 * @return rowsDeleted
 */
public Integer deleteMetricSla(Integer metricSlaId) {

    Connection conn = null;
    CallableStatement stmt = null;
    Integer rowsDeleted = 0;

    try {
        Class.forName("net.sourceforge.jtds.jdbc.Driver");
        conn = DriverManager.getConnection(this.host + ";user=" + this.username + ";password=" + this.password);

        // delete metric sla
        stmt = conn.prepareCall("uspMetricSla_Delete(?)");
        stmt.setInt(1, metricSlaId);
        rowsDeleted = stmt.executeUpdate();

    } catch (SQLException e) {
        this.loggingManager.LogError("Error : " + e.getClass().getName(), e.getMessage());
        e.printStackTrace();
    } catch (ClassNotFoundException e) {
        this.loggingManager.LogError("Error : " + e.getClass().getName(), e.getMessage());
        e.printStackTrace();
    } finally {
        DbUtils.closeQuietly(stmt);
        DbUtils.closeQuietly(conn);
    }

    return rowsDeleted;
}

From source file:shnakkydoodle.measuring.provider.MetricsProviderSQLServer.java

/**
 * Update metric sla/*from   w ww  .jav  a2s . com*/
 * 
 * @param metricSlaId
 * @param metricAlarmId
 * @param slaName
 * @param slaDescription
 * @param percentage
 * @return rowsUpdated
 */
@Override
public Integer updateMetricSla(Integer metricSlaId, Integer metricAlarmId, String slaName,
        String slaDescription, Double percentage) {
    Connection conn = null;
    CallableStatement stmt = null;
    Integer rowsUpdated = 0;

    try {
        Class.forName("net.sourceforge.jtds.jdbc.Driver");
        conn = DriverManager.getConnection(this.host + ";user=" + this.username + ";password=" + this.password);

        // Update sla
        stmt = conn.prepareCall("uspMetricSla_Update(?,?,?,?,?,?)");
        stmt.setInt(1, metricSlaId);
        stmt.setInt(2, metricAlarmId);
        stmt.setString(3, slaName);
        stmt.setString(4, slaDescription);
        stmt.setDouble(5, percentage);
        rowsUpdated = stmt.executeUpdate();
    } catch (SQLException e) {
        this.loggingManager.LogError("Error : " + e.getClass().getName(), e.getMessage());
        e.printStackTrace();
    } catch (ClassNotFoundException e) {
        this.loggingManager.LogError("Error : " + e.getClass().getName(), e.getMessage());
        e.printStackTrace();
    } finally {
        DbUtils.closeQuietly(stmt);
        DbUtils.closeQuietly(conn);
    }

    return rowsUpdated;
}

From source file:shnakkydoodle.measuring.provider.MetricsProviderSQLServer.java

/**
 * Add metric sla/*from w  w w.  ja v a 2  s . c  om*/
 * 
 * @param metricAlarmId
 * @param slaName
 * @param slaDescription
 * @param percentage
 * @param lastId
 */
@Override
public Integer addMetricSla(Integer metricAlarmId, String slaName, String slaDescription, Double percentage) {
    Connection conn = null;
    CallableStatement stmt = null;
    Integer lastId = 0;

    try {
        Class.forName("net.sourceforge.jtds.jdbc.Driver");
        conn = DriverManager.getConnection(this.host + ";user=" + this.username + ";password=" + this.password);

        // create new sla
        stmt = conn.prepareCall("uspMetricSla_Insert(?,?,?,?,?)");
        stmt.setInt(1, metricAlarmId);
        stmt.setString(2, slaName);
        stmt.setString(3, slaDescription);
        stmt.setDouble(4, percentage);
        stmt.registerOutParameter(5, Types.INTEGER);
        stmt.execute();

        lastId = stmt.getInt(5);
    } catch (SQLException e) {
        this.loggingManager.LogError("Error : " + e.getClass().getName(), e.getMessage());
        e.printStackTrace();
    } catch (ClassNotFoundException e) {
        this.loggingManager.LogError("Error : " + e.getClass().getName(), e.getMessage());
        e.printStackTrace();
    } finally {
        DbUtils.closeQuietly(stmt);
        DbUtils.closeQuietly(conn);
    }

    return lastId;
}