コード例 #1
0
  // get drivername, user, pw & server, and return connection id
  public void serve(InputStream i, OutputStream o) throws IOException {
    // TODOServiceList.getSingleInstance();
    initialize();
    NameListMessage nameListMessage = null;

    try {
      // read input to know which target panel is required
      ObjectInputStream input = new ObjectInputStream(i);
      nameListMessage = (NameListMessage) input.readObject();

      // parse the required panel
      parseSqlFile(nameListMessage);

    } catch (ClassNotFoundException ex) {
      if (Debug.isDebug()) ex.printStackTrace();
      nameListMessage.errorMessage = ex.toString();
    }

    // send object to the caller
    ObjectOutputStream output = new ObjectOutputStream(o);
    output.writeObject(nameListMessage);

    // end socket connection
    o.close();
    i.close();
  }
コード例 #2
0
  @Override
  public void updateOperation(Operation operation) throws OperationManagementDAOException {
    PreparedStatement stmt = null;
    ByteArrayOutputStream bao = null;
    ObjectOutputStream oos = null;
    try {
      super.updateOperation(operation);
      Connection connection = OperationManagementDAOFactory.getConnection();
      stmt =
          connection.prepareStatement(
              "UPDATE DM_POLICY_OPERATION O SET O.OPERATION_DETAILS=? " + "WHERE O.OPERATION_ID=?");
      bao = new ByteArrayOutputStream();
      oos = new ObjectOutputStream(bao);
      oos.writeObject(operation);

      stmt.setBytes(1, bao.toByteArray());
      stmt.setInt(2, operation.getId());
      stmt.executeUpdate();
    } catch (SQLException e) {
      throw new OperationManagementDAOException(
          "Error occurred while update policy operation metadata", e);
    } catch (IOException e) {
      throw new OperationManagementDAOException(
          "Error occurred while serializing policy operation object", e);
    } finally {
      if (bao != null) {
        try {
          bao.close();
        } catch (IOException e) {
          log.warn("Error occurred while closing ByteArrayOutputStream", e);
        }
      }
      if (oos != null) {
        try {
          oos.close();
        } catch (IOException e) {
          log.warn("Error occurred while closing ObjectOutputStream", e);
        }
      }
      OperationManagementDAOUtil.cleanupResources(stmt);
    }
  }