J2EE @ zxw
Learning in
J2EE
2008 年 1 月 7 日
1
J2EE @ zxw
内容目录
ORALCE..............................................................................................................................................4
一、选择行.....................................................................................................................................................................5
二、限制选择行.............................................................................................................................................................5
三、单行函数.................................................................................................................................................................6
四、从多个表里选取数据记录.....................................................................................................................................8
五、集合函数 ...............................................................................................................................................................9
六、子查询...................................................................................................................................................................10
七、在执行 SQL 语句时绑定变量.............................................................................................................................11
八、概述数据模型和数据库设计...............................................................................................................................12
九、创建表...................................................................................................................................................................14
十、ORACLE 里的数据字典......................................................................................................................................16
十一. 控制数据.............................................................................................................................................................17
十二、改变表和约束条件 .........................................................................................................................................19
十三、创建序列号.......................................................................................................................................................20
十四、创建视图...........................................................................................................................................................21
十五、创建索引...........................................................................................................................................................22
十六、控制用户访问...................................................................................................................................................23
补充:...........................................................................................................................................................................25
JDBC..................................................................................................................................................27
一、概要.......................................................................................................................................................................27
二、如何使用 JDBC....................................................................................................................................................28
三、JDBC 中的异常....................................................................................................................................................31
四、JDBC 中的事务....................................................................................................................................................31
五、JDBC2.0 新特性...................................................................................................................................................33
六、JDBC 对标准的扩展(JNDI):1.0 中所没有的东西哦!...................................................................................34
七、OOAD and Database Design................................................................................................................................35
Hibernate3.0.......................................................................................................................................39
一、Hibernate 的简介..................................................................................................................................................39
二、Hibernate 的工作原理..........................................................................................................................................40
三、关联关系映射.......................................................................................................................................................44
四、操作持久化对象...................................................................................................................................................46
五、事务,并发..............................................................................................................................................................49
六、高级映射概念(映射关系)...............................................................................................................................51
映射总结(图):............................................................................................................................................................57
七、高级查询...............................................................................................................................................................59
Java Servlets.......................................................................................................................................63
一、tomcat 和 servlet 介绍...........................................................................................................................................63
二、servlet 的生命周期...............................................................................................................................................66
三、资源跳转的方式...................................................................................................................................................67
四、在 tomcat 中配置数据源......................................................................................................................................69
五、持久化状态:Cookie,Session.................................................................................................................................70
复习:...........................................................................................................................................................................71
2
J2EE @ zxw
六、request、session、application..............................................................................................................................72
七、Filter:过滤器.........................................................................................................................................................72
八、监听器...................................................................................................................................................................73
JSP:Java Server Page..........................................................................................................................75
一、jsp 的工作原理:<比 serlvet 多了翻译阶段>.......................................................................................................76
二、jsp 中的元素.........................................................................................................................................................77
三、jsp 注释.................................................................................................................................................................78
四、page 属性:<%@ page attribute="value"....%>.....................................................................................................78
五、可重用的组件(javabean)......................................................................................................................................79
JSP 收集........................................................................................................................................................................82
六、自定义标签...........................................................................................................................................................84
七、EL(表达式语言)...................................................................................................................................................85
八、JSTL:Java Server Page Tag Libraries...................................................................................................................89
九、国际化标签:I18N(配置相应的语言信息)...........................................................................................................91
十、异常处理...............................................................................................................................................................93
Struts...................................................................................................................................................94
一、Struts 介绍(优缺点、控制层分类、工作流程)..................................................................................................94
二、Struts 标签库的使用............................................................................................................................................98
三、国际化 I18N........................................................................................................................................................100
四、异常处理.............................................................................................................................................................101
五、高级特性部分.....................................................................................................................................................102
六、Struts 的 validator 验证框架...............................................................................................................................104
JSF:Java Server Faces...................................................................................................................106
一、JSF 介绍..............................................................................................................................................................106
二、JSF 页面导航......................................................................................................................................................107
三、JSF 简单工作流程及简单开发步骤..................................................................................................................108
四、ManagedBean.....................................................................................................................................................109
五、JSP2.0 EL 和 JSF EL 的比较.............................................................................................................................111
六、国际化.................................................................................................................................................................112
七、事件处理:在 JSF 中有四种类型的事件............................................................................................................112
AJAX:Asynchronous(异步) JavaScript And Xml...........................................................................115
JavaScript.........................................................................................................................................122
一、概述.....................................................................................................................................................................122
二、基础语法.............................................................................................................................................................123
三、常用内置对象.....................................................................................................................................................124
四、常用 DHTML 对象.............................................................................................................................................124
EJB...................................................................................................................................................128
一、EJB 介绍.............................................................................................................................................................128
二、配置 weblogic、weblogic 与 jbuilder 集成........................................................................................................128
三、使用 EJB 的目的、包含的元素和开发 EJB 的过程........................................................................................129
四、weblogic 配置数据源.........................................................................................................................................133
五、SessionBean 介绍...............................................................................................................................................134
六、hibernate+session bean 开发...............................................................................................................................136
3
J2EE @ zxw
七、JMS 介绍............................................................................................................................................................136
八、Message-Driven Beans 介绍...............................................................................................................................137
补充:.........................................................................................................................................................................139
EJB3.0..............................................................................................................................................143
一、EJB2.0 和 EJB3.0 的区别...................................................................................................................................143
二、在 EJB3.0 中开发 SessionBean、MessageDriven-Bean...................................................................................144
三、JPA(数据库持久化标准)...................................................................................................................................145
四、hibernate 和 entity 中对象状态转换的区别......................................................................................................148
五、JPA 的使用.........................................................................................................................................................148
六、JPA 中的关系映射.............................................................................................................................................151
七、EJB-QL 增强语句..............................................................................................................................................153
八、事务.....................................................................................................................................................................154
Spring...............................................................................................................................................156
一、概述.....................................................................................................................................................................156
二、IOC(控制反转)...................................................................................................................................................157
三、AOP(面向方面的程序设计)..............................................................................................................................162
四、Spring 中的 Data Access....................................................................................................................................164
五、事务.....................................................................................................................................................................166
六、Spring 中的 Web.................................................................................................................................................167
OOAD&UML...................................................................................................................................170
一、OOA&OOD.......................................................................................................................................................170
二、UML....................................................................................................................................................................171
三、原则.....................................................................................................................................................................175
四、模式.....................................................................................................................................................................177
补充:.........................................................................................................................................................................179
CVS..................................................................................................................................................182
PL/SQL.............................................................................................................................................185
一、介绍.....................................................................................................................................................................185
二、匿名语句块.........................................................................................................................................................185
三、record 对象.........................................................................................................................................................187
五、分支结构.............................................................................................................................................................188
六、循环结构.............................................................................................................................................................189
七、游标.....................................................................................................................................................................189
八、异常块.................................................................................................................................................................191
九、procedure 存储过程............................................................................................................................................193
十、function 函数......................................................................................................................................................195
十一、package 包.......................................................................................................................................................196
十二、trigger 触发器.................................................................................................................................................198
JavaScript&&AJAX 代码集萃........................................................................................................201
4
J2EE @ zxw
ORALCE
-------------------------------------------------------------------------------------------------------
一、选择行
1. 简单的 SELECT 语句
SELECT 字段名 1 [AS] '字段名 1 解释' FROM table;
2. 处理 NULL
NVL 函数可把 NULL 转换成其它类型的符号
编程技巧: NVL 函数在多条件模糊查询的时候比较有用
NVL 函数可返回多种数据类型:
返回日期 NVL(start_date,'2002-02-01')
返回字符串 NVL(title,'no title')
返回数字 NVL(salary,1000)
3. 使用 SQL*PLUS(1)
SQL> desc table; 显示表结构
SQL> select * from tab; 查看用户下所有的表
SQL> set pause on; 可以使大量结果集在用户按“Enter”(回车)后翻页
SQL> set pagesize 100; 设定 SQL 语句返回结果集一页的行数 100, 默认值是 14
SQL> set linesize 100; 设定 SQL 语句返回结果集一行的宽度 100, 默认值是 80
4. SQL*PLUS 里规定字段的显示格式
规定数字的显示格式
SQL>column 字段名 format 99999999999;
SQL>column 字段名 format 999,999,999,999;
SQL>column 字段名 format a 数字 [word_wrapped];
规定 long 字符的显示宽度
SQL>set long 200;
规定字段名的显示内容
SQL> column 字段名 heading '字段名显示内容';
SQL> set heading off; 查询时不显示字段名称
规定字段的对齐方向
SQL> column 字段名 justify [left | right | center];
清除字段的格式
SQL> column 字段名 clear;
5. SQL*PLUS 里规定字段的显示格式例子
SQL> column last_name heading 'Employee|Name' format a15;
SQL> column salary justify right format $99,999.99;
SQL> column start_date format a10 null 'Not Hired';
说明:如果 start_date 为 null, 显示字符串'Not Hired'
6. 判断题(T/F)
(1). SQL command are always held in sql buffer. [T]
(2). SQL*PLUS command assit with query data. [T]
5