posts - 22,comments - 35,trackbacks - 0
          Windows XP的關(guān)機(jī)是由Shutdown.exe程序來控制的,位于Windows\System32文件夾中。如果想讓W(xué)indows 2000也實(shí)現(xiàn)同樣的效果,可以把Shutdown.exe復(fù)制到系統(tǒng)目錄下。

          比如你的電腦要在22:00關(guān)機(jī),可以選擇“開始→運(yùn)行”,輸入“at 22:00 Shutdown -s”,這樣,到了22點(diǎn)電腦就會出現(xiàn)“系統(tǒng)關(guān)機(jī)”對話框,默認(rèn)有30秒鐘的倒計(jì)時(shí)并提示你保存工作。如果你想以倒計(jì)時(shí)的方式關(guān)機(jī),可以輸入“Shutdown.exe -s -t 3600”,這里表示60分鐘后自動(dòng)關(guān)機(jī),“3600”代表60分鐘。

          設(shè)置好自動(dòng)關(guān)機(jī)后,如果想取消的話,可以在運(yùn)行中輸入“shutdown -a”。另外輸入“shutdown -i”,則可以打開設(shè)置自動(dòng)關(guān)機(jī)對話框,對自動(dòng)關(guān)機(jī)進(jìn)行設(shè)置。

          Shutdown.exe的參數(shù),每個(gè)都具有特定的用途,執(zhí)行每一個(gè)都會產(chǎn)生不同的效果,比如“-s”就表示關(guān)閉本地計(jì)算機(jī),“-a”表示取消關(guān)機(jī)操作,下面列出了更多參數(shù),大家可以在Shutdown.exe中按需使用。

          ? -f:強(qiáng)行關(guān)閉應(yīng)用程序
            -m:\\計(jì)算機(jī)名:控制遠(yuǎn)程計(jì)算機(jī)
            -i:顯示圖形用戶界面,但必須是Shutdown的第一個(gè)選項(xiàng)
            -l:注銷當(dāng)前用戶
            -r:關(guān)機(jī)并重啟
            -t:時(shí)間:設(shè)置關(guān)機(jī)倒計(jì)時(shí)
            -c:“消息內(nèi)容”:輸入關(guān)機(jī)對話框中的消息內(nèi)容(不能超127個(gè)字符)
          posted @ 2006-08-07 14:18 kelven 閱讀(431) | 評論 (0)編輯 收藏
          http://popkart.tiancity.com/homepage/
          posted @ 2006-07-10 13:18 kelven 閱讀(353) | 評論 (2)編輯 收藏
          1.將數(shù)據(jù)庫驅(qū)動(dòng)程序的JAR文件放在Tomcat的?common/lib?中;
          2.在server.xml中設(shè)置數(shù)據(jù)源,以MySQL數(shù)據(jù)庫為例,如下:
          在<GlobalNamingResources>?</GlobalNamingResources>節(jié)點(diǎn)中加入,
          ??????<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,數(shù)據(jù)源名稱,通常取”jdbc/XXX”的格式;
          ????????????type,”javax.sql.DataSource”;
          ????????????password,數(shù)據(jù)庫用戶密碼;
          ????????????driveClassName,數(shù)據(jù)庫驅(qū)動(dòng);
          ????????????maxIdle,最大空閑數(shù),數(shù)據(jù)庫連接的最大空閑時(shí)間。超過空閑時(shí)間,數(shù)據(jù)庫連
          ?????????????????????接將被標(biāo)記為不可用,然后被釋放。設(shè)為0表示無限制。
          ????????????MaxActive,連接池的最大數(shù)據(jù)庫連接數(shù)。設(shè)為0表示無限制。
          ????????????maxWait?,最大建立連接等待時(shí)間。如果超過此時(shí)間將接到異常。設(shè)為-1表示
          ?????????????????????無限制。
          3.在你的web應(yīng)用程序的web.xml中設(shè)置數(shù)據(jù)源參考,如下:
          ??在<web-app></web-app>節(jié)點(diǎn)中加入,
          ??<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>
          ??子節(jié)點(diǎn)說明:?description,描述信息;
          ???????????????res-ref-name,參考數(shù)據(jù)源名字,同上一步的屬性name;
          ???????????????res-type,資源類型,”javax.sql.DataSource”;
          ???????????????res-auth,”Container”;
          ???????????????res-sharing-scope,”Shareable”;
          4.在web應(yīng)用程序的context.xml中設(shè)置數(shù)據(jù)源鏈接,如下:
          ??在<Context></Context>節(jié)點(diǎn)中加入,
          ??<ResourceLink
          ???name="jdbc/DBPool"?
          ???type="javax.sql.DataSource"?
          ???global="jdbc/DBPool"/>
          ???屬性說明:name,同第2步和第3步的屬性name值,和子節(jié)點(diǎn)res-ref-name值;
          ?????????????type,同樣取”javax.sql.DataSource”;
          ?????????????global,同name值。
          ?
          至此,設(shè)置完成,下面是如何使用數(shù)據(jù)庫連接池。
          1.建立一個(gè)連接池類,DBPool.java,用來創(chuàng)建連接池,代碼如下:
          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.在要用到數(shù)據(jù)庫操作的類或jsp頁面中,用DBPool.getPool().getConnection(),獲得一個(gè)Connection對象,就可以進(jìn)行數(shù)據(jù)庫操作,最后別忘了對Connection對象調(diào)用close()方法,注意:這里不會關(guān)閉這個(gè)Connection,而是將這個(gè)Connection放回?cái)?shù)據(jù)庫連接池。
          posted @ 2006-06-14 11:17 kelven 閱讀(935) | 評論 (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等就會出現(xiàn)打不開的現(xiàn)象.
          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(文件的真實(shí)路徑);
          也可以

          <%
          if (request.getParameter("fileUrl") != null)
          {
          String strFileUrl = request.getParameter("fileUrl");

          //獲取文件名(DealFile是自己寫的一個(gè)處理文件的一個(gè)類)
          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 閱讀(1474) | 評論 (0)編輯 收藏
          主站蜘蛛池模板: 阿拉善左旗| 车致| 尼勒克县| 周至县| 衡东县| 河西区| 青神县| 石棉县| 互助| 奉贤区| 德安县| 祁阳县| 南宁市| 永昌县| 马公市| 敦化市| 上林县| 河南省| 永修县| 元氏县| 永平县| 惠来县| 牡丹江市| 赤城县| 西吉县| 盐池县| 青冈县| 白水县| 天台县| 千阳县| 苏尼特右旗| 凤翔县| 闻喜县| 改则县| 庆城县| 梨树县| 石城县| 潮安县| 石景山区| 瓦房店市| 蕉岭县|