随笔分类 - JAVA面试
摘要:1.Student表: 2.SC表: 3.使用左外连接查询两个表,显示的数据是左表中的所有数据,包含NULL值。是下面的临时表 SELECT a.SId,a.Sname,b.score FROM Student a LEFT JOIN SC b ON a.SId = b.SId; 4.使用where
阅读全文
摘要:1.openresty+redis+lua缓存 使用openresty+lua脚本实现多级缓存: 用户访问openresty中的Nginx,若null则访问redis,若null则访问数据库,数据库返回信息并存储在redis,redis在存储到nginx中。 2.反射机制 1.加载类,返回Class
阅读全文
摘要:5.6 ConcurrentHashMap底层原理 5.6.1 jdk1.7 5.6.1.1 数组结构 数据结构是数组+segment对象,采用segment分段锁和CAS保证并发。 JDK1.7中的ConcurrentHashMap是由 segment数组结构和 HashEntry 数组结构组成,
阅读全文
摘要:5.4 HashMap底层原理 5.4.1初始长度 // 0000 0001 << 4 = 0001 0000 = 16 static final int DEFAULT_INITIAL_CAPACITY = 1 << 4; // aka 16 HashMap的初始长度为16,当不够用时,再扩展,但
阅读全文
摘要:一、静态内部类: 1.访问内部静态类时,不需要实例化外部类。 public class Outer { static class Inner { } } class OtherClass { Outer.Inner oi = new Outer.Inner(); } 2.静态内部类中可以定义静态成员
阅读全文
摘要:方法一:遍历条目entries (键值都用到时) Map<String, String> map = new HashMap<String, String>(); for (Map.Entry<String, String>entry : map.entrySet()) { String key =
阅读全文
摘要:Oracle中常用的数据类型: 常用的数据类型有:一.数值类型number: 在Oracle中取消了在mysql中的int类型,使用number代替,如果你在创建数据库表的时候使用了int类型会自动转换成number类型,并且Oracle没有这个”auto_increment”属性,所以它没法像My
阅读全文
摘要:一、MySQL/Oracle数据库优化总结 1.使用PreparedStatement比Statement性能好。 与Statement相比: ①PreparedStatement接口代表预编译的语句,它主要的优势在于可以减少SQL的编译错误并增加SQL的安全性(减少SQL注射攻击的可能性); ②P
阅读全文