java最全面试宝典


Java . Java .....................................................................................................................7 1".java".........7 2Java goto?.......................................................................................................7 3&&&................................................................................................8 4 JAVA ..........................................................8 5switch byte long String ?...9 6shorts1=1;s1=s1+1;?shorts1=1;s1+=1;?....................... 9 7char ??..................................................9 8 2 8 ?............................................................... 9 9..................................................................................... 9 10 final 11 11"==" equals ................................................................. 11 12............................................................................. 12 13 static static ........................ 12 14Integer int .............................................................................................. 13 15Math.round(11.5)? Math.round(-11.5)?...................................13 16?............................................................................... 13 17 publicprivateprotected........................ 13 18Overload Override Overloaded ? 14 19 Constructor override?................................................................ 15 20? (implements)? (concrete class)? main .......................15 21 clone().............................................15 22................................................................................. 15 23java ......................................................................... 17 24abstract class interface ?................................................................. 17 25abstract method static, native synchronized?..................................................................................................................18 26Static Nested Class Inner Class ........................... 19 27............................. 20 28Anonymous Inner Class () extends() implements()interface()?................................................................................. 21 29super.getClass()...........................................................................21 30String ?.............................................................................22 31String s = "Hello";s = s + " world!"; String .....................................................................................................22 32 String ?....................................................................................... 23 33String s = new String("xyz"); String Object? 23 34String StringBuffer ............................................................................... 23 35 ?............................................... 24 36 length() ? String length() .....................24 37 String s="a"+"b"+"c"+"d";.................. 24 38 try {} return try finally {} code return ?....................................................25 39 ................................................................. 25 40 final, finally, finalize ...............................................................................27 41 ..................................................................... 27 42 error exception ?.............................................................................28 43 Java ..................................................... 28 44 5 runtime exception ................................................... 28 45 JAVA throws,throw,try,catch,finally try ...................................................................29 46 java ? stop() suspend() ..................................................................................29 47 sleep() wait() ?.............................................................................30 48 ................. 32 49. .................................................................. 33 50 ? ?..................................................33 51 run() start()? ...................................................................33 52 synchronized ?........................................................................................................... 33 53 ................................. 34 54 synchronized java.util.concurrent.locks.Lock ........................ 34 55 4 j 1 j 1 .....................................................................................................................36 56 10 100 10 100 50 .................................... 38 57 Collection .................................................................................. 43 58 Collection ........................................................43 59 ArrayList Vector .................................................................................... 44 60 HashMap Hashtable ...............................................................................44 61 List Map ?................................................................................................45 62 List, Set, Map Collection ?......................................................... 45 63 List Map Set ..............................45 64 ArrayList,Vector, LinkedList .........................................46 65 Vector .....................................................................46 66 Collection Collections ..................................................................... 47 67 Set ? == equals()? ?...............................................................................................47 68 ......................................................... 47 69 (x.equals(y) == true) hash code ?...................................................................................................................................48 70 TreeSet compareTo compareTo 48 71 5 ..................................................... 49 72 java JDK .............................................................................................49 73 .........................................................................................50 74 java java Serializable .................................................................................................................................51 75 JVM class ?........................................................52 76 heap stack .................................................................................. 52 77 GC ? GC?.............................................................................. 52 78 2 ............................................. 52 79 ................................................................................. 52 80 assert ...............................................................................................53 81 java ..........................................................53 82 java.lang.String .......................................................57 83. Java ...................................................................................................................57 . ......................................................................................................................61 1 a.txt b.txt c.txt a.txt b.txt . 61 2 d:\java .java d:\jad .java .jad ...............................................................................62 3 ABC 4 AB ABC DEF 6 ABC ABC+ .........................................................................................................................................65 4 .............................................................................................................65 5 java ...................................................66 6 .............................................................................................71 7 Singleton ..........................................................................................75 8 1............................................................................................................77 9 2............................................................................................................78 10 JAVA ...................... 79 11 a[n] java ................................................. 80 12 1011 > .................................................................................................81 . html&JavaScript&ajax ............................................................................................. 82 1. ............................................................................ 82 2. table n 3 123 456 789 ...................................................................... 83 3HTML form ? ?....................................................................................................... 84 4 HTML javascript .....84 5 ajax ...........................................85 . Java web ................................................................................................................... 85 1Tomcat ..................................................................................................85 2HTTP GET POST ...............................................................85 3 servlet;.......................................................................................... 85 4 Servlet ?....................................................................................86 5Servlet ...................................................................................................86 6SERVLET API forward() redirect() ................................................86 7 doGet() doPost() ................................................................... 86 8Request ..................................................................................... 87 9forward redirect ...................................................................................... 87 10 request.getAttribute() request.getParameter() ?...............................88 11. jsp ? ? ................................ 88 12. jsp ? ?..........................................................................88 13 JSP ......................................................................................................89 14. JSP INCLUDE INCLUDE ............................................. 89 15 ? ?..............................................................89 16 .........................................................................................89 17 JSP Servlet ................. 90 18 MVC ? ?............................................90 19 web iso8859-1 ............................................................................. 90 20 n reset.....................................................91 . ......................................................................................................................91 1....... 91 2 .....................................................................................................................................91 3 ?......................................................... 92 4 ?............................................................................................. 94 5 ?......................................................................... 95 6union union all ?............................................................................... 96 7. ......................................................................................................................97 8. SQL 80 ...................................100 9. ........................................................................................100 10. 101 .......................................................... 101 11. .............................................................................................. 102 12. .............................................................. 103 13. id , ................................................ 104 14. .................................................................................. 104 15. ...................................................................... 105 16 45 12 ............................... 106 17. ..............................................................................................107 18 100 ?..........................107 19 .......................................................................................................................................108 20. xxx sql ............................................................................................... 108 21 Jdbc ..........................................................................109 22 JDBC ............................................................................... 109 23 JDBC PreparedStatement Statement ...................................... 110 24. jdbc oracle ............................................111 25 Class.forName ? ?...................................................................111 26 ........................................................................... 111 27 JDBC , ...............112 28 ?................................................................................. 112 29 ?..................................................................113 30 ORM? JDBC ?....................................................113 . XML ....................................................................................................................... 113 1xml ? ?.......................................................................113 2 xml ? ?......................................114 3 jdom xml ? ?................................... 114 4 JAVA XML ........................................................................... 115 5XML XML ...........................................................................................................................117 . .................................................................................................... 117 1 Struts ......................................................................................117 2 Hibernate ............................................................................... 118 3AOP ........................................................................................................ 118 4 Spring ............................................................................................ 118 5 Struts Action servlet .......................................................................... 120 6Struts 1. MVC , .......................................................................................................................120 7STRUTS ( STRUTS )......................................................................121 8 struts1 struts2 ............................................................................121 9hibernate update() saveOrUpdate() session load() get() .......................................................................................................................................122 10 Hibernate JDBC ? one to many . 122 11 iBatis Hibernate ?......................................................................... 122 12 Hibernate orm ?................................... 122 9hibernate inverse ?..........................................................................122 13 DAO DAO ?................................................................ 123 14 spring+Hibernate ?............................................................ 123 15 spring+Hibernate ?............................................................ 123 16. hibernate ........................................................................... 123 17. Hibernate ............................................................................ 123 18 Spring ? Bean message , , "Hello" XML ?.....................................................125 19 Jdo ?...........................................................................................................125 20 spring IOC AOP............................................................................... 126 21 STRUTS ....................................................................................... 126 22 spring EJB .................................................................................... 126 . ....................................................................................................126 1UML ...............................................................................................................126 2j2ee ..............................................................126 3 ? ?..................................................127 . j2ee ......................................................................................................................... 127 1BS CS .................................................................................... 127 2 WEB SERVER .............................................................. 128 3.............................................................................................128 4J2EE ....................................................................................................... 128 5J2EE J2EE................................................ 128 6 J2EE ( ).................................... 129 7 weblogic ?.......................................................................129 8 weblogic ( ) ?.................... 129 9 ?................................................................... 130 10 weblogic ( ,Domain) jms ejb , ?...............................130 11 weblogic Domain ? helloWorld.jsp , http:// : //helloword.jsp ? javaBean ?..................................................................................................... 130 12 weblogic ejb ................................................130 13 weblogic ssl j2ee( ) ssl ?......................................................................................................................... 130 14 weblogic EJB?......................................................... 131 . EBJ ......................................................................................................................... 131 1EJB SessionBean EntityBean StatefulBean StatelessBean ..................................................................... 131 2 EJB 7 Transaction Level?....................................................131 3EJB JAVABEAN ...............................................................................131 4EJB SessionBean,EntityBean .......................................................................................................................................132 5EJB ............................................................................................. 132 6EJB ..................................................................................................... 132 7EJB ..................................................................................................... 132 8 EJB ................................................................ 133 . webservice ..........................................................................................................133 1WEB SERVICE JSWDL JAXP JAXM SOAP UDDI,WSDL ....................................................................................................133 2CORBA ? ?...............................................................................133 3. Linux................................................................................................................................. 134 4LINUX GDI ........................................................................134 5. ..........................................................................................................134 6 .................................................................................................134 7 (&,|,^) (&&,||) ............................................... 134 . ............................................................................................................................134 1 ................................................................................. 134 2 http://tomcat.apache.org/ ?.....................135 3 JAVA ..........................................................135 java java 1. Java 基础部分基础部分基础部分基础部分 io 1 ".java" public public 2Java goto? java java 3 &&& &&& and true true false false && false if(str != null && !str.equals(“”)) str null NullPointerException && & NullPointerException If(x==33 & ++y>0) y If(x==33 && ++y>0) && boolean & 0x0f & 4 bit 0x31 & 0x0f 0x01 && & 4 JAVA Java break ok: for(int i=0;i<10;i++) { for(intj=0;j<10;j++) { System.out.println(“i=” + i + “,j=” + j); if(j == 5) break ok; } } int arr[][] = {{1,2,3},{4,5,6,7},{9}}; boolean found = false; for(int i=0;i 78 "def" ---> 62 "xyz" ---> 65 hashSet 62,65,78 LinkedHashSet hashcode !hashset hashcode equals new Student HashSet HashSet size hashcode equals size Vector HashSet 64 ArrayList,Vector, LinkedList ArrayList Vector Vector synchronized ArrayList LinkedList LinkedList LinkedList LinkedList 65 Vector Vector newVector = new Vector(); For (int i=0;io1.age?1:age1 ){ regex = "" + seperators[0] + "|" + seperators[1]; }else{ regex = "" + seperators[0]; } words = results.split(regex); } public String nextWord(){ if(pos == words.length) return null; return words[pos++]; } } 2 d:\java .java d:\jad .java .jad listFiles FileFilter FileFilter FileFilter import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.FilenameFilter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; public class Jad2Java { public static void main(String[] args) throws Exception { File srcDir = new File("java"); if(!(srcDir.exists() && srcDir.isDirectory())) throw new Exception(" "); File[] files = srcDir.listFiles( new FilenameFilter(){ public boolean accept(File dir, String name) { return name.endsWith(".java"); } } ); System.out.println(files.length); File destDir = new File("jad"); if(!destDir.exists()) destDir.mkdir(); for(File f :files){ FileInputStream fis = new FileInputStream(f); String destFileName = f.getName().replaceAll("\\.java$", ".jad"); FileOutputStream fos = new FileOutputStream(new File(destDir,destFileName)); copy(fis,fos); fis.close(); fos.close(); } } private static void copy(InputStream ips,OutputStream ops) throws Exception{ int len = 0; byte[] buf = new byte[1024]; while((len = ips.read(buf)) != -1){ ops.write(buf,0,len); } } } 1. class jad2java{ 1. java 1.1 File srcDir = new File("d:\\java"); 1.2 java File[] files = srcDir.listFiles(new MyFileFilter()); 1.3 .java class MyFileFilter implememyts FileFilter{ public boolean accept(File pathname){ return pathname.getName().endsWith(".java") } } 2. 2.1 2.2 . 2.3 File File // 2.4 // } listFiles File[] listFiles(FileFilter filter){ File[] files = listFiles(); //Arraylist acceptedFilesList = new ArrayList(); File[] acceptedFiles = new File[files.length]; int pos = 0; for(File file: files){ boolean accepted = filter.accept(file); if(accepted){ //acceptedFilesList.add(file); acceptedFiles[pos++] = file; } } Arrays.copyOf(acceptedFiles,pos); //return (File[])accpetedFilesList.toArray(); } 3 ABC 4 AB ABC DEF 6 ABC ABC+ n public static void main(String[] args) throws Exception{ String str = " a abc def'; String str = " ABC "; int num = trimGBK(str.getBytes("GBK"),5); System.out.println(str.substring(0,num) ); } public static int trimGBK(byte[] buf,int n){ int num = 0; boolean bChineseFirstHalf = false; for(int i=0;i this .value) { if (right == null ) { right = new Node(); right.value=value; } else { right.store(value); } } } public boolean find( int value) { System. out .println("happen " + this .value); if (value == this .value) { return true ; } else if (value> this .value) { if (right == null ) return false ; return right.find(value); }else { if (left == null ) return false ; return left.find(value); } } public void preList() { System. out .print( this .value + ","); if (left!= null ) left.preList(); if (right!= null ) right.preList(); } public void middleList() { if (left!= null ) left.preList(); System. out .print( this .value + ","); if (right!= null ) right.preList(); } public void afterList() { if (left!= null ) left.preList(); if (right!= null ) right.preList(); System. out .print( this .value + ","); } public static void main(String [] args) { int [] data = new int [20]; for (int i=0;i this.value) { if(right != null) right.add(value); else { Node node = new Node(value); right = node; } } else{ if(left != null) left.add(value); else { Node node = new Node(value); left = node; } } } public boolean find(int value){ if(value == this.value) return true; else if(value > this.value){ if(right == null) return false; else return right.find(value); }else{ if(left == null) return false; else return left.find(value); } } public void display(){ System.out.println(value); if(left != null) left.display(); if(right != null) right.display(); } /*public Iterator iterator(){ }*/ public static void main(String[] args){ int[] values = new int[8]; for(int i=0;i<8;i++){ int num = (int)(Math.random() * 15); //System.out.println(num); //if(Arrays.binarySearch(values, num)<0) if(!contains(values,num)) values[i] = num; else i--; } System.out.println(Arrays.toString(values)); Node root = new Node(values[0]); for(int i=1;iuser2.value) { return 1; }else { return user1.name.compareTo(user2.name); } } } ); Iterator iterator = results.keySet().iterator(); while (iterator.hasNext()) { String name = (String)iterator.next(); Integer value = (Integer)results.get(name); if (value > 1) { sortedResults.add( new User(name,value)); } } printResults (sortedResults); } private static void printResults(TreeSet sortedResults) { Iterator iterator = sortedResults.iterator(); while (iterator.hasNext()) { User user = (User)iterator.next(); System. out .println(user.name + ":" + user.value); } } public static void dealLine(String line,Map map) { if (!"".equals(line.trim())) { String [] results = line.split(","); if (results.length == 3) { String name = results[1]; Integer value = (Integer)map.get(name); if (value == null ) value = 0; map.put(name,value + 1); } } } } 7 Singleton public class SingleTon { private SingleTon(){ } // private final static SingleTon instance = new SingleTon(); public static SingleTon getInstance(){ return instance; } } public class SingleTon { private SingleTon(){} private static instance = null;//new SingleTon(); public static synchronized SingleTon getInstance(){ if(instance == null) instance = new SingleTon(); return instance; } } public enum SingleTon{ ONE; } public class SequenceGenerator{ // private int count = 0; public synchronized int getSequence(){ ++count; } // private SequenceGenerator(){} private final static instance = new SequenceGenerator(); public static SingleTon getInstance(){ return instance; } } public class MemoryDao { private HashMap map = new HashMap(); public void add(Student stu1){ map.put(SequenceGenerator.getInstance().getSequence(),stu1); } // MemoryDao } Singleton Java Class Singleton : : private static private public getInstance , public class Singleton { private Singleton(){} // // private private static Singleton instance = new Singleton(); // class public static Singleton getInstance() { return instance; } } : public class Singleton { private static Singleton instance = null; public static synchronized Singleton getInstance() { // // if (instance==null) instance new Singleton(); return instance; } } : private static 8 1 带 n怪n截n映n 挥带带带 n次张怪感操 张怪感操 怪截操截 截未截映 未映未搞 未映未搞 截未截映 怪截操截 张怪感操 public static void doubleNum(int n) { System.out.println(n); if(n<=5000) doubleNum(n*2); System.out.println(n); } 9 2 张 张带 怪 张 怪 映 package cn.itcast; import java.util.Date; public class A1 { public static void main(String [] args) { System. out .println( computeAge (8)); } public static int computeAge( int n) { if (n==1) return 10; return computeAge (n-1) + 2; } } Gaibaota(N) = Gaibaota(N-1) + n public static void toBinary( int n,StringBuffer result) { if (n/2 != 0) toBinary (n/2,result); result.append(n%2); } 10 JAVA public class QuickSort { /** * * @param strDate * @param left * @param right */ public void quickSort(String[] strDate,int left,int right){ String middle,tempDate; int i,j; i=left; j=right; middle=strDate[(i+j)/2]; do{ while(strDate[i].compareTo(middle)<0&& i0&& j>left) j--; // if(i<=j){ // tempDate=strDate[i]; strDate[i]=strDate[j]; strDate[j]=tempDate; i++; j--; } }while(i<=j); // if(ileft){ quickSort(strDate,left,j); } } /** * @param args */ public static void main(String[] args){ String[] strVoid=new String[]{"11","66","22","0","55","22","0","32"}; QuickSort sort=new QuickSort(); sort.quickSort(strVoid,0,strVoid.length-1); for(int i=0;i 龄etu龄n s速尤龄eve龄se喻在尤to脚t龄需n错喻在尤龄ep首身都e演首首喻候 装 ]候姓候 候在尤龄ep首身都e演首首喻候 天 候姓候 候在尤龄ep首身都e演首首喻候天候姓候候在尤龄ep首身都e演首首喻候天候姓候候在植 public class RenMingBi { /** * @param args add by zxx ,Nov 29, 2008 */ private static final char[] data = new char[]{ '',' ',' ',' ',' ',' ',' ',' ',' ',' ' }; private static final char[] units = new char[]{ '',' ',' ',' ',' ',' ',' ',' ',' ' }; public static void main(String[] args) { // TODO Auto-generated method stub System.out.println( convert(135689123)); } public static String convert(int money) { StringBuffer sbf = new StringBuffer(); int unit = 0; while(money!=0) { sbf.insert(0,units[unit++]); int number = money%10; sbf.insert(0, data[number]); money /= 10; } return sbf.toString(); } } 三三三三. html&JavaScript&ajax 部分部分部分部分 1. 2004-11-21 12 JAVASCRIPT , //
2. table n 3 123 456 789
1
2
3
4
5
6
7
8
9
10
3HTML form ? ?
4 HTML javascript 5 ajax 四四四四. Java web 部分部分部分部分 1Tomcat : web.xml jsp Servlet tomcat jvm 2HTTP GET POST :servlet javax.servlet.Servlet init,service destroy 3 servlet; :servlet javax.servlet.Servlet init,service destroy 4 Servlet ? :servlet javax.servlet.Servlet init,service destroy Servlet init service service doXXX doGet doPost destroy web servlet servlet init() servlet service() do***() web servlet destroy() 5Servlet public class ServletName extends HttpServlet { public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { } public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { } } 6SERVLET API forward() redirect() : forward() sendRedirect() 7 doGet() doPost() Jsp FORM method get doGet() post doPost() 8Request setAttribute(String name,Object) name request getAttribute(String name) name getAttributeNames() request getCookies() Cookie Cookie getCharacterEncoding() getContentLength() Body getHeader(String name) HTTP getHeaders(String name) request Header getHeaderNames() request Header getInputStream() getMethod() getParameter(String name) name getParameterNames() getParametervalues(String name) name getProtocol() getQueryString() getRequestURI() getRemoteAddr() IP getRemoteHost() getSession([Boolean create]) Session getServerName() getServletPath() getServerPort() removeAttribute(String name) 9forward redirect forward URL URL redirect , , session,request 10 request.getAttribute() request.getParameter() ? 11. jsp ? ? :JSP 9 request GET/POST response pageContext session application servlet out config servlet page JSP exception request HttpServletRequest cookie, header, session response HttpServletResponse cookies, out javax.jsp.JspWriter pageContext javax.servlet.jsp.PageContext servlet API servlet session javax.servlet.http.HttpSession Session applicaton javax.servle.ServletContext servlet servlet config javax.servlet.ServletConfig servlet page servlet 12. jsp ? ? :JSP 6 jsp:include jsp:useBean JavaBean jsp:setProperty JavaBean jsp:getProperty JavaBean jsp:forward jsp:plugin Java OBJECT EMBED 13 JSP isErrorPage( Exception )isELIgnored( ) 14. JSP INCLUDE INCLUDE INCLUDE jsp:include INCLUDE include , <%@ include file=included.htm %> 15 ? ? forward sendRedirect include . go to 16 request session application cookie 17 JSP Servlet JSP Servlet Servlet JSP " servlet" Servlet JSP Servlet Java HTML JSP Java HTML .jsp JSP Servlet 18 MVC ? ? :MVC Model View Controller Model JavaBean EJB View JSP Controller Servlet 19 web iso8859-1 Public String translate (String str) { String tempStr = ""; try { tempStr = new String(str.getBytes("ISO-8859-1"), "GBK"); tempStr = tempStr.trim(); } catch (Exception e) { System.err.println(e.getMessage()); } return tempStr; } 20 n reset 五五五五. 数据库部分数据库部分数据库部分数据库部分 1 employee: eid,ename,salary,deptid; select * from employee order by deptid desc,salary 2 mysql> create table employee921(id int primary key auto_increment,name varchar(5 0),salary bigint,deptid int); mysql> insert into employee921 values(null,'zs',1000,1),(null,'ls',1100,1),(null ,'ww',1100,1),(null,'zl',900,1) ,(null,'zl',1000,2), (null,'zl',900,2) ,(null,'z l',1000,2) , (null,'zl',1100,2); sql select avg(salary) from employee921 group by deptid; mysql> select employee921.id,employee921.name,employee921.salary,employee921.dep tid tid from employee921 where salary > (select avg(salary) from employee921 where deptid = tid); group by where having group by where mysql> select employee921.id,employee921.name,employee921.salary,employee921.dep tid tid from employee921 where salary > (select avg(salary) from employee921 group by deptid having deptid = tid); select count(*) ,tid from ( select employee921.id,employee921.name,employee921.salary,employee921.deptid tid from employee921 where salary > (select avg(salary) from employee921 where deptid = tid) ) as t group by tid ; select a.ename,a.salary,a.deptid from emp a, (select deptd,avg(salary) avgsal from emp group by deptid ) b where a.deptid=b.deptid and a.salary>b.avgsal; 3 ? create procedure insert_Student (_name varchar(50),_age int ,out _id int) begin insert into student value(null,_name,_age); select max(stuId) into _id from student; end; call insert_Student('wfz',23,@id); select @id; mysql> create trigger update_Student BEFORE update on student FOR EACH ROW -> select * from student; create trigger update_Student BEFORE update on student FOR EACH ROW insert into student value(null,'zxx',28); mysql create trigger update_Student BEFORE update on student FOR EACH ROW delete from articles where id=8; OLD.id Facebook UCH mysql> delimiter | mysql> create procedure insertArticle_Procedure (pTitle varchar(50),pBid int,out pId int) -> begin -> insert into article1 value(null,pTitle,pBid); -> select max(id) into pId from article1; -> end; -> | Query OK, 0 rows affected (0.05 sec) mysql> call insertArticle_Procedure(' ',1,@pid); -> | Query OK, 0 rows affected (0.00 sec) mysql> delimiter ; mysql> select @pid; +------+ | @pid | +------+ | 3 | +------+ 1 row in set (0.00 sec) mysql> select * from article1; +----+--------------+------+ | id | title | bid | +----+--------------+------+ | 1 | test | 1 | |2 |chuanzhiboke|1 | | 3 | | 1 | +----+--------------+------+ 3 rows in set (0.00 sec) create table board1(id int primary key auto_increment,name varchar(50),ar ticleCount int); create table article1(id int primary key auto_increment,title varchar(50) ,bid int references board1(id)); delimiter | create trigger insertArticle_Trigger after insert on article1 for each ro w begin -> update board1 set articleCount=articleCount+1 where id= NEW.bid; -> end; -> | delimiter ; insert into board1 value (null,'test',0); insert into article1 value(null,'test',1); declare NEW.posttime 4 ? 1NF , 2NF 2NF 1NF 2NF 1NF 2NF 3NF 2NF 3NF 1 2 3 id id id 5 ? PreparedStatement Statement sql “inert into user values(1,1,1)”- “inert into user values(2,2,2)”- “inert into user values(?,?,?)”- hibernate empleyee->Deptment employee deptid mysql 1. select e.name,e.salary where e.managerid=(select id from employee where name='zxx'); 2. select e.name,e.salary,m.name,m.salary from employees e,employees m where e.managerid = m.id and m.name='zxx'; sql sql sql  oracle   ? PreparedStatment 4 3 m*n select * from flight,city where flight.startcityid=city.cityid and city.name='beijing'; m + n select * from flight where startcityid = (select cityid from city where cityname='beijing'); select flight.id,'beijing',flight.flightTime from flight where startcityid = (select cityid from city where cityname='beijing') 6union union all ? Student drop table student; create table student ( id int primary key, name nvarchar2(50) not null, score number not null ); insert into student values(1,'Aaron',78); insert into student values(2,'Bill',76); insert into student values(3,'Cindy',89); insert into student values(4,'Damon',90); insert into student values(5,'Ella',73); insert into student values(6,'Frado',61); insert into student values(7,'Gill',99); insert into student values(8,'Hellen',56); insert into student values(9,'Ivan',93); insert into student values(10,'Jay',90); commit; Union Union All select * from student where id < 4 union select * from student whereid>2andid<6 1 Aaron 78 2 Bill 76 3 Cindy 89 4 Damon 90 5 Ella 73 Union All 1 Aaron 78 2 Bill 76 3 Cindy 89 3 Cindy 89 4 Damon 90 5 Ella 73 Union Union All UNION UNION select * from gc_dfys union select * from ls_jg_dfys SQL UNION ALL UNION ALL UNION UNION ALL 7. s默首s默首s默首s默首 感张感张感张感张 截带截带截带截带 真熟真熟真熟真熟 s默首 se龄ve龄 张 se首e都t top 张带 堆 f龄o高 t w队e龄e 需金 not 需n 喻se首e都t top 感带 需金 f龄o高 t o龄金e龄 速y 需金 在 o龄金e 速y 需金 s默首 se龄ve龄 怪 se首e都t top 张带 堆 f龄o高 t w队e龄e 需金 需n 喻se首e都t top 截带 需金 f龄o高 t o龄金e龄 速y 需金在 o龄金e龄 速y 需金 金es都 高ys默首 se首e都t 堆 f龄o高 t o龄金e龄 速y 需金 首需高需t 感带姓张带 oracle select * from (select rownum r,* from t where r<=40) where r>30 -------------------- ------------------------------------- pageSize=20; pageNo = 5; 1. 1 sql mysql:sql = "select * from articles limit " + (pageNo-1)*pageSize + "," + pageSize; oracle: sql = "select * from " + "(select rownum r,* from " + "(select * from articles order by postime desc)" + "where rownum<= " + pageNo*pageSize +") tmp " + "where r>" + (pageNo-1)*pageSize; 7 rownum oracle rownum order by rownum order by rownum rownum order by rownum sqlserver:sql = "select top 10 * from id not id(select top " + (pageNo-1)*pageSize + "id from articles)" DataSource ds = new InitialContext().lookup(jndiurl); Connection cn = ds.getConnection(); //"select * from user where id=?" --->binary directive PreparedStatement pstmt = cn.prepareSatement(sql); ResultSet rs = pstmt.executeQuery() while(rs.next()) { out.println(rs.getString(1)); } 2. pageSize=20; pageNo = 5; cn = null stmt = null; rs = null; try { sqlserver:sql = "select * from articles"; DataSource ds = new InitialContext().lookup(jndiurl); Connection cn = ds.getConnection(); //"select * from user where id=?" --->binary directive PreparedStatement pstmt = cn.prepareSatement(sql); ResultSet rs = pstmt.executeQuery() for(int j=0;j<(pageNo-1)*pageSize;j++) { rs.next(); } int i=0; while(rs.next() && i<10) { i++; out.println(rs.getString(1)); } } cacth(){} finnaly { if(rs!=null)try{rs.close();}catch(Exception e){} if(stm......... if(cn............ } 3. pageSize=20; pageNo = 5; cn = null stmt = null; rs = null; try { sqlserver:sql = "select * from articles"; DataSource ds = new InitialContext().lookup(jndiurl); Connection cn = ds.getConnection(); //"select * from user where id=?" --->binary directive PreparedStatement pstmt = cn.prepareSatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,...); // SQLFeatureNotSupportedException ResultSet rs = pstmt.executeQuery() rs.absolute((pageNo-1)*pageSize) int i=0; while(rs.next() && i<10) { i++; out.println(rs.getString(1)); } } cacth(){} finnaly { if(rs!=null)try{rs.close();}catch(Exception e){} if(stm......... if(cn............ } 8. SQL 80 name kecheng fenshu 81 75 76 90 81 100 90 sql create table score(id int primary key auto_increment,name varchar(20),subject varchar(20),score int); insert into score values (null,' ',' ',81), (null,' ',' ',75), (null,' ',' ',76), (null,' ',' ',90), (null,' ',' ',81), (null,' ',' ',100), (null,' ',' ',90); A: select distinct name from score where name not in (select distinct name from score where score<=80) B:select distince name t1 from score where 80< all (select score from score where name=t1); 9. 金ep身龄t高ent n身高e姓 截 身姓速姓都姓金姓 s默首 尤 se首e都t 身尤n身高e姓 速尤n身高e f龄o高 te身高 身姓 te身高 速 w队e龄e 身尤n身高e 模 速尤n身高e 10. 101 SQL TestDB 101 TestDB 112 AccID Occmonth DebitOccur JcyAudit Select * from TestDB sql drop table if exists TestDB; create table TestDB(id int primary key auto_increment,AccID varchar(20), Occmonth date, DebitOccur bigint); insert into TestDB values (null,'101','1988-1-1',100), (null,'101','1988-2-1',110), (null,'101','1988-3-1',120), (null,'101','1988-4-1',100), (null,'101','1988-5-1',100), (null,'101','1988-6-1',100), (null,'101','1988-7-1',100), (null,'101','1988-8-1',100); -- insert into TestDB values (null,'102','1988-1-1',90), (null,'102','1988-2-1',110), (null,'102','1988-3-1',120), (null,'102','1988-4-1',100), (null,'102','1988-5-1',100), (null,'102','1988-6-1',100), (null,'102','1988-7-1',100), (null,'102','1988-8-1',100); -- insert into TestDB values (null,'103','1988-1-1',150), (null,'103','1988-2-1',160), (null,'103','1988-3-1',180), (null,'103','1988-4-1',120), (null,'103','1988-5-1',120), (null,'103','1988-6-1',120), (null,'103','1988-7-1',120), (null,'103','1988-8-1',120); -- insert into TestDB values (null,'104','1988-1-1',130), (null,'104','1988-2-1',130), (null,'104','1988-3-1',140), (null,'104','1988-4-1',150), (null,'104','1988-5-1',160), (null,'104','1988-6-1',170), (null,'104','1988-7-1',180), (null,'104','1988-8-1',140); -- insert into TestDB values (null,'105','1988-1-1',100), (null,'105','1988-2-1',80), (null,'105','1988-3-1',120), (null,'105','1988-4-1',100), (null,'105','1988-5-1',100), (null,'105','1988-6-1',100), (null,'105','1988-7-1',100), (null,'105','1988-8-1',100); select distinct AccID from TestDB where AccID not in (select TestDB.AccIDfrom TestDB, (select * from TestDB where AccID='101') as db101 where TestDB.Occmonth=db101.Occmonth and TestDB.DebitOccur<=db101.DebitOccur ); 11. ye身龄 高ont队 身高ount 张未未张 张 张尤张 张未未张 怪 张尤怪 张未未张 感 张尤感 张未未张 截 张尤截 张未未怪 张 怪尤张 张未未怪 怪 怪尤怪 张未未怪 感 怪尤感 张未未怪 截 怪尤截 ye身龄 高张 高怪 高感 高截 张未未张 张尤张 张尤怪 张尤感 张尤截 张未未怪 怪尤张 怪尤怪 怪尤感 怪尤截 s默首 金龄op t身速首e 需f ex需sts s身首es植 都龄e身te t身速首e s身首es喻需金 需nt 身uto质需n都龄e高ent p龄需高身龄y 餐ey姓ye身龄 v身龄都队身龄喻张带在姓 高ont队 v身龄都队身龄喻张带在姓 身高ount f首o身t喻怪姓张在在植 需nse龄t 需nto s身首es v身首ues 喻nu首首姓唤张未未张唤姓唤张唤姓张尤张在姓 喻nu首首姓唤张未未张唤姓唤怪唤姓张尤怪在姓 喻nu首首姓唤张未未张唤姓唤感唤姓张尤感在姓 喻nu首首姓唤张未未张唤姓唤截唤姓张尤截在姓 喻nu首首姓唤张未未怪唤姓唤张唤姓怪尤张在姓 喻nu首首姓唤张未未怪唤姓唤怪唤姓怪尤怪在姓 喻nu首首姓唤张未未怪唤姓唤感唤姓怪尤感在姓 喻nu首首姓唤张未未怪唤姓唤截唤姓怪尤截在植 se首e都t s身首es尤ye身龄 姓 喻se首e都t t尤身高ount f龄o高 s身首es t w队e龄e t尤高ont队次唤张唤 身n金 t尤ye身龄次 s身首es尤ye身龄在 唤张唤姓 喻se首e都t t尤身高ount f龄o高 s身首es t w队e龄e t尤高ont队次唤张唤 身n金 t尤ye身龄次 s身首es尤ye身龄在 唤怪唤姓 喻se首e都t t尤身高ount f龄o高 s身首es t w队e龄e t尤高ont队次唤张唤 身n金 t尤ye身龄次 s身首es尤ye身龄在 唤感唤姓 喻se首e都t t尤身高ount f龄o高 s身首es t w队e龄e t尤高ont队次唤张唤 身n金 t尤ye身龄次 s身首es尤ye身龄在 身s 唤截唤 f龄o高 s身首es 错龄oup 速y ye身龄植 12. 需金姓t需t首e姓postuse龄姓post金身te姓p身龄ent需金 s默首 drop table if exists articles; create table articles(id int auto_increment primary key,title varchar(50), postuser varchar(10), postdate datetime,parentid int references articles(id)); insert into articles values (null,' ',' ','1998-10-10 12:32:32',null), (null,' ',' ','1998-10-10 12:34:32',null), (null,' 1',' ','1998-10-10 12:35:32',1), (null,' 1',' ','1998-10-10 12:36:32',2), (null,' 2',' ','1998-10-10 12:37:32',1), (null,' 3',' ','1998-10-10 12:38:32',1), (null,' 2',' ','1998-10-10 12:39:32',2), (null,' 4',' ','1998-10-10 12:39:40',1); select a.title,a.postuser, (select max(postdate) from articles where parentid=a.id) reply from articles a where a.parentid is null; where from 13. id , 2. : id 1 2005001 0001 69 2 2005002 0001 89 3 2005001 0001 69 A: delete from tablename where id not in(select min(id ) from tablename group by , , , , ) create table student2(id int auto_increment primary key,code varchar(20),name varchar(20)); insert into student2 values(null,'2005001',' '),(null,'2005002',' '),(null,'2005001',' '); // mysql delete from student2 where id not in(select min(id) from student2 group by name); // select * from student2 where id not in(select min(id) from student2 group by name); // delete from student2 where id not in(select mid from (select min(id) mid from student2 group by name) as t); delete from student2 where id not in(select min(id) from (select * from s tudent2) as t group by t.name); 14. flight{flightID,StartCityID ,endCityID,StartTime} city{cityID, CityName) create table city(cityID int auto_increment primary key,cityName varchar(20)); create table flight (flightID int auto_increment primary key, StartCityID int references city(cityID), endCityID int references city(cityID), StartTime timestamp); // insert into city values(null,' '),(null,' '),(null,' '); insert into flight values (null,1,2,'9:37:23'),(null,1,3,'9:37:23'),(null,1,2,'10:37:23'),(null,2,3,'10:37:23'); 1 select * from flight f,city c where f.endcityid = c.cityid and startcityid = (select c1.cityid from city c1 where c1.cityname = " ") order by c.cityname asc; mysql> select flight.flightid,' ' startcity, e.cityname from flight,city e wh ere flight.endcityid=e.cityid and flight.startcityid=(select cityid from city wh ere cityname=' '); mysql> select flight.flightid,s.cityname,e.cityname from flight,city s,city e wh ere flight.startcityid=s.cityid and s.cityname=' ' and flight.endCityId=e.cit yID order by e.cityName desc; 2 select c1.CityName,c2.CityName,f.StartTime,f.flightID from city c1,city c2,flight f where f.StartCityID=c1.cityID and f.endCityID=c2.cityID and c1.cityName=' ' and c2.cityName=' ' 32005-5-8 select count(*) from (select c1.CityName,c2.CityName,f.StartTime,f.flightID from city c1,city c2,flight f where f.StartCityID=c1.cityID and f.endCityID=c2.cityID and c1.cityName=' ' and c2.cityName=' ' and (startTime) like '2005-5-8%' mysql select * from flight where date_format(starttime,'%Y-%m-%d')='1998-01-02' 15. Drop table if not exists employees; create table employees(id int primary key auto_increment,name varchar(50) ,salary int,managerid int references employees(id)); insert into employees values (null,' lhm',10000,null), (null,' zxx',15000,1 ),(null,'flx',9000,1),(null,'tg',10000,2),(null,'wzg',10000,3); Wzg flx,lhm zxx sql select e.* from employees e,employees m where e.managerid=m.id and e.sala ry>m.salary; 16 45 12 3 teacher student tea_stu teacher teaID name age student stuID name age teacher_student teaID stuID sql 1. name, age 2 age 40 age 12 1.sql select,insert,delete,update 2. drop table if exists tea_stu; drop table if exists teacher; drop table if exists student; create table teacher(teaID int primary key,name varchar(50),age int); create table student(stuID int primary key,name varchar(50),age int); create table tea_stu(teaID int references teacher(teaID),stuID int references student(stuID)); insert into teacher values(1,'zxx',45), (2,'lhm',25) , (3,'wzg',26) , (4,'tg',27); insert into student values(1,'wy',11), (2,'dh',25) , (3,'ysq',26) , (4,'mxc',27); insert into tea_stu values(1,1), (1,2), (1,3); insert into tea_stu values(2,2), (2,3), (2,4); insert into tea_stu values(3,3), (3,4), (3,1); insert into tea_stu values(4,4), (4,1), (4,2) , (4,3); 23,3 2,4 3 1 select teaid,count(*) from tea_stu group by teaid; 2 12 student 12 select tea_stu.teaid,count(*) total from student,tea_stu where student.stuid=tea_stu.stuid and student.age>12 group by tea_stu.teaid 3. teacher 45 select teacher.teaid,teacher.name,total from teacher ,(select tea_stu.tea id,count(*) total from student,tea_stu where student.stuid=tea_stu.stuid and stu dent.age>12 group by tea_stu.teaid) as tea_stu2 where teacher.teaid=tea_stu2.tea id and teacher.age<45; 17. select authorid,count(*) total from articles group by authorid having total= (select max(total2) from (select count(*) total2 from articles group by authorid) as t); select t.authorid,max(t.total) from select authorid,count(*) total from articles as t max select authorid,count(*) total from articles group by authorid having total=max(total) 18 100 ? alter table drop column score; alter table add colunm score int; inert update delete DML create table,drop table ,alter table DDL update user set score=0; alter table user drop column score;alter table user add column score int Runnable runnable = new Runnable(){ public void run(){ clearDb(); schedule(this,new Date(new Date().getYear()+1,0,0)); } }; schedule(runnable, new Date(new Date().getYear()+1,0,1)); 19 select count(*) as num,tb.id from tb, (select role from tb where id=xxx) as t1 where tb.role = t1.role and tb.id != t1.id group by tb.id having num = select count(role) from tb where id=xxx; 20. xxx sql Table EMPLOYEES Structure: EMPLOYEE_ID NUMBER Primary Key, FIRST_NAME VARCHAR2(25), LAST_NAME VARCHAR2(25), Salary number(8,2), HiredDate DATE, Departmentid number(2) Table Departments Structure: Departmentid number(2) Primary Key, DepartmentName VARCHAR2(25). (2 EMPLOYEES [1000,2000] last_name ’Obama’ 4 select * from employees where Year(hiredDate) = Year(date()) or (salary between 1000 and 200) or left(last_name,3)='abc'; (3) EMPLOYEES 1800 4 mysql> select id,name,salary,deptid did from employee1 where (select avg(salary) from employee1 where deptid = did) > 1800; (4) EMPLOYEES 5 select employee1.*,(employee1.salary-t.avgSalary)*100/employee1.salary from employee1, (select deptid,avg(salary) avgSalary from employee1 group by deptid) as t where employee1.deptid = t.deptid and employee1.salary>t.avgSalary; 21 Jdbc 22 JDBC package com.huawei.interview.lym; import java.sql.CallableStatement; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Types; public class JdbcTest { /** * @param args */ public static void main(String[] args) { //TODO Auto-generated method stub Connection cn = null ; CallableStatement cstmt = null ; try { // Class. forName ("com.mysql.jdbc.Driver"); // DataSource // Datasource ds = context.lookup() //cn = ds.getConnection(); cn = DriverManager. getConnection ("jdbc:mysql:///test","root","root"); cstmt = cn.prepareCall("{call insert_Student(?,?,?)}"); cstmt.registerOutParameter(3,Types. INTEGER); cstmt.setString(1, "wangwu"); cstmt.setInt(2, 25); cstmt.execute(); //get System. out .println(cstmt.getString(3)); } catch (Exception e) { //TODO Auto-generated catch block e.printStackTrace(); } finally { /*try{cstmt.close();}catch(Exception e){} try{cn.close();}catch(Exception e){}*/ try { if (cstmt != null ) cstmt.close(); if (cn != null ) cn.close(); } catch (SQLException e) { //TODO Auto-generated catch block e.printStackTrace(); } } } 23 JDBC PreparedStatement Statement sql select * from student where id =3---- -- xxxxx select * from student where id =3---- -xxxxx select * from student where id =4--- - select * from student where id =?--- - sql 24. jdbc oracle 25 Class.forName ? ? Class ClassNotFoundException Class Class newInstance Class.forName spring ioc jdbc 26 sql sql sql sql sql server: String sql = "select top " + pageSize + " * from students where id not in" + "(select top " + pageSize * (pageNumber-1) + " id from students order by id)" + "order by id"; mysql: String sql = "select * from students order by id limit " + pageSize*(pageNumber-1) + "," + pageSize; oracle: String sql = "select * from " + (select *,rownum rid from (select * from students order by postime desc) where rid<=" + pagesize*pagenumber + ") as t" + "where t>" + pageSize*(pageNumber-1); 27 JDBC , . Connection cn = null; PreparedStatement pstmt =null; Resultset rs = null; try { Class.forname(driveClassName); cn = DriverManager.getConnection(url,username,password); pstmt = cn.prepareStatement(“select score.* from score ,student “ + “where score.stuId = student.id and student.name = ?”); pstmt.setString(1,studentName); Resultset rs = pstmt.executeQuery(); while(rs.next()) { system.out.println(rs.getInt(“subject”) + “ ” + rs.getFloat(“score”) ); } }catch(Exception e){e.printStackTrace();} finally { if(rs != null) try{ rs.close() }catch(exception e){} if(pstmt != null) try{pstmt.close()}catch(exception e){} if(cn != null) try{ cn.close() }catch(exception e){} } 28 ? t龄y { 热onne都t需on 都onn 次 尤尤尤植 脚t身te高ent st高t 次 尤尤尤植 耦esu首t脚et 龄s 次 st高t尤exe都ute缩ue龄y喻候se首e都t 堆 f龄o高 t身速首e张候在植 w队需首e喻龄s尤next喻在在 { } } 都身t都队喻独x都ept需on ex在 { } f需n身首首y f需n身首首y t龄y t龄y f需n身首首y 29 ? J2EE Connection Connection Connection close Connection 30 ORM? JDBC ? orm object objecdt jdbc oop jdbc orm orm jdbc orm jdbc orm hibernate orm toplink,ojb 六六六六. XML 部分部分部分部分 1xml ? ? : DOM,SAX,STAX DOM: DOM DOM , XML SAX: DOM,SAX XML XML XML XML STAX:Streaming API for XML (StAX) 2 xml ? ? : XML XML XML XML XML 3 jdom xml ? ? : , package test; import java.io.*; public class DOMTest { private String inFile = "c:\\people.xml" private String outFile = "c:\\people.xml" public static void main(String args[]) { new DOMTest(); } public DOMTest() { try { javax.xml.parsers.DocumentBuilder builder = javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuilder(); org.w3c.dom.Document doc = builder.newDocument(); org.w3c.dom.Element root = doc.createElement(" "); org.w3c.dom.Element wang = doc.createElement(" "); org.w3c.dom.Element liu = doc.createElement(" "); wang.appendChild(doc.createTextNode(" ")); root.appendChild(wang); doc.appendChild(root); javax.xml.transform.Transformer transformer = javax.xml.transform.TransformerFactory.newInstance().newTransformer(); transformer.setOutputProperty(javax.xml.transform.OutputKeys.ENCODING, "gb2312"); transformer.setOutputProperty(javax.xml.transform.OutputKeys.INDENT, "yes"); transformer.transform(new javax.xml.transform.dom.DOMSource(doc), new javax.xml.transform.stream.StreamResult(outFile)); } catch (Exception e) { System.out.println (e.getMessage()); } } } 4 JAVA XML . : SAX XML XML 6258113 ,1955 ,95 SAXHandler.java import java.io.*; import java.util.Hashtable; import org.xml.sax.*; public class SAXHandler extends HandlerBase { private Hashtable table = new Hashtable(); private String currentElement = null; private String currentValue = null; public void setTable(Hashtable table) { this.table = table; } public Hashtable getTable() { return table; } public void startElement(String tag, AttributeList attrs) throws SAXException { currentElement = tag; } public void characters(char[] ch, int start, int length) throws SAXException { currentValue = new String(ch, start, length); } public void endElement(String name) throws SAXException { if (currentElement.equals(name)) table.put(currentElement, currentValue); } } JSP ,SaxXml.jsp: XML people.xml <%@ page errorPage=ErrPage.jsp contentType=text/html;charset=GB2312 %> <%@ page import=java.io.* %> <%@ page import=java.util.Hashtable %> <%@ page import=org.w3c.dom.* %> <%@ page import=org.xml.sax.* %> <%@ page import=javax.xml.parsers.SAXParserFactory %> <%@ page import=javax.xml.parsers.SAXParser %> <%@ page import=SAXHandler %> <% File file = new File(c:\people.xml); FileReader reader = new FileReader(file); Parser parser; SAXParserFactory spf = SAXParserFactory.newInstance(); SAXParser sp = spf.newSAXParser(); SAXHandler handler = new SAXHandler(); sp.parse(new InputSource(reader), handler); Hashtable hashTable = handler.getTable(); out.println(); out.println( + ); out.println( + ); out.println( + ); out.println( + ); out.println(
+ (String)hashTable.get(new String(name)) +
+ (String)hashTable.get(new String(college))+
+ (String)hashTable.get(new String(telephone)) +
+ (String)hashTable.get(new String(notes)) +
); %> 5XML XML a: dtd schema b: :schema xml XML ( DTD schema )c: DOM,SAX,STAX DOM: DOM DOM , XML SAX: DOM,SAX XML XML XML XML STAX:Streaming API for XML (StAX) 七七七七. 流行的框架与新技术流行的框架与新技术流行的框架与新技术流行的框架与新技术 1 Struts : 1. struts MVC Web servlet Servlet ActionServlet ActionServlet web.xml Servlet Servlet /WEB-INF/struts-config.xml action struts 2. ActionServlet action formbean java formbean 3. ActionServlet formbean action execute formbean validate formbean action execute input input error 4.action ActionForward actionforward struts-config.xml jsp struts-config.xml jsp action jsp struts 2 Hibernate : 1. 2. Java java jdbc jdbc 3. java java ORM Object Relation Mapping JDBC ORM Hibernate ORM Hibernate JDBC save get 4. Hibernate Configuration SessionFactory session CRUD session 5. Hibernate hibernate.cfg.xml hbm.xml hibernate.cfg.xml hbm.xml 6. Hibernate Session hql 3AOP 4 Spring 1.Spring BeanFactory BeanFactory ApplicationContext Spring 2. Spring IOC IOC IOC DIDepency Injection Class Programmer { Computer computer = null; public void code() { //Computer computer = new IBMComputer(); //Computer computer = beanfacotry.getComputer(); computer.write(); } public void setComputer(Computer computer) { this.computer = computer; } } spring 3. Spring AOP AOP AOP AOP JDK Proxy CGLI B Advice Advice spring spring aop 5 Struts Action servlet 6Struts 1. MVC , . 2 tag ,Struts (Taglib) 3. 4. Exception . 5. 6. I18N forward jsp struts forward tomcate Struts Action thread safe action . Struts Action Web Web Junit Struts TestCase . Struts FormBean String Commons-Beanutils Class Servlet . Struts Action ServletRequest ServletResponse Servlet .Struts JSTL JSTL JSTL Collection Action . Struts Action Servlet Action . Struts Action class hierarchies action . struts Form Action ( DispatchAction) Struts struts application event application event component event 7STRUTS ( STRUTS ) Struts Java Servlet/JavaServer Pages Web framework Struts MVC(Model-View-Controller) Struts . controller servlet Action .JSP tag controller servlet .XML Java reflection APIs JavaBeans 8 struts1 struts2 1. MVC WEB , 2 struts1 struts2 3.struts2 struts1 struts1 struts2 4.struts1 Servlet ActionServlet struts2 filter struts2.0 FilterDispatcher struts2.1 StrutsPrepareAndExecuteFilter 5.struts1 action Action struts2 action struts1 Action struts2 Action struts2 Action 6. struts1 formbean struts2 action 7.struts1 Action DispatchAction struts2 Action ActionSupport validateXxx() Xxx() struts2 url package namespace struts2 struts2 boardid ognl el key Struts1Struts2Action Struts2Action struts redirect url struts2 redirect 9hibernate update() saveOrUpdate() session load() get() 10 Hibernate JDBC ? one to many . 11 iBatis Hibernate ? jdbc api jdbc api jdbc api sql java sql ibatis jdbc api sql java ; queryForList queryForObject sql Hibernate orm sql ,ibatis xml sql hibernate ibatis hibernate sql sql sql hibernate hibernate ibatis ibatis sql 12 Hibernate orm ? 9hibernate inverse ? Object[] bean bean field1,field2 Bean(type1 filed1,type2 field2) hql bean 13 DAO DAO ? Object[] bean bean field1,field2 Bean(type1 filed1,type2 field2) hql bean 14 spring+Hibernate ? Object[] bean bean field1,field2 Bean(type1 filed1,type2 field2) hql bean 15 spring+Hibernate ? Object[] bean bean field1,field2 Bean(type1 filed1,type2 field2) hql bean 16. hibernate Object[] bean bean field1,field2 Bean(type1 filed1,type2 field2) hql bean 17. Hibernate 12 hibernate Session 3 Hibernate 1 Hashmap hibernate Cache Dao { hashmap map = new map(); User getUser(integer id) { User user = map.get(id) if(user == null) { user = session.get(id); map.put(id,user); } return user; } } Dao { Cache cache = null setCache(Cache cache) { this.cache = cache } User getUser(int id) { if(cache!=null) { User user = cache.get(id); if(user ==null) { user = session.get(id); cache.put(id,user); } return user; } return session.get(id); } } 2Hibernate Session Hibernate session Session Session Session Session Session Hibernate Session Hibernate Hibernate session 3 Hibernate EHCache OSCache Hibernate hibernate.cfg.xml Hibernate Hibernate SessionFactory Hibernate SessionFactory 18 Spring ? Bean message , , "Hello" XML ? 19 Jdo ? JDO Java java data object , API JDO JDBC API JDO JDO JDBC RDBMS JDO XML ODBMS 20 spring IOC AOP 21 STRUTS 22 spring EJB 八八八八. 软件工程与设计模式软件工程与设计模式软件工程与设计模式软件工程与设计模式 1UML UML , ( ), , ( , ), 2j2ee 23 67 Java 23 Factory Builder Factory Method Prototype Singleton Facade Adapter Bridge Composite Decorator Flyweight Proxy Command Interpreter Visitor Iterator Mediator Memento Observer State Strategy Template Method Chain Of Responsibleity 3 ? ? MVC JSP/Servlet J2EE 九九九九. j2ee 部分部分部分部分 1BS CS C/S Client/Server PC Oracle Sybase InFORMix SQL Server B/ Brower/Server Browser Netscape Navigator Internet Explorer Oracle Sybase InFORMix SQL Server WWW eb Server C/S B/S : C/S , , . B/S , , , . . C/S , C/S , . C/S . B/S . B/S , , C/S , , . B/S , . C/S B/S , MS .Net BizTalk 2000 Exchange 2000 , . SUN IBM JavaBean , B/S . C/S , B/S . B/S , . . , C/S , , . . B/S , , . . . C/S , , , . B/S , , , C/S . . C/S Window , , B/S , . , . C/S , B/S , B-B B-C B-G , 2 WEB SERVER Weblogic Tomcat Jboss WEB SERVER IIS Apache 3 BEA WebLogic Server IBM WebSphere Application Server Oracle9i Application Server jBoss Tomcat 4J2EE :Je22 Sun (multi-diered), (distributed), (component-base) (enterpriese application model). (tier) (clietn tier) ,web ,Business , (EIS) j2ee 5J2EE J2EE J2EE J2EE JDBC JNDI RMI JMS EJB JTA 6 J2EE ( ) web JSP SERVLET JSP,SERVLET WEB TOMCAT,WEBLOGIC,WEBSPHERE J2EE WEB APPLICATION WEB J2EE WEB EJB Enterprise java bean EJB J2EE EJB JNDI Java Naming & Directory Interface JAVA JMS Java Message Service JAVA JTA Java Transaction API JAVA JAF Java Action FrameWork JAVA RMI/IIOP: Remote Method Invocation /internet RMI JAVA 7 weblogic ? Weblogic Domian startServerName set MEM_ARGS=-Xms32m -Xmx200m 32M 200M 8 weblogic ( ) ? commenv set PRODUCTION_MODE=true 9 ? WLS_USER WLS_PW boot.properties . 10 weblogic ( ,Domain) jms ejb , ? Domain config.xml 11 weblogic Domain ? helloWorld.jsp , http:// : //helloword.jsp ? javaBean ? Domain applications Web Web jsp Javabean WEB-INF classes 12 weblogic ejb EJB ejb-jar.xml,weblogic-ejb-jar.xmlCMP Bean weblogic-cmp-rdbms-jar.xml 13 weblogic ssl j2ee( ) ssl ? DemoIdentity.jks DemoTrust.jks KeyStore SSL Enable SSL CA identity trust keystore SSL 14 weblogic EJB? Deployment EJB 十十十十. EBJ 部分部分部分部分 1EJB SessionBean EntityBean StatefulBean StatelessBean EJB Session Bean Entity Bean Message Driven Bean JNDI RMI JAT SessionBean J2EE EJB EntityBean SessionBean EntityBean Session Bean Stateful Session Bean Stateless Session Bean Session Bean method Stateful Session Bean Stateful Session Bean Stateless Session Bean Stateless Session Bean EJB Container Stateless Session Bean method Stateless Session Bean methods Bean Instance Stateful Session Bean Stateless Session Bean Stateful Session Bean J2EE Server Stateful Session Bean 2 EJB 7 Transaction Level? 3EJB JAVABEAN Java Bean Java Bean Java Bean Java Bean Tomcat Java Bean Java Bean Serializable Bean Java Bean COM COM Enterprise Java Bean DCOM Java RMI EJB EJB Webspere WebLogic EJB EJB EJB EJB EJB EJB 4EJB SessionBean,EntityBean SessionBean Stateless Session Bean Bean EJB Bean Stateful Session Bean Bean Stateful Session Bean Bean EntityBean Entity Beans Entity beans EJB Entity beans Entity Beans Beans EJB OMG OTS Sun Microsystems Transaction ServiceJTS Java Transaction APIJTA X/Open XA 5EJB 6EJB Stateful Session Bean Cache Bean MRU NRU EJB EJB Object Bean Bean ejbActive ejbPassivate 7EJB Session Bean Entity Bean Message Driven Bean Bean Stateful Stateless Bean Bean BMP CMP 8 EJB JNDI JNDI Home Home Create Remote Remote 十一十一十一十一 . webservice 部分部分部分部分 1WEB SERVICE JSWDL JAXP JAXM SOAP UDDI,WSDL Web ServiceWeb Service Web Service JAXP(Java API for XML Parsing) Java DOM, SAX, XSLT JAXM(Java API for XML Messaging) SOAP API WSDL XML SOAP (Simple Object Access Protocol) XML UDDI UDDI Web Web Service Web Service 2CORBA ? ? CORBA (Common Object Request Broker Architecture) (Object Management Group OMG) (IDL), (binding: ) 3. Linux 4LINUX GDI LINUX " " GDI 5. 问得稀里糊涂的题问得稀里糊涂的题问得稀里糊涂的题问得稀里糊涂的题 6 ServletsJSP page Java servlet include include servlet servlet JSP request Web Web forward include session Web Web application Web Web 7 (&,|,^) (&&,||) a. , , b. 十二十二十二十二 . 其他其他其他其他 1 . 4WEB SERVICE JSWDL JAXP JAXM SOAP UDDI,WSDL 2 http://tomcat.apache.org/ ? 演p身都队e 航o高都身t 需s t队e se龄v首et 都ont身需ne龄 t队身t 需s use金 需n t队e off需都需身首 耦efe龄en都e 真高p首e高ent身t需on fo龄 t队e 研身v身 脚e龄v首et 身n金 研身v身脚e龄ve龄 累身错es te都队no首o错需es尤 航队e 研身v身 脚e龄v首et 身n金 研身v身脚e龄ve龄 累身错es spe都需f需都身t需ons 身龄e 金eve首ope金 速y 脚un un金e龄 t队e 研身v身 热o高高un需ty 累龄o都ess 尤 演p身都队e 航o高都身t 需s 金eve首ope金 需n 身n open 身n金 p身龄t需都需p身to龄y env需龄on高ent 身n金 龄e首e身se金 un金e龄 t队e 演p身都队e 脚oftw身龄e 稍需都ense 尤 演p身都队e 航o高都身t 需s 需nten金e金 to 速e 身 都o首首身速o龄身t需on of t队e 速est-of-速龄ee金 金eve首ope龄s f龄o高 身龄oun金 t队e wo龄首金尤 著e 需nv需te you to p身龄t需都需p身te 需n t队需s open 金eve首op高ent p龄o面e都t尤 航o 首e身龄n 高o龄e 身速out 错ett需n错 需nvo首ve金姓 都首需都餐 队e龄e 尤 演p身都队e 航o高都身t powe龄s nu高e龄ous 首身龄错e-s都身首e姓 高需ss需on-都龄需t需都身首 we速 身pp首需都身t需ons 身都龄oss 身 金需ve龄se 龄身n错e of 需n金ust龄需es 身n金 o龄错身n需z身t需ons尤 脚o高e of t队ese use龄s 身n金 t队e需龄 sto龄需es 身龄e 首需ste金 on t队e 累owe龄e金激y w需餐需 p身错e尤 3 JAVA 张尤 航身首餐 身速out ove龄龄需金需n错姓 ove龄首o身金需n错尤 怪尤 航身首餐 身速out 研演萨演 金es需错n p身tte龄ns you 餐nown尤 感尤 航身首餐 身速out t队e 金需ffe龄en都e 速etween 稍需n餐稍需st姓 演龄龄身y稍需st 身n金 萨需都to龄尤 截尤 航身首餐 身速out t队e 金需ffe龄en都e 速etween 身n 演速st龄身都t 都首身ss 身n金 身n 真nte龄f身都e尤 挥尤 热首身ss 身 次 new 热首身ss喻在植 热首身ss 速 次 new 热首身ss喻在植 需f喻身 次次 速在 龄etu龄ns t龄ue o龄 f身首se姓 w队y洋 搞尤 著队y we use 脚t龄需n错激uffe龄 w队en 都on都身ten身t需n错 st龄需n错s洋 操尤 航龄y to exp首身需n 脚需n错首eton to us洋 真s 需t t队龄e身金 s身fe洋 真f no姓 队ow to 高身餐e 需t t队龄e身金 s身fe洋 映尤 航龄y to exp首身需n 真o都洋 未尤 疼ow to set 高身ny-to-高身ny 龄e首身t需ons队需p 需n 疼需速e龄n身te洋 张带尤 航身首餐 身速out t队e 金需ffe龄en都e 速etween 真管管独耦 研紧真管 身n金 稍琐独航 研紧真管尤 张张尤 著队y we use 需n金ex 需n 金身t身速身se洋 疼ow 高身ny 需n金exes 需s t队e 高身x需高u高 需n one t身速首e 身s you龄 su错错est需on洋 张怪尤 著队en ‘琐需n身首’ 需s use金 需n 都首身ss姓 高et队o金 身n金 p龄ope龄ty姓 w队身t 金ose 需t 高e身n洋 张感尤 熟o you 队身ve 身ny expe龄需en都e on 藏符稍洋 航身首餐 身速out 身ny 藏符稍 too首 you use金 姓e尤错尤 研演藏激姓 研演藏用尤 张截尤 熟o you 队身ve 身ny expe龄需en都e on 稍需nux洋 张挥尤 真n 紧紧熟 w队身t 需s t队e 龄e身son w队en you 都龄e身te 身 脚e默uen都e 金需身错龄身高洋 演金高需n需st龄身to龄 张带校感截校怪带 张搞截餐 怪 感张带带 截n 装]装]装] 最后希望大家都能找到满意的工作最后希望大家都能找到满意的工作最后希望大家都能找到满意的工作最后希望大家都能找到满意的工作!
还剩135页未读

继续阅读

下载pdf到电脑,查找使用更方便

pdf的实际排版效果,会与网站的显示效果略有不同!!

需要 10 金币 [ 分享pdf获得金币 ] 1 人已下载

下载pdf

pdf贡献者

ccp9999

贡献于2018-08-23

下载需要 10 金币 [金币充值 ]
亲,您也可以通过 分享原创pdf 来获得金币奖励!
下载pdf