丄諦啲仇魜ヤ
如 果 敌 人 让 你 生 气 , 那 说 明 你 没 有 胜 他 的 把 握!
posts - 6,comments - 56,trackbacks - 1

我的评论

re: EXT2.0 做的登陆界面 Crying 2009-01-06 10:32  
@waiting_over
不好意思 在自己的编译环境中 是取的login2.js 这个名字
发帖时 自己 在贴 login2.js 里的内容 时 直接取了个名字叫login.js了
re: Java中对日期的常用处理 Crying 2008-11-05 11:31  
package com.ants.env.util;


import java.sql.Timestamp;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.ants.env.finance.implement.ChPlKindImp;

// Referenced classes of package com.ants.util:
// StringUtil

public class DateUtil
{

public DateUtil()
{
}

public static Date convertStrToDate(String s)
{
return convertStrToDate(s, "yyyy-MM-dd");
}

public static Date convertStrToDate(String s, String pattern)
{
try
{
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
return sdf.parse(s);
}
catch(ParseException pe)
{
pe.printStackTrace();
}
return null;
}

public static Timestamp convertStrToTimestamp(String s, String pattern)
{
try
{
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
return new Timestamp(sdf.parse(s).getTime());
}
catch(ParseException pe)
{
pe.printStackTrace();
}
return null;
}

public static java.sql.Date convertStrToSQLDate(String s)
{
if(StringUtil.removeNull(s).equals(""))
return null;
else
return new java.sql.Date(convertStrToDate(s).getTime());
}

public static java.sql.Date convertStrToSQLDate()
{
return new java.sql.Date((new Date()).getTime());
}

public static java.sql.Date convertStrToSQLDate(Date date)
{
return new java.sql.Date(date.getTime());
}

public static Timestamp convertStrToTimestamp(String s)
{
if(StringUtil.removeNull(s).equals(s))
return null;
else
return new Timestamp(convertStrToDate(s).getTime());
}

public static Timestamp convertStrToTimestamp(Date d)
{
if(d == null)
return null;
else
return new Timestamp(d.getTime());
}

public static String getDateString()
{
Calendar c = Calendar.getInstance();
Date d = c.getTime();
return getDateString(d, "yyyy-MM-dd");
}

public static String getDateString(Date d)
{
return getDateString(d, "yyyy-MM-dd");
}

public static String getGeneralDateString(Date d)
{
return getDateString(d, "yyyy-MM-dd HH:mm:ss");
}

public static String getDateString(Date d, String pattern)
{
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
return sdf.format(d);
}

public static boolean equals(Date d)
{
return equals(d, new Date());
}

public static boolean equals(Date d1, Date d2)
{
return getDateString(d1).equals(getDateString(d2));
}

public static java.sql.Date getSQLDate(int year, int month, int date, int hour, int minute, int second)
{
_logger.info("getSQLDate:" + getDate(year, month, date, hour, minute, second).getTime());
java.sql.Date d = new java.sql.Date(getDate(year, month, date, hour, minute, second).getTime());
_logger.info("second:" + String.valueOf(getSecond(d)));
return new java.sql.Date(getDate(year, month, date, hour, minute, second).getTime());
}

public static Date getDate(int year, int month, int date, int hour, int minute, int second)
{
Calendar c = Calendar.getInstance();
c.set(year, month, date, hour, minute, second);
_logger.info("Calendar :" + c.getTime());
return c.getTime();
}

public static int getYear(Date d)
{
Calendar c = Calendar.getInstance();
c.setTime(d);
return c.get(1);
}

public static int getMonth(Date d)
{
Calendar c = Calendar.getInstance();
c.setTime(d);
return c.get(2) + 1;
}

public static int getDay(Date d)
{
Calendar c = Calendar.getInstance();
c.setTime(d);
return c.get(5);
}

public static int getHour(Date d)
{
Calendar c = Calendar.getInstance();
c.setTime(d);
return c.get(11);
}

public static int getMinute(Date d)
{
Calendar c = Calendar.getInstance();
c.setTime(d);
return c.get(12);
}

public static int getSecond(Date d)
{
Calendar c = Calendar.getInstance();
c.setTime(d);
return c.get(13);
}

public static Timestamp convertDateToTimestamp(Date d)
{
return new Timestamp(d.getTime());
}

public static java.sql.Date getNextMonStartDate(String year, String month)
{
int yearInt = Integer.parseInt(year);
int monthInt = Integer.parseInt(month);
if(monthInt == 12)
return convertStrToSQLDate(Integer.toString(yearInt + 1) + "-1-1");
else
return convertStrToSQLDate(year + "-" + Integer.toString(monthInt + 1) + "-1");
}

public static java.sql.Date getMonStartDate(String year, String month)
{
return convertStrToSQLDate(year + "-" + month + "-1");
}

public static java.sql.Date getYearStartDate(String year)
{
return convertStrToSQLDate(year + "-1-1");
}

public static Date getDateAddHour(Date date, int hour)
{
long l = date.getTime();
long n = l + (long)(hour * 60 * 60 * 1000);
Date dateAddHour = new Date(n);
return dateAddHour;
}

public static Date getNextDate(Date date)
{
return getDateAddHour(date, 24);
}

public static Date getSecondDate(Date date)
{
return getDateAddHour(date, 48);
}

public static Date getPreviousDate(Date date)
{
return getDateAddHour(date, -24);
}

public static Date getSQLDateAddHour(java.sql.Date date, int hour)
{
long l = date.getTime();
long n = l + (long)(hour * 60 * 60 * 1000);
java.sql.Date dateAddHour = new java.sql.Date(n);
return dateAddHour;
}

public static java.sql.Date getSQLDateAddYear(java.sql.Date date, int year)
{
Calendar c = Calendar.getInstance();
c.setTime(date);
c.set(1, c.get(1) + year);
return new java.sql.Date(c.getTime().getTime());
}

public static Date getNextSQLDate(java.sql.Date date)
{
return getSQLDateAddHour(date, 24);
}

public static Date getPreviousSQLDate(java.sql.Date date)
{
return getSQLDateAddHour(date, -24);
}

public static String getStartByAllWeek(String year, int weekCount)
{
Calendar cal = Calendar.getInstance();
cal.set(Integer.parseInt(year), 0, 1);
int week = cal.get(7);
cal.add(6, (9 - week) + (weekCount - 1) * 7);
return new String(cal.get(1) + "-" + (cal.get(2) + 1) + "-" + cal.get(5));
}

public static String getStartByFirstDay(String year, int weekCount)
{
return getStartByAllWeek(year, weekCount - 1);
}

public static java.sql.Date getDateByYearQuarter(String year, String quarter)
{
if(quarter.equals("1"))
return convertStrToSQLDate(year + "-01-01");
if(quarter.equals("2"))
return convertStrToSQLDate(year + "-04-01");
if(quarter.equals("3"))
return convertStrToSQLDate(year + "-07-01");
if(quarter.equals("4"))
return convertStrToSQLDate(year + "-10-01");
else
return null;
}

public static String[] getYearlist(int yearCount)
{
return getYearlist(yearCount, 0);
}

public static String[] getYearlist(int yearCount, int addCount)
{
String yearList[] = new String[yearCount];
Date date = new Date();
String select = "";
int year = getYear(date) - yearCount / 2;
for(int i = 0; i < yearCount; i++)
{
if(i == yearCount / 2 + addCount)
select = "selected";
yearList[i] = "<option " + select + ">" + year + "</option>";
select = "";
year++;
}

return yearList;
}

public static String getQuarterName(String quarterId)
{
if(quarterId.equals("1"))
return "\u4E00\u5B63\u5EA6";
if(quarterId.equals("2"))
return "\u4E8C\u5B63\u5EA6";
if(quarterId.equals("3"))
return "\u4E09\u5B63\u5EA6";
if(quarterId.equals("4"))
return "\u56DB\u5B63\u5EA6";
if(quarterId.equals("0"))
return "\u5168\u5E74";
else
return "";
}

public static String getWeekName(Date date)
{
Calendar c = Calendar.getInstance();
c.setTime(date);
int i = c.get(7);
if(i == 1)
return "\u661F\u671F\u5929";
if(i == 2)
return "\u661F\u671F\u4E00";
if(i == 3)
return "\u661F\u671F\u4E8C";
if(i == 4)
return "\u661F\u671F\u4E09";
if(i == 5)
return "\u661F\u671F\u56DB";
if(i == 6)
return "\u661F\u671F\u4E94";
if(i == 7)
return "\u661F\u671F\u516D";
else
return "";
}

public static String getWeekName()
{
return getWeekName(new Date());
}

public static boolean isInTime(Timestamp ts, int hour)
{
long todayTime = (new Date()).getTime();
return ts.getTime() <= todayTime + (long)(hour * 60 * 60 * 1000) && ts.getTime() >= todayTime;
}

public static void main(String args[])
{
System.out.println(convertStrToTimestamp("2005-06-06 14-05-06", "yyyy-MM-dd HH-mm-ss"));
}

public static String getHourSelect(String hour)
{
String hourSelect = "";
hour = StringUtil.removeNull(hour);
if(!"".equals(hour))
hourSelect = "<option value=" + StringUtil.addZero(hour) + " selected>" + StringUtil.addZero(hour) + "</option>";
for(int i = 0; i < 24; i++)
hourSelect = hourSelect + "<option value=" + StringUtil.addZero(i) + " >" + StringUtil.addZero(i) + "</option>";

return hourSelect;
}

public static String getMinuteAndSecondSelect(String MinuteOrSecond)
{
String MinuteOrSecondSelect = "";
MinuteOrSecond = StringUtil.removeNull(MinuteOrSecond);
if(!"".equals(MinuteOrSecond))
MinuteOrSecondSelect = "<option value=" + StringUtil.addZero(MinuteOrSecond) + " selected>" + StringUtil.addZero(MinuteOrSecond) + "</option>";
for(int i = 0; i < 60; i++)
MinuteOrSecondSelect = MinuteOrSecondSelect + "<option value=" + StringUtil.addZero(i) + " >" + StringUtil.addZero(i) + "</option>";

return MinuteOrSecondSelect;
}

// private static Logger _logger;
// static Class class$0; /* synthetic field */



private static final Log _logger = LogFactory.getLog(ChPlKindImp.class);
}

re: Java中对日期的常用处理 Crying 2008-11-05 11:30  
判断新记录

private boolean isNewRecord(java.sql.Timestamp date) {
long part = (System.currentTimeMillis() - date.getTime()) / (60 * 60 * 24 * 1000);
return (part >= 0 && part < 8);
}
re: hibernate分页1[未登录] Crying 2008-10-19 11:21  
@456
在DAO类中啊
re: Flex 视频大全『可下载』 Crying 2008-09-06 01:02  
辛苦了 楼主 EMAIL: wangsq777@126.com
re: SimpleDateFormat详解 Crying 2008-07-29 16:07  
 
【转自www.bitsCN.com】
import java.util.*;
  import java.text.*;
  public class FormatDate {
   public static void main(String[] args) {
    Date now = new Date();
  
    DateFormat defaultFormat = DateFormat.getDateInstance();
    DateFormat shortFormat = DateFormat.getDateInstance(DateFormat.SHORT);
    DateFormat mediumFormat = DateFormat.getDateInstance(DateFormat.MEDIUM);
    DateFormat longFormat = DateFormat.getDateInstance(DateFormat.LONG);
    DateFormat fullFormat = DateFormat.getDateInstance(DateFormat.FULL);
    String defaultDate = defaultFormat.format(now);
    String shortDate = shortFormat.format(now);
    String mediumDate = mediumFormat.format(now);
    String longDate = longFormat.format(now);
    String fullDate = fullFormat.format(now);
  
    System.out.println("(Default) Today :" + defaultDate);
    System.out.println("(SHORT) Today : " + shortDate);
    System.out.println("(MEDIUM) Today :" + mediumDate);

    System.out.println("(LONG) Today : " + longDate);
    System.out.println("(FULL) Today : " + fullDate);
   }
  }
  
  运行结果为:
  D:\javamail>java FormatDate
  (Default) Today :2003-6-15
  (SHORT) Today : 03-6-15
  (MEDIUM) Today :2003-6-15
  (LONG) Today : 2003年6月15日
  (FULL) Today : 2003年6月15日 星期日
 
re: DWR 实现联动下拉列表 Crying 2008-07-09 19:32  
struts 里面不可以用 select 标签 ?
哈哈 我正在寻求这个 今天有幸看见你的文章
希望自己能学习哈
麻烦 一下 wangsq777@126.com
re: 网页实用的 Crying 2008-04-24 11:03  

checkbox或者是radio 判断选择项



function checkQuestions()
{
var dd=document.getElementsByName("question");
var isSelected=false;
var StrValue="";
for(var i=0;i<dd.length;i++){
if(dd[i].checked){
isSelected=true;
StrValue+=dd[i].value+",";
}
}
if(!isSelected){
alert('您没选择投票项!');
}else{
alert(StrValue);
clearCheck();


}
}

function clearCheck(){
var dd=document.getElementsByName("question");
for(var i=0;i<dd.length;i++){
dd[i].checked=false;
}
}
re: 树形菜单 Crying 2008-03-25 09:04  
http://www.blogjava.net/sitinspring/archive/2008/03/23/188005.html

很好的一个菜单列子
re: Java中对日期的常用处理 Crying 2008-03-10 17:52  
//将字符转化为日期DATE

String birth = addStudentForm.getBirthdayYear() + "-"+ addStudentForm.getBirthdayMonth() + "-"+ addStudentForm.getBirhthdayDay();
try {
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
Date date = sd.parse(birth);
student.setBirthday(date);
} catch (ParseException e) {

System.out.println("插入失败插入失败插入失败插入失败插入失败插入失败");
}
////将日期转化为字符串
SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd");
String dd=sd.format(new Date());


////将日期转化为Timestamp

public static Timestamp convertDateToTimestamp(Date d)
{
if(d == null)
return null;
else
return new Timestamp(d.getTime());
}

------------------------------------------------------------
//第二天
public static Date getNextDate(Date date)
{
return getDateAddHour(date, 24);
}

public static Date getDateAddHour(Date date, int hour)
{
long l = date.getTime();
long n = l + (long)(hour * 60 * 60 * 1000);
Date dateAddHour = new Date(n);
return dateAddHour;
}
//前一天
public static Date getPreviousDate(Date date)
{
return getDateAddHour(date, -24);
}

注解: 加一天 就24 建一天就-24
以此类推 2天.....



好贴 转啦
re: YOYOPlayer开发手记(二)概述 Crying 2008-01-08 22:13  
我用YOYOPlayer 感觉不错! 谢谢啊
re: 网页实用的 Crying 2007-12-03 10:56  
验证 IP

function chk(){
var ip= document.getElementById("v").value;

if(!ip||ip.replace(/\s/g,"")=="")
{
alert("IP不能为空!");
return false;
}

if (!(/^(\d{1,3})(\.\d{1,3}){3}$/.test(ip)))
{ alert("IP格式错误!");
return false;
}
for (var j=0;j<4;j++)
{ if (ip.split('.')[j]>255)
{ alert("IP中的一段或多段数字超出范围!");
return false;
}
}

}
</script>


验证 三网段


<script type="text/javascript">
function chk(){
var ip= document.getElementById("v").value;

if(!ip||ip.replace(/\s/g,"")=="")
{
alert("网段不能为空!");
return false;
}

if (!(/^(\d{1,3})(\.\d{1,3}){2}$/.test(ip)))
{ alert("网段格式错误!");
return false;
}
for (var j=0;j<3;j++)
{ if (ip.split('.')[j]>255)
{ alert("IP中的一段或多段数字超出范围!");
return false;
}
}

}
</script>
re: 网页实用的[未登录] Crying 2007-11-20 10:15  
打印

<a href=javascript:window.print()>打 印</a>]
re: 网页实用的 Crying 2007-10-18 13:05  
select使用 和用span改变字体 用li来代替<br/>
<html>
<head>
<script language="javascript" type="text/javascript">
function checkSelect(value)
{
alert(document.getElementById("Select1").value);
alert(document.getElementById("Select1").options[document.getElementById("Select1").selectedIndex].text);
alert(value);
}

</script>
<link type="text/css" rel="stylesheet" href="myStyle.css"/>
</head>
<body>
<div align="center"><img src="ww.jpg" width="98%" height="126"></div>
</div>
<select id="Select1" onChange="checkSelect(this.value)">
<option value="00" selected>...</option>
<option value="1">2001</option>
<option value="2">2002</option>
<option value="3">2003</option>
<option value="4">2004</option>
<option value="5">2005</option>
<option value="6">2006</option>
</select>
<ul>
<span>真的<span>|
<span>假的</span>

<li class="shu">vvv</li>
<li><font color="blue">ddddddddd</font></li>

<li><span> dddddddddd</span></li>
</ul>
<p><a href="#">连接的变化</a>
<input name="dd" type="text" id="dd" onMouseOver=this.focus()>
<input type="text" onmouseover=this.focus()>
</p>

</body>

</html>
/******************************************
span{color:blue; font-size:24px}
li{list-style:none}

a:link{color:black; text-decoration:none}
a:visited{color:red; text-decoration:none }
a:hover{color:yellow ; text-decoration: none}
a:active{color:red ; text-decoration:none}

.shu{color: #33FF66}





re: 网页实用的 Crying 2007-10-18 13:00  
innerHTML 使用

<html>
<head>
<style type="text/css" >

span.bb{color :red}
</style>
<script type="text/javascript" language="javascript">
function load()
{
alert("vv");
document.getElementById("inner").innerHTML="成功";
}
</script>
</head>
<body onload="load()">
<span class="bb" id="inner">你还没输入</span>
</body>
</html>
HO HO! hao
re: struts中的文件上传 Crying 2007-10-11 16:03  
下载

public ActionForward download(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
if (logger.isDebugEnabled()) {
logger.debug("entering 'AttachmentAction.download()' method...");
}
ActionMessages messages = new ActionMessages();

String id = request.getParameter("id");
String attachmentFile=request.getParameter("file");
String type = request.getParameter("type");
if (id != null||attachmentFile!=null) {
Attachment attachment =null;
if(id!=null) {
attachment= mgr.view(id);
} else if(attachmentFile!=null) {
attachment=mgr.viewByFile(attachmentFile);
}

if (attachment == null) {
messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(
"object.miss"));
saveMessages(request, messages);
return mapping.findForward("failure");
}
//filename=new String(filename.getBytes("iso-8859-1"),"gb2312");
//String filepath=this.getServletContext().getRealPath("/upload");
File file = new File(mgr.getRoot()+"/"+attachment.getAttachmentFile());
String fileName = URLEncoder.encode(attachment.getAttachment(),
"UTF-8");
BufferedInputStream br = new BufferedInputStream(
new FileInputStream(file));
byte[] buf = new byte[1024 * 1024];
int len = 0;
response.reset(); //纯下载方式
//response.setContentType("application/x-msdownload");
if (type == null) {
response
.setContentType("application/octet-stream;charset=utf-8");
response.setCharacterEncoding("UTF-8");
response.setHeader("Content-Disposition",
"attachment; filename=" + fileName);
} else if (type != null && type.equals("jpg")) {
response.setHeader("Cache-Control", "no-store");
response.setDateHeader("Expires", 0);
response.setContentType("image/jpeg");
}
OutputStream out = response.getOutputStream();
while ((len = br.read(buf)) > 0)
out.write(buf, 0, len);
br.close();
out.close();
}
return null;
}
re: sql面试题及答案 Crying 2007-09-27 10:16  
SQL经典面试题及答案2007年07月27日 星期五 上午 08:421.一道SQL语句面试题,关于group by
表内容:
2005-05-09 胜
2005-05-09 胜
2005-05-09 负
2005-05-09 负
2005-05-10 胜
2005-05-10 负
2005-05-10 负

如果要生成下列结果, 该如何写sql语句?

胜 负
2005-05-09 2 2
2005-05-10 1 2
------------------------------------------
create table #tmp(rq varchar(10),shengfu nchar(1))

insert into #tmp values('2005-05-09','胜')
insert into #tmp values('2005-05-09','胜')
insert into #tmp values('2005-05-09','负')
insert into #tmp values('2005-05-09','负')
insert into #tmp values('2005-05-10','胜')
insert into #tmp values('2005-05-10','负')
insert into #tmp values('2005-05-10','负')

1)select rq, sum(case when shengfu='胜' then 1 else 0 end)'胜',sum(case when shengfu='负' then 1 else 0 end)'负' from #tmp group by rq
2) select N.rq,N.勝,M.負 from (
select rq,勝=count(*) from #tmp where shengfu='胜'group by rq)N inner join
(select rq,負=count(*) from #tmp where shengfu='负'group by rq)M on N.rq=M.rq
3)select a.col001,a.a1 胜,b.b1 负 from
(select col001,count(col001) a1 from temp1 where col002='胜' group by col001) a,
(select col001,count(col001) b1 from temp1 where col002='负' group by col001) b
where a.col001=b.col001

2.请教一个面试中遇到的SQL语句的查询问题
表中有A B C三列,用SQL语句实现:当A列大于B列时选择A列否则选择B列,当B列大于C列时选择B列否则选择C列。
------------------------------------------
select (case when a>b then a else b end ),
(case when b>c then b esle c end)
from table_name

3.面试题:一个日期判断的sql语句?
请取出tb_send表中日期(SendTime字段)为当天的所有记录?(SendTime字段为datetime型,包含日期与时间)
------------------------------------------
select * from tb where datediff(dd,SendTime,getdate())=0

4.有一张表,里面有3个字段:语文,数学,英语。其中有3条记录分别表示语文70分,数学80分,英语58分,请用一条sql语句查询出这三条记录并按以下条件显示出来(并写出您的思路):
大于或等于80表示优秀,大于或等于60表示及格,小于60分表示不及格。
显示格式:
语文 数学 英语
及格 优秀 不及格
------------------------------------------
select
(case when 语文>=80 then '优秀'
when 语文>=60 then '及格'
else '不及格') as 语文,
(case when 数学>=80 then '优秀'
when 数学>=60 then '及格'
else '不及格') as 数学,
(case when 英语>=80 then '优秀'
when 英语>=60 then '及格'
else '不及格') as 英语,
from table

5.在sqlserver2000中请用sql创建一张用户临时表和系统临时表,里面包含两个字段ID和IDValues,类型都是int型,并解释下两者的区别?
------------------------------------------
用户临时表:create table #xx(ID int, IDValues int)
系统临时表:create table ##xx(ID int, IDValues int)

区别:
用户临时表只对创建这个表的用户的Session可见,对其他进程是不可见的.
当创建它的进程消失时这个临时表就自动删除.

全局临时表对整个SQL Server实例都可见,但是所有访问它的Session都消失的时候,它也自动删除.

6.sqlserver2000是一种大型数据库,他的存储容量只受存储介质的限制,请问它是通过什么方式实现这种无限容量机制的。
------------------------------------------
它的所有数据都存储在数据文件中(*.dbf),所以只要文件够大,SQL Server的存储容量是可以扩大的.

SQL Server 2000 数据库有三种类型的文件:

主要数据文件
主要数据文件是数据库的起点,指向数据库中文件的其它部分。每个数据库都有一个主要数据文件。主要数据文件的推荐文件扩展名是 .mdf。

次要数据文件
次要数据文件包含除主要数据文件外的所有数据文件。有些数据库可能没有次要数据文件,而有些数据库则有多个次要数据文件。次要数据文件的推荐文件扩展名是 .ndf。

日志文件
日志文件包含恢复数据库所需的所有日志信息。每个数据库必须至少有一个日志文件,但可以不止一个。日志文件的推荐文件扩展名是 .ldf。

7.请用一个sql语句得出结果
从table1,table2中取出如table3所列格式数据,注意提供的数据及结果不准确,只是作为一个格式向大家请教。
如使用存储过程也可以。

table1

月份mon 部门dep 业绩yj
-------------------------------
一月份 01 10
一月份 02 10
一月份 03 5
二月份 02 8
二月份 04 9
三月份 03 8

table2

部门dep 部门名称dname
--------------------------------
01 国内业务一部
02 国内业务二部
03 国内业务三部
04 国际业务部

table3 (result)

部门dep 一月份 二月份 三月份
--------------------------------------
01 10 null null
02 10 8 null
03 null 5 8
04 null null 9

------------------------------------------
1)
select a.部门名称dname,b.业绩yj as '一月份',c.业绩yj as '二月份',d.业绩yj as '三月份'
from table1 a,table2 b,table2 c,table2 d
where a.部门dep = b.部门dep and b.月份mon = '一月份' and
a.部门dep = c.部门dep and c.月份mon = '二月份' and
a.部门dep = d.部门dep and d.月份mon = '三月份' and
2)
select a.dep,
sum(case when b.mon=1 then b.yj else 0 end) as '一月份',
sum(case when b.mon=2 then b.yj else 0 end) as '二月份',
sum(case when b.mon=3 then b.yj else 0 end) as '三月份',
sum(case when b.mon=4 then b.yj else 0 end) as '四月份',
sum(case when b.mon=5 then b.yj else 0 end) as '五月份',
sum(case when b.mon=6 then b.yj else 0 end) as '六月份',
sum(case when b.mon=7 then b.yj else 0 end) as '七月份',
sum(case when b.mon=8 then b.yj else 0 end) as '八月份',
sum(case when b.mon=9 then b.yj else 0 end) as '九月份',
sum(case when b.mon=10 then b.yj else 0 end) as '十月份',
sum(case when b.mon=11 then b.yj else 0 end) as '十一月份',
sum(case when b.mon=12 then b.yj else 0 end) as '十二月份',
from table2 a left join table1 b on a.dep=b.dep

8.华为一道面试题
一个表中的Id有多个记录,把所有这个id的记录查出来,并显示共有多少条记录数。
------------------------------------------
select id, Count(*) from tb group by id having count(*)>1
select * from(select count(ID) as count from table group by ID)T where T.count>1


import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
import java.io.*;

public class SendMail
{
static final String MAIL_HOST = "61.177.95.155";
static final boolean MAIL_NEEDAUTH = true;
static final String DEFAULT_MAIL_USER = "lioulb@126.com";
static final String DEFAULT_MAIL_PASSWORD = ".......";
static final String DEFAULT_FORMAT = "plain"; //纯文本
private MimeMessage mimeMsg; //MIME邮件对象
private Multipart mp; //Multipart对象,邮件内容,标题,附件等内容均添加到其中后再生成MimeMessage对象
private Session session; //邮件会话对象
private Properties props; //系统属性
private boolean needAuth; //smtp是否需要认证
private String userName; //smtp认证用户名和密码
private String password; //smtp认证密码
private String mailFormat = DEFAULT_FORMAT; //邮件文本格式

public SendMail(String host,boolean needAuth,String user,String password)
{ //构造方法
if(host==null||host.trim().equals(""))
{
host = MAIL_HOST;
}
setHost(host);
createMimeMessage();
setAuth(needAuth);
if(user==null)
{
user = "";
}
if(password==null)
{
password = "";
}
setUser(user,password);
setFrom(user);
}

public SendMail()
{
setHost(MAIL_HOST);
createMimeMessage();
setAuth(MAIL_NEEDAUTH);
setUser(DEFAULT_MAIL_USER,DEFAULT_MAIL_PASSWORD);
setFrom(DEFAULT_MAIL_USER);
}

private void setHost(String hostName)
{ //设置smtp的主机地址
if(props==null)
{
props = System.getProperties(); //获得系统属性对象
}
props.put("mail.smtp.host",hostName); //设置SMTP主机
}

private void setAuth(boolean need)
{ //smtp认证
if(props==null)
{
props = System.getProperties();
}
if(need)
{
props.put("mail.smtp.auth","true");
}
else
{
props.put("mail.smtp.auth","false");
}
}

private void setUser(String userName,String password)
{ //设置smtp用户名和密码
this.userName = userName;
this.password = password;
}

private boolean createMimeMessage()
{ //生成邮件对象
try
{
session = Session.getDefaultInstance(props,null); //获得邮件会话对象
}
catch(Exception e)
{
e.printStackTrace();
return false;
}
try
{
mimeMsg = new MimeMessage(session); //创建MIME邮件对象
mp = new MimeMultipart();
return true;
}
catch(Exception e)
{
e.printStackTrace();
return false;
}
}

private void setMailFormat(String format)
{ //设置邮件的正文格式 plain:纯文本格式 html:html格式
if(format==null)
{
format = "plain";
}
format = format.trim();
if(format.equals("plain")||format.equals("html"))
{
this.mailFormat = "text/"+format;
}
else
{
this.mailFormat = "text/plain";
}
}

public boolean sendMail(String to,String subject,String body,String format)
{ //发送不带附件,不转发的邮件
boolean theReturn = true;
setMailFormat(format);
// String aLine = Time.getdate()+" "+Time.gettime()+" send: "+this.userName
//+" "+to+" "+Common.convertToGb(subject);

String aLine = " send: "+this.userName
+" "+to+" "+subject;
if(setSubject(subject)&&setBody(body)&&setTo(to))
{
theReturn = sendOut();
aLine = aLine+" [Success]";
}
else
{
theReturn = false;
aLine = aLine+" [Failed]";
}

return theReturn;
}

public boolean sendMail(String to,String subject,String body)
{
return sendMail(to,subject,body,DEFAULT_FORMAT);
}

private boolean setSubject(String mailSubject)
{ //设置邮件主题
try
{
//mailSubject = Common.convertToGb(mailSubject);
mimeMsg.setSubject(mailSubject);
return true;
}
catch(Exception e)
{
e.printStackTrace();
return false;
}
}

private boolean setBody(String mailBody)
{ //设置邮件正文
try
{
//mailBody = Common.convertToGb(mailBody);
BodyPart bp = new MimeBodyPart();
bp.setContent(mailBody,this.mailFormat+";charset=GB2312"); //"<meta http-equiv=Content-Type content=text/html; charset=gb2312>"+mailBody
mp.addBodyPart(bp);
return true;
}
catch(Exception e)
{
e.printStackTrace();
return false;
}
}

private boolean setFrom(String from)
{ //设置发信人地址
try
{
mimeMsg.setFrom(new InternetAddress(from));
return true;
}
catch(Exception e)
{
e.printStackTrace();
return false;
}
}

private boolean setTo(String to)
{ //设置收信人地址
if(to==null)
{
return false;
}
try
{
mimeMsg.addRecipients(Message.RecipientType.TO,InternetAddress.parse(to));
return true;
}
catch(Exception e)
{
e.printStackTrace();
return false;
}
}

private boolean addFileAffix(String filename)
{ //添加附件
try
{
BodyPart bp = new MimeBodyPart();
FileDataSource fileds = new FileDataSource(filename);
bp.setDataHandler(new DataHandler(fileds));
bp.setFileName(fileds.getName());
mp.addBodyPart(bp);
return true;
}
catch(Exception e)
{
e.printStackTrace();
return false;
}
}

private boolean setCopyTo(String copyto)
{ //设置转发人地址
if(copyto==null)
{
return false;
}
try
{
mimeMsg.addRecipients(Message.RecipientType.CC,
(Address[])InternetAddress.parse(copyto));
return true;
}
catch(Exception e)
{
e.printStackTrace();
return false;
}
}

public int tryToConnect()
{ //连接邮箱 1:连接成功 0:连接失败 -1:已经连接或系统忙
int theReturn = 0;
// String aLine = Time.getdate()+" "+Time.gettime()+" Connect: "+this.userName
//+" "+this.userName+" "+this.password;

String aLine = " Connect: "+this.userName
+" "+this.userName+" "+this.password;
try
{
Session mailSession = Session.getInstance(props,null);
Transport transport = mailSession.getTransport("smtp");
transport.connect((String)props.get("mail.smtp.host"),this.userName,
this.password);
transport.close();
theReturn = 1;
aLine = aLine+" [Success]";
}
catch(MessagingException e)
{
e.printStackTrace();
theReturn = 0;
}
catch(IllegalStateException e)
{
e.printStackTrace();
theReturn = -1;
}
catch(Exception e)
{
e.printStackTrace();
theReturn = 0;
aLine = aLine+" [Failed]";
}
return theReturn;
}

private boolean sendOut()
{ //发送邮件
try
{
mimeMsg.setContent(mp);
mimeMsg.saveChanges();
Session mailSession = Session.getInstance(props,null);
Transport transport = mailSession.getTransport("smtp");
transport.connect((String)props.get("mail.smtp.host"),this.userName,
this.password);
transport.sendMessage(mimeMsg,mimeMsg.getAllRecipients());
transport.close();
return true;
}
catch(Exception e)
{
e.printStackTrace();
return false;
}
}

public boolean changePwd(String userName,String newPwd)
{ //修改邮箱密码
boolean theReturn = false;
try
{
String commond = "passwd "+userName;
Process process = Runtime.getRuntime().exec(commond);
BufferedReader br = new BufferedReader(new InputStreamReader(process.
getInputStream()));
PrintStream ps = new PrintStream(process.getOutputStream());
BufferedReader br1 = new BufferedReader(new InputStreamReader(process.
getErrorStream()));
char ac[] = new char[1024];
br1.read(ac);
ps.println(newPwd);
ps.flush();
br1.read(ac);
ps.println(newPwd);
ps.flush();
br1.read(ac);
if(process.waitFor()==0)
{
theReturn = true;
}
}
catch(Exception e)
{
e.printStackTrace();
//e.printStackTrace(System.out);
System.out.println(e.toString());
theReturn = false;
}
return theReturn;
}

public boolean addUser(String userName)
{ //添加邮件用户 (密码默认为空)
boolean theReturn = false;
try
{
String commond = "/usr/sbin/useradd "+userName+
" -g mail -d /dev/null -s /bin/false";
Process process = Runtime.getRuntime().exec(commond);
BufferedReader br = new BufferedReader(new InputStreamReader(process.
getInputStream()));
PrintStream ps = new PrintStream(process.getOutputStream());
BufferedReader br1 = new BufferedReader(new InputStreamReader(process.
getErrorStream()));
char ac[] = new char[1024];
br1.read(ac);
if(process.waitFor()==0)
{
theReturn = true;
}
}
catch(Exception e)
{
e.printStackTrace(System.out);
theReturn = false;
}
return theReturn;
}

public boolean addUser(String userName,String pwd)
{ //添加邮件用户
boolean theReturn = addUser(userName);
if(theReturn)
{
theReturn = changePwd(userName,pwd);
if(!theReturn)
{ //修改密码失败
deleUser(userName);
}
}
return theReturn;
}

public boolean deleUser(String userName)
{ //删除邮件用户
boolean theReturn = false;
try
{
String commond = "/usr/sbin/userdel "+userName;
Process process = Runtime.getRuntime().exec(commond);
BufferedReader br = new BufferedReader(new InputStreamReader(process.
getInputStream()));
PrintStream ps = new PrintStream(process.getOutputStream());
BufferedReader br1 = new BufferedReader(new InputStreamReader(process.
getErrorStream()));
char ac[] = new char[1024];
br1.read(ac);
if(process.waitFor()==0)
{
theReturn = true;
}
}
catch(Exception exception)
{
exception.printStackTrace(System.out);
theReturn = false;
}
return theReturn;
}

public static void main(String args[]){
SendMail myMail=new SendMail();
System.out.println(myMail.sendMail("oxservice@126.com","this is test","my \n test"));
}
}
re: javascript小技巧 Crying 2007-09-21 12:21  
javascript事件查询综合
click() 对象.click() 使对象被点击。
closed 对象.closed 对象窗口是否已关闭true/false
clearTimeout(对象) 清除已设置的setTimeout对象
clearInterval(对象) 清除已设置的setInterval对象
confirm("提示信息") 弹出确认框,确定返回true取消返回false
cursor:样式 更改鼠标样式 hand crosshair text wait help default auto e/s/w/n-resize

event.clientX 返回最后一次点击鼠标X坐标值;
event.clientY 返回最后一次点击鼠标Y坐标值;
event.offsetX 返回当前鼠标悬停X坐标值
event.offsetY 返回当前鼠标悬停Y坐标值

document.write(document.lastModified) 网页最后一次更新时间
document.ondblclick=x 当双击鼠标产生事件
document.onmousedown=x 单击鼠标键产生事件

document.body.scrollTop; 返回和设置当前竖向滚动条的坐标值,须与函数配合,
document.body.scrollLeft; 返回和设置当前横向滚动务的坐标值,须与函数配合,
document.title document.title="message"; 当前窗口的标题栏文字
document.bgcolor document.bgcolor="颜色值"; 改变窗口背景颜色
document.Fgcolor document.Fgcolor="颜色值"; 改变正文颜色
document.linkcolor document.linkcolor="颜色值"; 改变超联接颜色
document.alinkcolor document.alinkcolor="颜色值"; 改变正点击联接的颜色
document.VlinkColor document.VlinkColor="颜色值"; 改变已访问联接的颜色
document.forms.length 返回当前页form表单数
document.anchors.length 返回当前页锚的数量
document.links.length 返回当前页联接的数量
document.onmousedown=x 单击鼠标触发事件
document.ondblclick=x 双击鼠标触发事件
defaultStatus window.status=defaultStatus; 将状态栏设置默认显示

function function xx(){...} 定义函数
isNumeric 判断是否是数字
innerHTML xx=对象.innerHTML 输入某对象标签中的html源代码
innerText divid.innerText=xx 将以div定位以id命名的对象值设为XX

location.reload(); 使本页刷新,target可等于一个刷新的网页

Math.random() 随机涵数,只能是0到1之间的数,如果要得到其它数,可以为*10,再取整
Math.floor(number) 将对象number转为整数,舍取所有小数
Math.min(1,2) 返回1,2哪个小
Math.max(1,2) 返回1,2哪个大

navigator.appName 返回当前浏览器名称
navigator.appVersion 返回当前浏览器版本号
navigator.appCodeName 返回当前浏览器代码名字
navigator.userAgent 返回当前浏览器用户代标志

onsubmit onsubmit="return(xx())" 使用函数返回值
opener opener.document.对象 控制原打开窗体对象

prompt xx=window.prompt("提示信息","预定值"); 输入语句
parent parent.框架名.对象 控制框架页面

return return false 返回值
random 随机参数(0至1之间)
reset() form.reset(); 使form表单内的数据重置

split("") string.split("") 将string对象字符以逗号隔开
submit() form对象.submit() 使form对象提交数据

String对象的 charAt(x)对象 反回指定对象的第多少位的字母
lastIndexOf("string") 从右到左询找指定字符,没有返回-1
indexOf("string") 从左到右询找指定字符,没有返回-1
LowerCase() 将对象全部转为小写
UpperCase() 将对象全部转为大写
substring(0,5) string.substring(x,x) 返回对象中从0到5的字符
setTimeout("function",time) 设置一个超时对象
setInterval("function",time) 设置一个超时对象

toLocaleString() x.toLocaleString() 从x时间对象中获取时间,以字符串型式存在
typeof(变量名) 检查变量的类型,值有:String,Boolean,Object,Function,Underfined

window.event.button==1/2/3 鼠标键左键等于1右键等于2两个键一起按为3
window.screen.availWidth 返回当前屏幕宽度(空白空间)
window.screen.availHeight 返回当前屏幕高度(空白空间)
window.screen.width 返回当前屏幕宽度(分辨率值)
window.screen.height 返回当前屏幕高度(分辨率值)
window.document.body.offsetHeight; 返回当前网页高度
window.document.body.offsetWidth; 返回当前网页宽度
window.resizeTo(0,0) 将窗口设置宽高
window.moveTo(0,0) 将窗口移到某位置
window.focus() 使当前窗口获得焦点
window.scroll(x,y) 窗口滚动条坐标,y控制上下移动,须与函数配合
window.open() window.open("地址","名称","属性")
属性:toolbar(工具栏),location(地址栏),directions,status(状态栏),
menubar(菜单栏),scrollbar(滚动条),resizable(改变大小), width(宽),height(高),fullscreen(全 屏),scrollbars(全屏时无滚动条无参 数,channelmode(宽屏),left(打开窗口x坐标),top(打开窗口y坐标)
window.location = 'view-source:' + window.location.href 应用事件查看网页源代码;


a=new Date(); //创建a为一个新的时期对象
y=a.getYear(); //y的值为从对象a中获取年份值 两位数年份
y1=a.getFullYear(); //获取全年份数 四位数年份
m=a.getMonth(); //获取月份值
d=a.getDate(); //获取日期值
d1=a.getDay(); //获取当前星期值
h=a.getHours(); //获取当前小时数
m1=a.getMinutes(); //获取当前分钟数
s=a.getSeconds(); //获取当前秒钟数


对象.style.fontSize="文字大小";
单位:mm/cm/in英寸/pc帕/pt点/px象素/em文字高
1in=1.25cm
1pc=12pt
1pt=1.2px(800*600分辩率下)

文本字体属性:
fontSize大小
family字体
color颜色
fontStyle风格,取值为normal一般,italic斜体,oblique斜体且加粗
fontWeight加粗,取值为100到900不等,900最粗,light,normal,bold
letterSpacing间距,更改文字间距离,取值为,1pt,10px,1cm
textDecoration:文字修饰;取值,none不修饰,underline下划线,overline上划线
background:文字背景颜色,
backgroundImage:背景图片,取值为图片的插入路径


点击网页正文函数调用触发器:

1.onClick 当对象被点击
2.onLoad 当网页打开,只能书写在body中
3.onUnload 当网页关闭或离开时,只能书写在body中
4.onmouseover 当鼠标悬于其上时
5.onmouseout 当鼠标离开对象时
6.onmouseup 当鼠标松开
7.onmousedown 当鼠标按下键
8.onFocus 当对象获取焦点时
9.onSelect 当对象的文本被选中时
10.onChange 当对象的内容被改变
11.onBlur 当对象失去焦点
onsubmit=return(ss())表单调用时返回的值

直线 border-bottom:1x solid black
虚线 border-bottom:1x dotted black
点划线 border-bottom:2x dashed black
双线 border-bottom:5x double black
槽状 border-bottom:1x groove black
脊状 border-bottom:1x ridge black

re: 网页实用的 Crying 2007-09-20 18:19  
框架



<frameset rows="21%,*">
<frame src="aa.html" noresize>//noresize 是确定框架的大小固定且不能改变
<frameset cols="20%,*">
<frame src="bb.html" noresize>
<frame src="bb.html" scrolling="yes" >//scrolling 是确定滚动条是否对用户有效,yes,no,auto
</frameset>
</frameset>
re: 网页实用的 Crying 2007-09-19 19:48  
退出
1.。<html:submit onclick="javascript:window.close()">退出</html:submit>
2.。<a href="javascript:window.close()">关闭</a>


除去空格
in Javascript:
去掉leading/trailing 空格: str = str.replace(/^\s+|\s+$/g,"");
去掉all空格: str = str.replace(/\s+/g,"");





re: 网页实用的 Crying 2007-09-19 19:46  
<head>

<title>Untitled Document</title>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<SCRIPT LANGUAGE="JavaScript">

<!--

function formHandler(URL)
{


window.location.href = URL;

}
// -->


</SCRIPT>

</head>

<FORM name = "form">

<SELECT NAME="site" SIZE=1 onChange ="formHandler(this.value)">

<option value="">连接到…. </option>

<option value="http://www.ddvip.com">豆豆技术</option>

<option value="http://soft.ddvip.net">豆豆软件 </option>

<option value="http://bbs.ddvip.net">豆豆论坛 </option>

<option value="http://vip.ddvip.net">视频在线 </option>

<option value="http://soft.ddvip.net">豆豆软件 </option>

</SELECT>
</FORM>
re: 网页实用的 Crying 2007-09-19 19:45  
重定向
<html:submit onclick="javascript:window.location.href='userIpt.jsp'">返回</html:submit>
//////////////////////////////////

<html>
<head>
<title>错误页面</title>
<script type="text/javascript">
<!--
function check(){

form.action="log.jsp";
}
//-->
</script>
</head>

<body bgcolor="#E0F0F8">
<center>
<form action="" name="form">
对不起你 !无权访问!
<br>
<html:submit onclick="check()">返回</html:submit>
</form>
</center>
</body>
</html>
/********刷新frame***********/

window.parent.frames('leftFrame').document.location.reload();
javascript:window.parent.frames('leftFrame').document.location.reload();
re: 网页实用的 Crying 2007-09-19 19:43  
倒计时

<Script Language="JavaScript">
   var timedate= new Date("October 1,2007");
   var times= "2010年国庆节";
   var now = new Date();
   var date = timedate.getTime() - now.getTime();
   var time = Math.floor(date / (1000 * 60 * 60 * 24));
   if (time >= 0)
   document.write( "现在离"+times+"还有: "+time +"天")
</Script>
re: AOP观念(转载) Crying 2007-09-16 11:50  
AOP对我来说到现在还没真正的理解,昨天晚上又把《Spring开发 手册》和《精通Spring》的AOP部分看了哈可是还是云里雾里的,要是叫我说出AOP的思想我肯定打哽心里是明白会用,可就是说不上来(丢人了....).。
我现在就把我所能说的都说出来啊,说的不对大家别骂我,要是能对AOP有很好理解的麻烦给我留个言,给小弟带来点感悟。。。先谢谢啦。
我认为AOP的实现其实就是靠的就是代理Bean(PoxyFactoryBean)和拦截器(Interceptor)来实现的。
AOP中有几个关键字Aspect,advice,pointCut,target,......
Aspect 就是将你想往目标对象中插入的东西(如事务,日志),将这些日志,事务封装成一个类也就成了Aspect了。
advice 是可是说是Aspect中的一个方法吧。
pointCut 是目标对象中的一个方法,也就是你想在目标对像的哪个位置织入你 的Advice。
target 就是你的目标对象啦

Spring AOP
re: AOP观念(转载) Crying 2007-09-16 11:07  
IOC 个人理解
从字面意思来说是控制反转,利用依赖注入模式将原来组件依赖于对象的关系,改变成组件依赖于抽象接口,将应用程序依赖于容器变成容器管理应用程序。为了调用IOC容器,组件必须利用BeanFactory或ApplicationContext,利用他们可以管理容器中的Bean实例的生命周期,用getBean(String ...)方法得到Bean实例,ApplicationContext在BeanFactory的基础之上实现了扩展增加了资源取得,消息解析,事件处理等功能,使得Spring的IOC容器来协调各组件间相互的依赖关系。
http://www.itisedu.com/phrase/200603091205485.html