posts - 22,comments - 35,trackbacks - 0
          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 閱讀(426) | 評論 (0)編輯 收藏
          http://popkart.tiancity.com/homepage/
          posted @ 2006-07-10 13:18 kelven 閱讀(347) | 評論 (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 閱讀(931) | 評論 (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 閱讀(1466) | 評論 (0)編輯 收藏

          [http://www.javaalmanac.com] - Java開發者年鑒一書的在線版本. 要想快速查到某種Java技巧的用法及示例代碼, 這是一個不錯的去處.
          [http://www.onjava.com] - O'Reilly的Java網站. 每周都有新文章.
          [http://java.sun.com] - 官方的Java開發者網站 - 每周都有新文章發表.
          [http://www.developer.com/java] - 由Gamelan.com 維護的Java技術文章網站.
          [http://www.java.net] - Sun公司維護的一個Java社區網站.
          [http://www.builder.com] - Cnet的Builder.com網站 - 所有的技術文章, 以Java為主.
          [http://www.ibm.com/developerworks/java] - IBM的Developerworks技術網站; 這是其中的Java技術主頁.
          [http://www.javaworld.com] - 最早的一個Java站點. 每周更新Java技術文章.
          [http://www.devx.com/java] - DevX維護的一個Java技術文章網站.
          [http://www.fawcette.com/javapro] - JavaPro在線雜志網站.
          [http://www.sys-con.com/java] - Java Developers Journal的在線雜志網站.
          [http://www.javadesktop.org] - 位于Java.net的一個Java桌面技術社區網站.
          [http://www.theserverside.com] - 這是一個討論所有Java服務器端技術的網站.
          [http://www.jars.com] - 提供Java評論服務. 包括各種framework和應用程序.
          [http://www.jguru.com] - 一個非常棒的采用Q&A形式的Java技術資源社區.
          [http://www.javaranch.com] - 一個論壇,得到Java問題答案的地方,初學者的好去處。
          [http://www.ibiblio.org/javafaq/javafaq.html] - comp.lang.java的FAQ站點 - 收集了來自comp.lang.java新聞組的問題和答案的分類目錄.
          http://java.sun.com/docs/books/tutorial/] - 來自SUN公司的官方Java指南 - 對于了解幾乎所有的java技術特性非常有幫助.
          http://www.javablogs.com] - 互聯網上最活躍的一個Java Blog網站.
          http://java.about.com/] - 來自About.com的Java新聞和技術文章網站.

          posted @ 2006-04-05 14:03 kelven 閱讀(412) | 評論 (0)編輯 收藏
          主站蜘蛛池模板: 西昌市| 米林县| 修文县| 宁强县| 河北区| 文成县| 阳春市| 旬邑县| 冕宁县| 肇庆市| 建瓯市| 邹城市| 齐河县| 长岭县| 泾阳县| 申扎县| 元谋县| 嘉定区| 黎平县| 鲁甸县| 松原市| 会理县| 襄汾县| 喜德县| 中西区| 岳阳县| 米脂县| 巴林左旗| 威海市| 深圳市| 华蓥市| 合水县| 皮山县| 嘉义县| 贡觉县| 堆龙德庆县| 内丘县| 嵩明县| 凤冈县| 灌南县| 北京市|