数据库中char与varchar的区别

他们两个的底层数据结构都是线性表,但char是定长的,varchar是链表结构的。

过时的技术

===============================================================
GWT Google Web Toolkit 是一种允许开发人员使用 Java 编程语言快速构建和维护复杂但性能高的 JavaScript 前端应用程序的工具集,能够降低开发难度,尤其是与 Eclipse Google 插件结合使用时,优势更明显。有了 GWT可以使用 Java 编程语言编写 AJAX 前端,然后 GWT 会交叉编译到优化的JavaScript 中,而 JavaScript 可以自动在所有主要浏览器上运行。

k8s (全称:kubernetes)
Docker
https://my.oschina.net/jamesview/blog/2994112
serverless
https://www.npmjs.com/package/serverless
**
=================================================================================

java 通过发送 UDP-NetBIOS-NS 获取客户端的Mac地址

  1. UdpGetClientMacAddr umac = new UdpGetClientMacAddr(sip);
  2. String smac = umac.GetRemoteMacAddr();
  1. final UdpGetClientMacAddr umac = new UdpGetClientMacAddr(sip);
  2. //---长时间获取不到MAC地址则放弃
  3. ExecutorService exec = Executors.newFixedThreadPool(1);
  4. Callable<String> call = new Callable<String>() {
  5. public String call() throws Exception {
  6. return umac.GetRemoteMacAddr();
  7. }
  8. };
  9. try {
  10. Future<String> future = exec.submit(call);
  11. String smac = future.get(1000 * 1, TimeUnit.MILLISECONDS);
  12. loginMonitor.setMacAddress(smac);
  13. } catch (TimeoutException ex) {
  14. loginMonitor.setMacAddress("获取失败");
  15. logger.info("获取MAC地址超时");
  16. ex.printStackTrace();
  17. }
  18. // 关闭线程池
  19. exec.shutdown();
  20. //---
  1. package shmc.commonsys.security.controller;
  2. import java.io.IOException;
  3. import java.net.DatagramPacket;
  4. import java.net.DatagramSocket;
  5. import java.net.InetAddress;
  6. /**
  7. * 主机A向主机B发送“UDP-NetBIOS-NS”询问包,即向主机B的137端口,发Query包来询问主机B的NetBIOS Names信息。
  8. * 其次,主机B接收到“UDP-NetBIOS-NS”询问包,假设主机B正确安装了NetBIOS服务........... 而且137端口开放,则主机B会向主机A发送一个“UDP-NetBIOS-NS”应答包,即发Answer包给主机A。
  9. * 并利用UDP(NetBIOS Name Service)来快速获取远程主机MAC地址的方法
  10. *
  11. */
  12. public class UdpGetClientMacAddr {
  13. private String sRemoteAddr;
  14. private int iRemotePort=137;
  15. private byte[] buffer = new byte[1024];
  16. private DatagramSocket ds=null;
  17. public UdpGetClientMacAddr(String strAddr) throws Exception{
  18. sRemoteAddr = strAddr;
  19. ds = new DatagramSocket();
  20. }
  21. public final DatagramPacket send(final byte[] bytes) throws IOException {
  22. DatagramPacket dp = new DatagramPacket(bytes,bytes.length,InetAddress.getByName(sRemoteAddr),iRemotePort);
  23. ds.send(dp);
  24. return dp;
  25. }
  26. public final DatagramPacket receive() throws Exception {
  27. DatagramPacket dp = new DatagramPacket(buffer,buffer.length);
  28. ds.receive(dp);
  29. return dp;
  30. }
  31. public byte[] GetQueryCmd() throws Exception {
  32. byte[] t_ns = new byte[50];
  33. t_ns[0] = 0x00;
  34. t_ns[1] = 0x00;
  35. t_ns[2] = 0x00;
  36. t_ns[3] = 0x10;
  37. t_ns[4] = 0x00;
  38. t_ns[5] = 0x01;
  39. t_ns[6] = 0x00;
  40. t_ns[7] = 0x00;
  41. t_ns[8] = 0x00;
  42. t_ns[9] = 0x00;
  43. t_ns[10] = 0x00;
  44. t_ns[11] = 0x00;
  45. t_ns[12] = 0x20;
  46. t_ns[13] = 0x43;
  47. t_ns[14] = 0x4B;
  48. for(int i = 15; i < 45; i++){
  49. t_ns[i] = 0x41;
  50. }
  51. t_ns[45] = 0x00;
  52. t_ns[46] = 0x00;
  53. t_ns[47] = 0x21;
  54. t_ns[48] = 0x00;
  55. t_ns[49] = 0x01;
  56. return t_ns;
  57. }
  58. public final String GetMacAddr(byte[] brevdata) throws Exception {
  59. // 获取计算机名
  60. int i = brevdata[56] * 18 + 56;
  61. String sAddr="";
  62. StringBuffer sb = new StringBuffer(17);
  63. // 先从第56字节位置,读出Number Of Names(NetBIOS名字的个数,其中每个NetBIOS Names Info部分占18个字节)
  64. // 然后可计算出“Unit ID”字段的位置=56+Number Of Names×18,最后从该位置起连续读取6个字节,就是目的主机的MAC地址。
  65. for(int j = 1; j < 7;j++)
  66. {
  67. sAddr = Integer.toHexString(0xFF & brevdata[i+j]);
  68. if(sAddr.length() < 2)
  69. {
  70. sb.append(0);
  71. }
  72. sb.append(sAddr.toUpperCase());
  73. if(j < 6) sb.append(':');
  74. }
  75. return sb.toString();
  76. }
  77. public final void close() throws Exception {
  78. ds.close();
  79. }
  80. public final String GetRemoteMacAddr() throws Exception {
  81. byte[] bqcmd = GetQueryCmd();
  82. send(bqcmd);
  83. DatagramPacket dp = receive();
  84. String smac = GetMacAddr(dp.getData());
  85. close();
  86. return smac;
  87. }
  88. public static void main(String args[]) throws Exception{
  89. UdpGetClientMacAddr umac=new UdpGetClientMacAddr("172.19.1.198");
  90. umac=new UdpGetClientMacAddr("192.168.16.83");
  91. System.out.println(umac.GetRemoteMacAddr());
  92. }
  93. }

================================================================================

java通过执行系统命令,获取对方的mac地址

  1. // 1.获取IP方式
  2. public static String getIpAddress(HttpServletRequest request) {
  3. String ip = request.getHeader("X-real-ip");
  4. if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
  5. ip = request.getHeader("x-forwarded-for");
  6. }
  7. if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
  8. ip = request.getHeader("Proxy-Client-IP");
  9. }
  10. if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
  11. ip = request.getHeader("WL-Proxy-Client-IP");
  12. }
  13. if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
  14. ip = request.getHeader("HTTP_CLIENT_IP");
  15. }
  16. if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
  17. ip = request.getHeader("HTTP_X_FORWARDED_FOR");
  18. }
  19. if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
  20. ip = request.getRemoteAddr();
  21. }
  22. return ip;
  23. }
  24. // 2.通过IP获取Mac地址;
  25. static String getMacAddrByIp(String ip) {
  26. String macAddr = null;
  27. try {
  28. Process process = Runtime.getRuntime().exec("nbtstat -a " + ip);
  29. BufferedReader br = new BufferedReader(
  30. new InputStreamReader(process.getInputStream()));
  31. Pattern pattern = Pattern.compile("([A-F0-9]{2}-){5}[A-F0-9]{2}");
  32. Matcher matcher;
  33. for (String strLine = br.readLine(); strLine != null;
  34. strLine = br.readLine()) {
  35. matcher = pattern.matcher(strLine);
  36. if (matcher.find()) {
  37. macAddr = matcher.group();
  38. break;
  39. }
  40. }
  41. } catch (IOException e) {
  42. e.printStackTrace();
  43. }
  44. System.out.println(macAddr);
  45. return macAddr;
  46. }
  47. public static void main(String[] args) {
  48. String ip = "192.168.8.59";
  49. getMacAddrByIp(ip);
  50. }

————————————————
版权声明:本文为CSDN博主「qing_mei_xiu」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qing_mei_xiu/java/article/details/80745557