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.aygfsteel.com/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: Java中對日期的常用處理[未登錄] Crying 2008-01-08 23:23
好貼 轉啦
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>
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