Examples of StopwatchStorageException


Examples of com.commsen.stopwatch.StopwatchStorageException

   */
  public void open() throws StopwatchStorageException {
      try {
          Class.forName(getDriver());
      } catch (ClassNotFoundException e) {
          throw new StopwatchStorageException("failed to load " + getDriver() + " driver.", e);
      }
 
    try {
        if (isDebug())getLogger().debug("Connecting to database ... ");
       
        updateConnection = DriverManager.getConnection(getConnectionString(), getUser(), getPassword());
        selectConnection = DriverManager.getConnection(getConnectionString(), getUser(), getPassword());
       
        if (isDebug())getLogger().debug("connection sucsessful. Checking tables ... ");
       
    } catch (SQLException e) {
          throw new StopwatchStorageException("database connection error", e);
    }

    // check if table exists
    try {
      Statement statement =  selectConnection.createStatement();
      statement.execute(getCheckTableQuery());
      statement.close();
      if (getTruncTableQuery() != null && !"".equals(getTruncTableQuery().trim())) {
        try {
          statement =  updateConnection.createStatement();
          statement.executeUpdate(getTruncTableQuery());
          statement.close();
        } catch (SQLException e) {
          throw new StopwatchStorageException("Can not truncate table", e);
        }
      }
        if (isDebug())getLogger().debug("table(s) exists. Engine will now attempt to create prepared statements ... ");
    } catch (SQLException e) {
      try {
        Statement statement =  updateConnection.createStatement();
        statement.execute(getCreateTableQuery());
        statement.close();
          if (isDebug())getLogger().debug("table(s) created. Engine will now attempt to create prepared statements ... ");
      } catch (SQLException e1) {
        throw new StopwatchStorageException("Can not create table(s)", e1);
      }
    }
   
    try {
      insertPreparedStatement = updateConnection.prepareStatement(getInsertQuery());
      updatePreparedStatement = updateConnection.prepareStatement(getUpdateQuery());
      deletePreparedStatement = updateConnection.prepareStatement(getDeleteQuery());
      lastIdentityStatement = updateConnection.prepareStatement(getLastIdentityQuery());
     
      allReportStatement = selectConnection.prepareStatement(getAllReportQuery());
      allByGroupReportStatement = selectConnection.prepareStatement(getAllByGroupReportQuery());
      allByLabelReportStatement = selectConnection.prepareStatement(getAllByLabelReportQuery());
      groupReportStatement = selectConnection.prepareStatement(getGroupReportQuery());
      labelReportStatement = selectConnection.prepareStatement(getLabelReportQuery());
      singleReportStatement = selectConnection.prepareStatement(getSingleReportQuery());
     
      loadStatement = selectConnection.prepareStatement(getLoadQuery());
      groupLoadStatement = selectConnection.prepareStatement(getGroupLoadQuery());
      labelLoadStatement = selectConnection.prepareStatement(getLabelLoadQuery());
      groupLabelLoadStatement = selectConnection.prepareStatement(getGroupLabelLoadQuery());
     
        if (isDebug()) getLogger().debug("Prepared statements created!");
    } catch (SQLException e) {
          throw new StopwatchStorageException("can not create prepared statements", e);
    }
  }
View Full Code Here

Examples of com.commsen.stopwatch.StopwatchStorageException

      updateConnection = null;
      selectConnection.close();
      selectConnection = null;
        if (isDebug()) getLogger().debug("Database shut down !!!");
    } catch (SQLException e) {
          throw new StopwatchStorageException("database error", e);
    }
  }
View Full Code Here

Examples of com.commsen.stopwatch.StopwatchStorageException

        long result = resultSet.getLong(1);
        resultSet.close();
        return result;
      }
    } catch (SQLException e) {
          throw new StopwatchStorageException("database error", e);
    }
  }
View Full Code Here

Examples of com.commsen.stopwatch.StopwatchStorageException

        deletePreparedStatement.setLong(1, id);
        deletePreparedStatement.executeUpdate();
        return true;
      }
    } catch (SQLException e) {
          throw new StopwatchStorageException("database error", e);
    }
  }
View Full Code Here

Examples of com.commsen.stopwatch.StopwatchStorageException

        updatePreparedStatement.setLong(2, id);
        updatePreparedStatement.executeUpdate();
        return true;
      }
    } catch (SQLException e) {
          throw new StopwatchStorageException("database error", e);
    }

  }
View Full Code Here

Examples of com.commsen.stopwatch.StopwatchStorageException

   */
  public void close() throws StopwatchStorageException {
    try {
      updateConnection.createStatement().execute("drop table stopwatch");
    } catch (SQLException e) {
          throw new StopwatchStorageException("database error", e);
    }
    super.close();
  }
View Full Code Here

Examples of com.commsen.stopwatch.StopwatchStorageException

        long result = resultSet.getLong(1);
        resultSet.close();
        return result;
      }
    } catch (SQLException e) {
          throw new StopwatchStorageException("database error", e);
    }
  } 
View Full Code Here

Examples of com.commsen.stopwatch.StopwatchStorageException

        updatePreparedStatement.setLong(3, id);
        updatePreparedStatement.executeUpdate();
        return true;
      }
    } catch (SQLException e) {
          throw new StopwatchStorageException("database error", e);
    }

  } 
View Full Code Here

Examples of com.commsen.stopwatch.StopwatchStorageException

        resultSet.close();
        byIdCount.put(new Long(result), key);
        return result;
      }
    } catch (SQLException e) {
          throw new StopwatchStorageException("database error", e);
    }
  } 
View Full Code Here

Examples of com.commsen.stopwatch.StopwatchStorageException

        }
       
        return true;
      }
    } catch (SQLException e) {
          throw new StopwatchStorageException("database error", e);
    }

  } 
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.