2006年01月27日

今年春节终于可以安安心心地过年了,祝所有"牛们"迎来收获的一年,快乐的一年!

春节期间[1-28 ~ 2-4],俺的blog将停止更新,感谢各位朋友捧场!

2006年01月26日

由于软件下载中的一篇文章出现连续英文安符太长,撑坏了版面.见下图!


图一


图二

以下资料皆收集自网上的零碎介绍,如有出入,烦劳告知!

目前我所了解到的 java认证有四种,分别是:
1,SCJP: Sun Certified Java Programmer
2,SCJD: Sun Certified Java Developer
3,SCWCD: Sun Certified Web Component Developer
4,SCEA: Sun Certified Enterprise Architect

1,  java程序员的认证Sun Certified JAVA Programmer(SCJP)

    课程:SL-275 JAVA语言编程

    本课程使学员掌握如何使用标准JAVA Development Kit,V1.1 (JDK) 开发应用程序和applets。在本课程中您将学会JAVA 语言的语法。 如何使用JAVA 来创建图形用户接口 (GUI), 事件处理机制, 例外处理, 通过设计与开发各种JAVA 程序来获得实际的编程经验. 您也将学到文件输入/输出(I/O)、 多线程和网络的知识.。本课程适用于熟悉C或C++的编程人员, 也适用于想参加Sun JAVA 认证考试的学员。

    预备知识:学习本课程之前必须具备以下能力

    能够编译C 或C++ 程序或者已经参加过SL-110课程;能够创建和编译简单的程序;使用 WWW(World wide web) 浏览器, 如: Netscape;能够使用vi或者OpenWindows的文件编辑器;使用基本UNIX的命令。

    课程学习完成后,将具备以下能力:

    使用JAVA 编程语言创建JAVA 应用程序和applets
    定义和描述垃圾搜集, 安全性和JAVA 虚拟机(JVM)
    描述和使用 JAVA 语言面向对象的特点
    开发图形用户接口 (GUI),利用JAVA支持的多种布局管理
    描述和使用 JAVA 1.1 的事件处理模式
    使用JAVA 语言的鼠标输入, 文本, 窗口和菜单窗
    使用JAVA的例外处理来控制程序执行和定义用户自己的例外事件
    使用JAVA 语言的先进的面向对象特点, 包括方法重载, 方法覆盖, 抽象类, 接口等等实现文件的输入/输出(I/O)
    使用JAVA 语言内在的线程模式来控制多线程
    使用JAVA的Sockets 机制进行网络通信

    参加Java程序员认证考试

    java程序员认证考试考试号为310-025。Java程序员的认证考试以Sun公司的SL-275英文原版教材为标准,需要掌握并作为考试内容的知识点有:声明和权限控制,流控制和异常处理,垃圾回收机制,基本语法,操作数和符号,重载、覆盖、运行类型和面向对象,线程等;此外,还有java.awt、java.lang、java.util、java.io包中的常用类等。 javaSL-275的考试共有试题59道,通过分数为61分(答对36道题即可)。时间为120分钟,在提交试卷前的任何时候,都可以看到任意一道试题。题型分为单选和多选题(可根据单选框或多选框来判断),多选题在题目中将指明该题有几个正确答案。

    参加考试需要提前2天到考试中心注册考生ID,并和考试中心的工作人员预约考试时间。考生必须按时参加考试,并携带本人身份证。考试结束即可看到考试结果。Sun公司颁发的证书将在考试之后的2个月内以信件方式发到考生注册的地址处。

2,  java开发员认证Sun Certified JAVA Deverloper(SCJD)

    java开发员的认证考试以Sun指定的javaSL-285为教材,机考部分的考试号为310-027。

    Java开发员认证课程:

    课程的具体内容有:解释软件开发周期每阶段的目标,可使用适当的java程序类型,了解API设计的基本元素,根据项目中的功能要求确定程序组件;描述关系数据库的设计及其设计原则;了解JDBC、ODBC及其使用;创建良好的GUI设计原则设计自己的用户界面;使用Socket连接以适当格式传输数据,创建一个多层java小程序或应用程序;了解在Solaris和Windows平台之间的移植问题。

    Java开发员的认证考试:

    Java开发员的考试分程序设计和机考两部分。其中,程序设计部分不限时。考生报名后,可从指定的网址下载考试题目,并根据题目要求进行程序设计。在指定的时间段(1年)内,考生须传回自行设计的java程序。但通常情况下,考生都会在2至3个月内将程序传回。机考部分将针对程序回答题目,只要真正领悟和掌握了设计程序的过程和内容,回答这部分考题就没有问题了。开发员的认证考试是对一个java开发人员综合能力的一种考核,通过该课程的学习将培养一个程序设计人员的独立编程的能力,而该证书的取得也是对这种能力的一个有力证明。

3,  SCWCD

Sun Certified Web Component Developer (SCWCD) 是 J2EE 领域最令人羡慕的证书之一。如果您想要获得 SCWCD 证书,需要知道不仅仅要学习 servlet 和 JSP 技术,还要深入了解考试目标中指定的主题。甚至对于有经验的程序员,在考试中的表现欠佳也是很正常的,因为他们可能没有精通目标所覆盖的内容。要想成功通过考试,遵循某种学习方法是很重要的,而该方法是在考试目标的指导下进行的。


4,SCEA

Sun Certified Enterprise Architect(SCEA)考试针对的是用 Java 2 Platform, Enterprise Edition(J2EE)技术、以健壮的、可伸缩的、安全的和灵活的方式来设计和构建企业解决方案的专业人员。本考试是有关 J2EE 的认证的最高一级。尽管从逻辑上说,这门考试是在程序员和开发员考试之后,但是参加这门考试没有什么先决条件。设计 J2EE 解决方案的实际经验会帮助您顺利通过第一次考试。本考试由三部分组成,一部分是基础知识多选测试,一部分是任务指派,而最后一部分是评论和解释。

2006年01月24日

//: c09:CatsAndDogs.java
//Simple container example.
//Create a Cats container and test it.
import java.util.*;

class Cats{
 private ArrayList cats = new ArrayList();
 public void add(Cat cat){
  cats.add(cat);
 }
 public Cat get(int index){
  return (Cat)cats.get(index);
 }
 public int size(){
  return cats.size();
 }
}

public class CatsandDogs{
 public static void main(String[] args){
  Cats cats = new Cats();
  for(int i=0;i<10;i++)
   cats.add(new Cat(i));
  //add(Cat) in Cats cannot be applied to (Dog)
  //cats.add(new Dog(10));
  for(int i=0; i < cats.size();i++)
   cats.get(i).print();
 }
}

2006年01月23日

//: chapter 9 practice 7 : the problem of using inheritance
// instead of composition in MouseList
import java.util.*;

public class MouseList extends ArrayList{
 private ArrayList list1 = new ArrayList();
 public void add(Mouse m){
  list1.add(m);
 }
 //if you use inheritance, you cannot use the method below:
 //get(int) in MouseList cannot override get(int) in java.util.
 //AbstractList; attempting to use incompatible return type
 //you can use Object return type or other method name, or
 //use other arguments type.
 //but, that don’t meet out required.
 public Mouse get(int index){
  return (Mouse)list1.get(index);
 }
 public int size(){ return list1.size(); }
}

// chapter 9 practice 6
class Cat{
 private int catNumber;
 Cat(int x){
  catNumber = x;
 }
 public void cry(){
  System.out.println("cat #" + catNumber + " is cry:miao~~");
 }
}

class Mouse {
 private int mouseNumber;
 Mouse(int x){
  mouseNumber = x;
 }
 public void cry(){
  System.out.println("mouse #" + mouseNumber + "is cry:zhizhi~~");
 }
}

public class P6{
 public static void main(String[] args){
  MouseList ml = new MouseList();
  for(int i=0;i<5;i++)
   ml.add(new Mouse(i));
  //add(Mouse) in MouseList cannot be applied to (Cat)
  //because there is no method overload within MouseList
  //ml.add(new Cat(1));
 }
}

//chapter 9 practice 5: test ArrayList and LinkedList.
import java.util.*;
import com.bruceeckel.util.*;

public class P5{
 static void testList(List list1){
  Collections2.fill(list1,Collections2.countries,10);
  Collections.sort(list1);
  System.out.println(list1);
  Collections.shuffle(list1);
  System.out.println(list1);
  Collections.shuffle(list1);
  System.out.println(list1);
 }
 public static void main(String[] args){
  ArrayList al = new ArrayList();
  LinkedList ll = new LinkedList();
  testList(al);
  testList(ll);
 }
}

//: chapter 9 practice 4 : fill a map with Gerbil
// tip: I use the Pair class out of com.bruceeckel.util,
// so we need to change the Pair constuctor to be public.
import java.util.*;
import com.bruceeckel.util.*;

class Gerbil{
 private int gerbilNumber;
 Gerbil(int x){
  gerbilNumber = x;
 }
 public void hop(){
  System.out.println("Gerbil #" + gerbilNumber + " is hopping");
 }
 //to be the name of the object
 public String name(){
  return "Gerbil #" + gerbilNumber;
 }
 //to be print
 public String toString(){
  return "Gerbil #" + gerbilNumber + "reference";
 }
}

class GerbilGenerator implements MapGenerator{
 private Arrays2.RandIntGenerator gen;
 private Gerbil gerbil;
 public GerbilGenerator(int mod){
  gen = new Arrays2.RandIntGenerator(mod);
 }
 public Pair next(){
  gerbil = new Gerbil(gen.next());
  return new Pair(gerbil.name(),gerbil);
 }
}

public class P4{
 public static void main(String[] args){
  HashMap hm = new HashMap();
  // default Gerbil Ubound number
  int mod=100;
  // user give the Ubound number
  if (args.length != 0)
   mod = Integer.parseInt(args[0]);
  Collections2.fill(hm,new GerbilGenerator(mod),10);
  Iterator it = hm.keySet().iterator();
  while(it.hasNext()){
   Object gkey = it.next();
   System.out.println(gkey);
   ((Gerbil)hm.get(gkey)).hop();
  }
 }
}

2006年01月21日

原创作品,转载请注明出处。

<SCRIPT LANGUAGE = "VBSCRIPT" RUNAT="SERVER">
‘===============================================================
‘简明网站访问统计程序
‘Author: 不见不散
‘Version: 1.1
‘撰写时间: 2006-1-21
‘===============================================================
 Sub Application_OnStart
  ’==============
  ’在线人数
  ’==============
  Application("online") = 0
  ’==============
  ’连接数据库
  ’==============
  Application("str_conn") = "Provider = Microsoft.jet.oledb.4.0;data source = " & Server.MapPath("database\spider.mdb")
  Dim conn
  Set conn = Server.CreateObject("Adodb.Connection")
  conn.open Application("str_conn")
  ’==============
  ’获取数据
  ’==============
  Dim rs,sql,TimeNow
  Set rs = Server.CreateObject("Adodb.RecordSet")
  sql = "Select * from stat"
  TimeNow = now()
  rs.open sql,conn,1,3
  ’同一天的Application重启;  
  If Day(rs("today")) = Day(TimeNow) Then
   Application("now") = rs("today")
   ’总访问记录
   Application("total") = rs("totalCount")
   ’今天访问数
   Application("today") = rs("todayCount")
   ’昨天访问数
   Application("yestoday") = rs("yestodayCount")
  ’不同天的Application重启;
  Else
   ’更新时间
   rs("today") = TimeNow
   ’重获时间
   Application("now") = TimeNow
   ’总访问记录
   Application("total") = rs("totalCount")
   ’今天记录设为1
   Application("today") = 1
   ’昨天记录
   Application("yestoday") = rs("todayCount")
  End If
   rs.Update
  ’=============
  ’清理
  ’=============
  rs.Close
  Set rs = Nothing
  conn.Close
  Set conn = Nothing
 End Sub
‘================================================================ 
 Sub Application_OnEnd
  ’================
  ’连接数据库
  ’================
  Dim conn
  Set conn = Server.CreateObject("Adodb.Connection")
  conn.open Application("str_conn")
  ’================
  ’获取数据
  ’================
  Dim rs,sql,TimeNow
  sql = "Select * From stat Order by id"
  TimeNow = now()
  Set rs = Server.CreateObject("Adodb.RecordSet")
  rs.Open sql,conn,1,3
  
  rs("totalCount") = Application("total")
  rs("yestodayCount") = Application("yestoday")
  rs("todayCount") = Application("today")
  rs("today") = TimeNow
  rs.Update
  ’===============
  ’清理
  ’===============
  rs.close
  Set rs = Nothing
  conn.Close
  Set conn = Nothing
 End Sub
‘================================================================ 
 Sub Session_OnStart
  ’===========
  ’是否换天
  ’===========
  If Day(Application("now")) <> Day(now()) Then
   Application("now") = now()
   Application("yestoday") = Application("today")
   Application("today") = 1
  End If
  
  ’在线计数
  Application.Lock()
  Application("online") = Application("online") + 1
  
  ’访问计数
  Application("total") = Application("total") + 1
  Application("today") = Application("today") + 1
  Application.UnLock()
 End Sub
‘================================================================ 
 Sub Session_OnEnd
  If Day(Application("now")) <> Day(now()) Then
   Application("now") = now()
   Application("yestoday") = Application("today")
   Application("today") = 0
  End If

  Dim StartTime
   StartTime = (Timer/60) mod 30
  If StartTime > 25 Then
   Call randRun
  End If
  
  Application.Lock()
  Application("online") = Application("online") – 1
  Application.UnLock()
 End Sub
‘================================================================
 Sub randRun
  ’=============================
  ’随机储存,减少丢失数据机率。
  ’=============================
  Dim StartTime,TimeNow
   StartTime = (Timer/60) mod 60
   TimeNow = now()
  Dim rs,sql,conn
   Set conn = Server.CreateObject("Adodb.Connection")
   conn.open Application("str_conn")
   Set rs = Server.CreateObject("Adodb.RecordSet")
   sql = "select * from stat order by id"
   rs.Open sql,conn,1,3
   rs("totalCount") = Application("total")
   rs("todayCount") = Application("today")
   rs("yestodayCount") = Application("yestoday")
   rs("today") = TimeNow
   rs.Update
   rs.Close
   Set rs = Nothing 
 End Sub
</SCRIPT>

2006年01月20日

//: c9:p3
// Practice using ArrayList : using iterator().

import java.util.*;

class Gerbil {
 private int gerbilNumber;
 Gerbil(int x) {
  gerbilNumber = x;
 }
 void hop() {
  System.out.println("# gerbil " + gerbilNumber + " is hopping");
 }
}
public class P3 {
 private static int t;
 public static void main(String[] args) {
  if(args.length != 0)
   t = Integer.parseInt(args[0]);
  else
   t = 10;
  ArrayList al = new ArrayList();
  for(int i = 1; i < t; i++)
   al.add(new Gerbil(i));
  Iterator it = al.iterator();
  while(it.hasNext())
   ((Gerbil)it.next()).hop();
 }
}