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

          比如你的電腦要在22:00關(guān)機(jī),可以選擇“開(kāi)始→運(yùn)行”,輸入“at 22:00 Shutdown -s”,這樣,到了22點(diǎn)電腦就會(huì)出現(xiàn)“系統(tǒng)關(guān)機(jī)”對(duì)話框,默認(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”,則可以打開(kāi)設(shè)置自動(dòng)關(guān)機(jī)對(duì)話框,對(duì)自動(dòng)關(guān)機(jī)進(jìn)行設(shè)置。

          Shutdown.exe的參數(shù),每個(gè)都具有特定的用途,執(zhí)行每一個(gè)都會(huì)產(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ī)對(duì)話框中的消息內(nèi)容(不能超127個(gè)字符)
          posted @ 2006-08-07 14:18 kelven 閱讀(426) | 評(píng)論 (0)編輯 收藏
          http://popkart.tiancity.com/homepage/
          posted @ 2006-07-10 13:18 kelven 閱讀(347) | 評(píng)論 (2)編輯 收藏
          1.將數(shù)據(jù)庫(kù)驅(qū)動(dòng)程序的JAR文件放在Tomcat的?common/lib?中;
          2.在server.xml中設(shè)置數(shù)據(jù)源,以MySQL數(shù)據(jù)庫(kù)為例,如下:
          在<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"/>
          ???屬性說(shuō)明:name,數(shù)據(jù)源名稱,通常取”jdbc/XXX”的格式;
          ????????????type,”javax.sql.DataSource”;
          ????????????password,數(shù)據(jù)庫(kù)用戶密碼;
          ????????????driveClassName,數(shù)據(jù)庫(kù)驅(qū)動(dòng);
          ????????????maxIdle,最大空閑數(shù),數(shù)據(jù)庫(kù)連接的最大空閑時(shí)間。超過(guò)空閑時(shí)間,數(shù)據(jù)庫(kù)連
          ?????????????????????接將被標(biāo)記為不可用,然后被釋放。設(shè)為0表示無(wú)限制。
          ????????????MaxActive,連接池的最大數(shù)據(jù)庫(kù)連接數(shù)。設(shè)為0表示無(wú)限制。
          ????????????maxWait?,最大建立連接等待時(shí)間。如果超過(guò)此時(shí)間將接到異常。設(shè)為-1表示
          ?????????????????????無(wú)限制。
          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)說(shuō)明:?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"/>
          ???屬性說(shuō)明:name,同第2步和第3步的屬性name值,和子節(jié)點(diǎn)res-ref-name值;
          ?????????????type,同樣取”javax.sql.DataSource”;
          ?????????????global,同name值。
          ?
          至此,設(shè)置完成,下面是如何使用數(shù)據(jù)庫(kù)連接池。
          1.建立一個(gè)連接池類,DBPool.java,用來(lái)創(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ù)庫(kù)操作的類或jsp頁(yè)面中,用DBPool.getPool().getConnection(),獲得一個(gè)Connection對(duì)象,就可以進(jìn)行數(shù)據(jù)庫(kù)操作,最后別忘了對(duì)Connection對(duì)象調(diào)用close()方法,注意:這里不會(huì)關(guān)閉這個(gè)Connection,而是將這個(gè)Connection放回?cái)?shù)據(jù)庫(kù)連接池。
          posted @ 2006-06-14 11:17 kelven 閱讀(931) | 評(píng)論 (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等就會(huì)出現(xiàn)打不開(kāi)的現(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是自己寫(xiě)的一個(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 閱讀(1466) | 評(píng)論 (0)編輯 收藏
          主站蜘蛛池模板: 井陉县| 吉木乃县| 昂仁县| 平遥县| 常宁市| 乐平市| 兰溪市| 祁东县| 奉节县| 夏津县| 临高县| 康乐县| 班玛县| 咸宁市| 北宁市| 巍山| 江孜县| 商河县| 隆林| 泉州市| 靖边县| 丹江口市| 沅陵县| 夏河县| 顺昌县| 榆中县| 海伦市| 万安县| 凤凰县| 炉霍县| 扶绥县| 青河县| 宁河县| 南投县| 娱乐| 丹棱县| 德保县| 定南县| 竹北市| 夏津县| 乌拉特中旗|