临时笔记

2019-01-01 00:00:00

### Java nginx 真实 ip 问题 tomcat 通过 nginx 做反向代理后,获取客户端 ip 时拿到的是 nginx 的 ip,并非真实客户 ip 解决方案: 在 nginx 配置文件中添加下面的一条配置,将真实 ip 加入请求头中 `proxy_set_header X-Forwarded-For $remote_addr;` 再通过 java 代码取出对应的请求头,即可拿到真实 ip ``` public String getIp() { String requestHeader = "X-Forwarded-For"; // 优先从响应头中取出真实 IP 地址 String ipFromProxy = request.getHeader(requestHeader); if (StringUtils.isNotNull(ipFromProxy) && !"unknown".equalsIgnoreCase(ipFromProxy)) { String[] ipArr = ipFromProxy.split(","); return ipArr[0].trim(); } String remoteAddr = request.getRemoteAddr(); return remoteAddr; } ``` Nginx 代理 WebSockets 通过增加 Upgrade 和 Connection 头信息,来支持代理 WebSocket ``` location /websocket/ { proxy_pass http://websocket; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } ``` ### SQL 部分内容已迁移 SELECT INTO 和 INSERT INTO SELECT 两种表复制语句 ### Oracle 查询被锁定表 ``` SELECT O.OBJECT_NAME, S.MACHINE, S.TERMINAL, S.USERNAME, S.OSUSER, S.PROGRAM, S.SID, S.SERIAL# FROM GV$LOCKED_OBJECT L, DBA_OBJECTS O, GV$SESSION S WHERE L.OBJECT_ID  = O.OBJECT_ID AND L.SESSION_ID = S.SID; ``` ``` -- 杀掉会话 ALTER SYSTEM KILL SESSION 'SID,SERIAL#'; ``` ### Oracle 其他待学习函数 `OVER()` ``` WITH TEMP AS ( SELECT '01' AS A, '11' AS B, '111' AS C FROM DUAL UNION ALL SELECT '01' AS A, '12' AS B, '121' AS C FROM DUAL UNION ALL SELECT '01' AS A, '12' AS B, '122' AS C FROM DUAL UNION ALL SELECT '02' AS A, '21' AS B, '211' AS C FROM DUAL UNION ALL SELECT '02' AS A, '22' AS B, '221' AS C FROM DUAL UNION ALL SELECT '03' AS A, '31' AS B, '311' AS C FROM DUAL ) SELECT * FROM (SELECT A, B, C, MAX(B) OVER (PARTITION BY A ) AS MAXS FROM TEMP) WHERE B = MAXS; ``` `ROW_NUMBER()` ``` SELECT T1.* FROM ( SELECT ROW_NUMBER() OVER(PARTITION BY LYDH ORDER BY RKSJ DESC) RN, SUM(T.SSCS) OVER(PARTITION BY LYDH) SUM, T.LYDH, T.RKSJ, T.RKR FROM T_ERP_SHZTMX T ) T1 WHERE T1.RN = 1; ``` ``` SELECT TRUNC(SYSDATE,'dd') FROM DUAL; --2013-01-06 返回当前年月日 ``` ``` SELECT TO_CHAR('0.8', 'FM99990.00') FROM DUAL; ``` ``` -- 创建表同时创建散列分区 CREATE TABLE T_ERP_SMXSLSJLB_TEST PARTITION BY HASH (KHMC) PARTITIONS 10 AS SELECT * FROM T_ERP_SMXSLSJLB_BAK WHERE ROWNUM < 100; -- 散列分区分布 SELECT DBMS_ROWID.ROWID_OBJECT(ROWID) OBJ_ID, COUNT(*) FROM T_ERP_SMXSLSJLB_TEST GROUP BY DBMS_ROWID.ROWID_OBJECT(ROWID); -- 创建局部索引 CREATE INDEX T_ERP_SMXSLSJLB_TEST_INDEX ON T_ERP_SMXSLSJLB_TEST(KHMC) LOCAL; -- 删除表 DROP TABLE T_ERP_SMXSLSJLB_TEST; -- 查询用户表分区 SELECT * FROM USER_TAB_PARTITIONS; -- 查询用户回收站 SELECT * FROM USER_RECYCLEBIN; SELECT COUNT(*) FROM USER_RECYCLEBIN; -- 根据表名恢复表结构 FLASHBACK TABLE T_ERP_SMXSLSJLB_TEST TO BEFORE DROP; FLASHBACK TABLE "BIN$cd3tXq/iGjngUzgKqMDBqA==$0" TO BEFORE DROP; -- 清空回收站指定数据 PURGE TABLE "BIN$ceEiEsddHK3gUzgKqMACNA==$0"; ``` ### 其他技术 分布式事务 多线程 jvm 调优 tomcat 调优 java 爬虫:phantomjs [阿里 Maven](http://maven.aliyun.com/) [Echarts](http://echarts.baidu.com/) [使用Oracle函数索引 提高查询效率](http://database.51cto.com/art/201010/231096.htm) [阿里面试回来,想和Java程序员谈一谈](https://zhuanlan.zhihu.com/p/26089746) [多少k的java web程序员应该懂多线程和jvm优化](https://www.zhihu.com/question/59725713/answer/168709945?utm_medium=social&utm_source=qq) [GitHub 上有哪些优秀的 Java 爬虫项目?](https://www.zhihu.com/question/31427895) [Java工程师成神之路](http://www.hollischuang.com/archives/489) [成神之路系列文章](http://www.hollischuang.com/archives/1001) [互联网 Java 工程师进阶知识完全扫盲](https://github.com/doocs/advanced-java) [24小时邮箱](http://24mail.chacuo.net/) [在线发短信](http://www.afreesms.com/freesms/) [在线收短信](https://www.receive-sms-online.info/) [在线PS](https://pixlr.com/editor/?loc=zh-cn) [高精度IP定位_1](https://www.opengps.cn/Data/IP/LocHighAcc.aspx) [高精度IP定位_2](http://www.chaipip.com) [高精度IP定位_3](https://www.chaidu.com/App/Web/IP) [Ubuntu Pastebin 代码片段分享](http://paste.ubuntu.com/) [图片合成(QQ用)](https://bupt-hjm.github.io/fun-photo-combine/) [snipaste 截图工具](https://www.snipaste.com) [在线看PDM文件](http://www.dmanywhere.cn/) [Scratch](https://beta.scratch.mit.edu/) [Free Dynamic DNS - dynv6](https://dynv6.com/) 腾讯云开发者平台 https://dev.tencent.com/ https://studio.dev.tencent.com/ 高精度IP定位提供商: [RTBAsia](http://www.rtbasia.com) [埃文科技](http://www.ipplus360.com) 淘宝UED的前端智勇大闯关 http://ued.taobao.org/quiz/ http://ued.taobao.org/quiz2/ http://ued.taobao.org/quiz3/ 免注册网盘 https://letsupload.co/ https://secufiles.com/ https://mirrorace.com/ windows中的符号链接用法:`mklink /d ...` java 反射捕获的异常类型为 `InvocationTargetException` **Todo** ``` select trunc(sysdate, 'month') from dual; ```

分类:未分类     关键词:临时

评论(0) 浏览(74)