Windows XP的關機是由Shutdown.exe程序來控制的,位于Windows\System32文件夾中。如果想讓Windows 2000也實現同樣的效果,可以把Shutdown.exe復制到系統目錄下。
比如你的電腦要在22:00關機,可以選擇“開始→運行”,輸入“at 22:00 Shutdown -s”,這樣,到了22點電腦就會出現“系統關機”對話框,默認有30秒鐘的倒計時并提示你保存工作。如果你想以倒計時的方式關機,可以輸入“Shutdown.exe -s -t 3600”,這里表示60分鐘后自動關機,“3600”代表60分鐘。
設置好自動關機后,如果想取消的話,可以在運行中輸入“shutdown -a”。另外輸入“shutdown -i”,則可以打開設置自動關機對話框,對自動關機進行設置。
Shutdown.exe的參數,每個都具有特定的用途,執行每一個都會產生不同的效果,比如“-s”就表示關閉本地計算機,“-a”表示取消關機操作,下面列出了更多參數,大家可以在Shutdown.exe中按需使用。
? -f:強行關閉應用程序
-m:\\計算機名:控制遠程計算機
-i:顯示圖形用戶界面,但必須是Shutdown的第一個選項
-l:注銷當前用戶
-r:關機并重啟
-t:時間:設置關機倒計時
-c:“消息內容”:輸入關機對話框中的消息內容(不能超127個字符)
posted @
2006-08-07 14:18 kelven 閱讀(421) |
評論 (0) |
編輯 收藏
http://popkart.tiancity.com/homepage/
posted @
2006-07-10 13:18 kelven 閱讀(342) |
評論 (2) |
編輯 收藏
1.將數據庫驅動程序的JAR文件放在Tomcat的?common/lib?中;
2.在server.xml中設置數據源,以MySQL數據庫為例,如下:
在<GlobalNamingResources>?</GlobalNamingResources>節點中加入,
??????<Resource
??????name="jdbc/DBPool"
??????type="javax.sql.DataSource"
??????password="root"
??????driverClassName="com.mysql.jdbc.Driver"
??????maxIdle="2"
??????maxWait="5000"
??????username="root"
??????url="jdbc:mysql://127.0.0.1:3306/test"
??????maxActive="4"/>
???屬性說明:name,數據源名稱,通常取”jdbc/XXX”的格式;
????????????type,”javax.sql.DataSource”;
????????????password,數據庫用戶密碼;
????????????driveClassName,數據庫驅動;
????????????maxIdle,最大空閑數,數據庫連接的最大空閑時間。超過空閑時間,數據庫連
?????????????????????接將被標記為不可用,然后被釋放。設為0表示無限制。
????????????MaxActive,連接池的最大數據庫連接數。設為0表示無限制。
????????????maxWait?,最大建立連接等待時間。如果超過此時間將接到異常。設為-1表示
?????????????????????無限制。
3.在你的web應用程序的web.xml中設置數據源參考,如下:
??在<web-app></web-app>節點中加入,
??<resource-ref>
????<description>MySQL?DB?Connection?Pool</description>
????<res-ref-name>jdbc/DBPool</res-ref-name>
????<res-type>javax.sql.DataSource</res-type>
????<res-auth>Container</res-auth>
????<res-sharing-scope>Shareable</res-sharing-scope>
?</resource-ref>
??子節點說明:?description,描述信息;
???????????????res-ref-name,參考數據源名字,同上一步的屬性name;
???????????????res-type,資源類型,”javax.sql.DataSource”;
???????????????res-auth,”Container”;
???????????????res-sharing-scope,”Shareable”;
4.在web應用程序的context.xml中設置數據源鏈接,如下:
??在<Context></Context>節點中加入,
??<ResourceLink
???name="jdbc/DBPool"?
???type="javax.sql.DataSource"?
???global="jdbc/DBPool"/>
???屬性說明:name,同第2步和第3步的屬性name值,和子節點res-ref-name值;
?????????????type,同樣取”javax.sql.DataSource”;
?????????????global,同name值。
?
至此,設置完成,下面是如何使用數據庫連接池。
1.建立一個連接池類,DBPool.java,用來創建連接池,代碼如下:
import?javax.naming.Context;
import?javax.naming.InitialContext;
import?javax.naming.NamingException;
import?javax.sql.DataSource;
public?class?DBPool?{
????private?static?DataSource?pool;
????static?{
?????????Context?env?=?null;
??????????try?{
??????????????env?=?(Context)?new?InitialContext().lookup("java:comp/env");
??????????????pool?=?(DataSource)env.lookup("jdbc/DBPool");
??????????????if(pool==null)?
??????????????????System.err.println("'DBPool'?is?an?unknown?DataSource");
???????????????}?catch(NamingException?ne)?{
??????????????????ne.printStackTrace();
??????????}
??????}
????public?static?DataSource?getPool()?{
????????return?pool;
????}
}
2.在要用到數據庫操作的類或jsp頁面中,用DBPool.getPool().getConnection(),獲得一個Connection對象,就可以進行數據庫操作,最后別忘了對Connection對象調用close()方法,注意:這里不會關閉這個Connection,而是將這個Connection放回數據庫連接池。
posted @
2006-06-14 11:17 kelven 閱讀(927) |
評論 (0) |
編輯 收藏
<%@ page import="java.io.*"%>
<%
String root=application.getRealPath("/");
String fileName=request.getParameter("fileName");
String filePath=request.getParameter("filePath");
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition",
"attachment; filename=\"" +fileName+ "\"");
try{
java.io.OutputStream os = response.getOutputStream(); //不加此行將只能下載文本文件.下載jpg等就會出現打不開的現象.
java.io.FileInputStream fis = new java.io.FileInputStream(root+filePath);
byte[] b = new byte[1024];
int i = 0;
while ( (i = fis.read(b)) > 0 )
{
os.write(b, 0, i);
}
fis.close();
os.flush();
os.close();
}
catch ( Exception e )
{
System.out.println ( "IOException." + e );
}
%>
java.io.FileInputStream fis = new java.io.FileInputStream(文件的真實路徑);
也可以
<%
if (request.getParameter("fileUrl") != null)
{
String strFileUrl = request.getParameter("fileUrl");
//獲取文件名(DealFile是自己寫的一個處理文件的一個類)
DealFile dealFile = new DealFile(strFileUrl);
String filename = dealFile.getFileName();
response.setHeader("content-type","application/octet-stream");
response.setHeader("Content-Disposition","attachment;filename=\""+ filename+"\"");
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
try
{
//從文件所在目錄以流的方式讀取文件
bis = new BufferedInputStream(new FileInputStream(getServletContext().getRealPath(strFileUrl)));
bos = new BufferedOutputStream(response.getOutputStream());
byte[] buff = new byte[2048];
int bytesRead;
while(-1 != (bytesRead = bis.read(buff, 0, buff.length)))
{
bos.write(buff,0,bytesRead);
}
bos.flush();
}
catch(final IOException e)
{
System.out.println ( "IOException." + e );
}
finally
{
if (bis != null)
bis.close();
if (bos != null)
bos.close();
}
return;
}
%>
posted @
2006-04-14 16:04 kelven 閱讀(1461) |
評論 (0) |
編輯 收藏