`
vicento4
  • 浏览: 21223 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论
收藏列表
标题 标签 来源
nginx配置静态文件下载 nginx
location /hotfile/ {
        autoindex on;
        # 不缓存html,防止程序更新后缓存继续生效
        if ($request_filename ~* .*\.(?:htm|html)$) {
                add_header Cache-Control "private, no-store, no-cache, must-revalidate, proxy-revalidate";
                access_log on;
        }
        alias /srv/webapps/hotfile/; # 静态文件nginx处理
        index  index.html index.htm;
    }
qpress解压文件 qpress
qpress -d /xxx/xxxxxxx/xxxxxxxx.qp ./
linux软链接 linux
ln -s /xxx/xx/bin/xxx.sh /usr/bin/xxx.sh

l 是 L不是I
xbstream解压备份文件 xbstream
xbstream -x -C ./ < /data/xxx/xxxxxxxxxxx.xb

解决在websocket的拦截器HandshakeInterceptor获取不到登录用户session的问题
拦截器代码:

public boolean beforeHandshake(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler webSocketHandler, Map<String, Object> map) throws Exception {
        // 将 request 对象转换为 ServletServerHttpRequest 对象
        ServletServerHttpRequest serverRequest = (ServletServerHttpRequest) request;
        // 获取 HTTP Session 对象
        HttpSession session = serverRequest.getServletRequest().getSession();
        if (session != null) {
            // 从 HTTP Session 中获取用户信息
            User user = (User) session.getAttribute("user");
            if (user != null) {
                // 将从 HTTP Session 中获取的用户信息存入 WebSocket 的 Attributes 对象中
                map.put("user", user);
                // 继续握手
                return true;
            }
        }
        // 终止握手
        return false;
    }

这一行
User user = (User) session.getAttribute("user");
使用拿不到登录用户的session。

经排查发现是controller里的session和socket拦截器的session不是同一个

导致的原因是:
前台调用登录的请求路径是127.0.0.1,  连接后台socket的地址是localhost, 所以导致两个session不是同一个

解决办法:
将登录和连接socket的地址改为相同。
DB2游标的declare continue handler for not found使用
create procedure resumeInstReset(in in_liquidationGroup bigint )
dynamic result sets 0
modifies sql data
language sql
begin
    declare var_instrumentID varchar(13);--
    declare var_legNumber smallint;--
    declare var_cflNumber smallint;--
    declare var_resetNumber smallint;--
    declare var_payRate float;--
    declare var_payAmount float;--
    declare var_status smallint;--

    declare log_notfound int default 0;--
    declare resetLogCur cursor for select InstrumentID,LegNumber,CflNumber,ResetNumber,PayRate,PayAmount,Status
         from InstResetLog  where LiquidationGroup = in_liquidationGroup;--

    declare continue handler for not found
         begin
              set log_notfound=1;--
         end;--

    open resetLogCur;--
    set log_notfound=0;--
    fetch resetLogCur into    var_instrumentID,var_legNumber,var_cflNumber,var_resetNumber,var_payRate,var_payAmount,var_status;--

    while log_notfound=0 do
         set log_notfound=0;--
         update InstReset set PayRate=payRate,PayAmount=payAmount,Status=status where InstrumentID=var_instrumentID and LegNumber=var_legNumber and CflNumber=var_cflNumber and ResetNumber=var_resetNumber;--
         fetch resetLogCur into  var_instrumentID,var_legNumber,var_cflNumber,var_resetNumber,var_payRate,var_payAmount,var_status;--
    end while;--
close resetLogCur;--
end@


注:
declare continue handler for not found
         begin
              set log_notfound=1;--
         end;--
这段代码是在while循环里,fetch操作的时候,如果出现not found,就会抛异常到上面这段,会给log_notfound赋值为1,
所以下次循环的时候,就会跳过此while循环,说明游标已经到最后一行。


对于多个游标的在一起使用,要在前一个游标使用完之后,在打开第二个游标之前,将log_notfound值重新设置为0,因为第一个游标读取完之后,会将这个值赋值为1,如果不重置值为0,第二个游标会不进while循环。

declare ProductAtCursor cursor for select Name,AttrNumber,LegNumber,
                    Factor,Type from wangkunxiang.PRODUCTATTRIBUTE  WHERE Name = productName;
                    
    declare updateIndexCursor cursor for select TmpAttrNumber2,TmpFactor2,FactorExsit2,TmpType2,TmpAttrNumber3
                    from SESSION.tempForUpdate Order BY TmpAttrNumber2;  
                                    
    declare continue handler for not FOUND 
            BEGIN
              SET endTable_mark=1;--
            END;                  
  
  SET startPos=70;
  SET pos=startPos;
  
  open ProductAtCursor;
  fetch ProductAtCursor into ProductName,AttrNumber,LegNumber,Factor,TYPE;

  while endTable_mark = 0 do 
    Begin
            if(AttrNumber<startPos and Type=1) THEN
              begin
                   if(exists( select TmpAttrNumber from SESSION.tempDealTagsIndex where TmpFactor = Factor)) THEN
                      begin
                           SET TmpAttrNumber2 = (select TmpAttrNumber from SESSION.tempDealTagsIndex where TmpFactor = Factor);
                           insert into SESSION.tempForUpdate VALUES(TmpAttrNumber2,Factor,1,1,AttrNumber);
                      END;
                   END IF;
              END;
            END IF;
           fetch ProductAtCursor into ProductName,AttrNumber,LegNumber,Factor,TYPE;

    END;
  END WHILE;
  close ProductAtCursor;

  SET endTable_mark=0;  -----这里将endTable_mark重置为0          
  open updateIndexCursor;
  fetch updateIndexCursor into AttrNumber,Factor,FactorExsit,Type,TmpAttrNumber3;

  while endTable_mark = 0 do
    Begin
            if(FactorExsit = 1 and Type = 1) THEN
              begin
                      update PRODUCTATTRIBUTE set AttrNumber=pos where AttrNumber = TmpAttrNumber3 and Name = ProductName;
                      SET pos = pos + 1;
              END;
            END IF;
           fetch updateIndexCursor into AttrNumber,Factor,FactorExsit,Type,TmpAttrNumber3;
    END;
  END WHILE;
  close updateIndexCursor;
Global site tag (gtag.js) - Google Analytics