<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:gd="http://schemas.google.com/g/2005" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;DkYBQng6eCp7ImA9WhdTEUw.&quot;"><id>tag:blogger.com,1999:blog-272429821527780388</id><updated>2011-07-08T01:35:53.610-07:00</updated><title>Code-StandUp</title><subtitle type="html" /><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://codestandup.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://codestandup.blogspot.com/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/272429821527780388/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" /><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>115</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/Code-standup" /><feedburner:info uri="code-standup" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry gd:etag="W/&quot;DkYBQng4fip7ImA9WhdTEUw.&quot;"><id>tag:blogger.com,1999:blog-272429821527780388.post-6673446710590619530</id><published>2011-07-07T21:40:00.000-07:00</published><updated>2011-07-08T01:35:53.636-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-07-08T01:35:53.636-07:00</app:edited><title>x509,pkcs7和Pkcs12之間關係</title><content type="html">&lt;div&gt;&lt;br /&gt;x.509,是x500那套網絡協議（好像是目錄協議吧）的一個子集，專門定義了在目錄訪問中需要身份認證的證書的格式。後來被rfc收錄3280。 &lt;/div&gt;&lt;div&gt;&lt;br /&gt;PKCS#12是“個人信息交換語法”。它可以用來將x.509的證書和證書對應的私鑰打包，進行交換。比如你在windows下，可以將IE裡的證書連帶私鑰導出，並設置一個口令保護。這個pfx格式的文件，就是按照pkcs#12的格式打包的。當然pkcs#12不僅僅只是作以上用途的。它可以用來打包交換任何信息。你可以和張三李四用PKCS#12來交換私人數據，包括x.509證書和私鑰。&lt;br /&gt;你在交換x.509證書和私鑰可以採用任何數據格式，例如PKCS#12。 &lt;/div&gt;&lt;div&gt;&lt;br /&gt;PKCS#7麼，舉個例子，你給張三李四發了一封籤名郵件，同時你將你的個人證書隨郵件一起發給了張三李四，這個時候，你可以按照PKCS#7的格式來打包。&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: arial, sans-serif; "&gt;&lt;span title="" style="background-color: rgb(230, 236, 249); color: rgb(0, 0, 0); "&gt;P7一般是把證書分成兩個文件，一個公鑰一個私鑰，有PEM和DER兩種編碼方式。&lt;/span&gt;&lt;span title=""&gt;PEM比較多見，就是純文本的，P7一般是分發公鑰用，看到的就是一串可見字符串，擴展名經常是.crt,.cer,.key等。 &lt;/span&gt;&lt;span title=""&gt;DER是二進制編碼。&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;P12是把證書壓成一個文件，.pfx 。&lt;/span&gt;&lt;span title=""&gt;主要是考慮分發證書，私鑰是要絕對保密的，不能隨便以文本方式散播。&lt;/span&gt;&lt;span title=""&gt;所以P7格式不適合分發。 &lt;/span&gt;&lt;span title=""&gt;.pfx中可以加密碼保護，所以相對安全些。&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;在實踐中要中，用戶證書都是放在USB Key中分發，服務器證書經常還是以文件方式分發。&lt;/span&gt;&lt;span title=""&gt;服務器證書和用戶證書，都是X509證書，就是裡面的屬性有區別.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;X509 是證書規範&lt;br /&gt;PKCS#7 是消息語法（常用於數字簽名與加密）&lt;br /&gt;PKCS#12 個人消息交換與打包語法（如.PFX .P12）打包成帶公鑰與私鑰&lt;br /&gt;還有其它常用的是PKCS#10 是證書請求語法。&lt;br /&gt;&lt;br /&gt;通過CA產生的出來的證書格式文件一般是以PFX P12格式發布給使用者（公鑰與私鑰），用戶拿到證書後，&lt;br /&gt;可以通過IE來導入或直接雙擊嚮導安裝證書，此時私鑰安裝到系統的私有密鑰庫中。使用時系統會自動查找到&lt;br /&gt;私鑰。而最安全的方式還是使用其它USB硬件來存儲，私鑰將無法再從硬件鎖只導出，並且支持硬件訪問需要&lt;br /&gt;用戶的密鑰才能訪問到硬件內的私鑰，永遠保證了私鑰不出硬件鎖！提高了安全性，靈活性，且可以移動的方便性。如ETOKEN產品，一些硬件信息可參考www.dztech.cn.&lt;br /&gt;而相互雙方通迅時使用且​​交換的是帶公鑰的證書如CER文件。&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;PKI標準可以分為第一代和第二代標準[12]。&lt;br /&gt;&lt;br /&gt;第一代PKI標準主要包括美國RSA公司的公鑰加密標準（Public Key Cryptography Standards，PKCS）系列、國際電信聯盟的ITU-T X.509、IETF組織的公鑰基礎設施X.509（Public Key Infrastructure X .509，PKIX）標準系列、無線應用協議（Wireless Application Protocol ,WAP）論壇的無線公鑰基礎設施（Wireless Public Key Infrastructure，WPKI）標準等。第一代PKI標準主要是基於抽象語法符號（Abstract Syntax Notation One，ASN.1）編碼的，實現比較困難，這也在一定程度上影響了標準的推廣。&lt;br /&gt;第二代PKI標準是在2001年，由微軟、VeriSign和webMethods三家公司發布了XML密鑰管理規範（XML Key Management Specification，XKMS），被稱為第二代PKI標準。 XKMS由兩部分組成：XML密鑰信息服務規範（XML Key Information Service Specification，X-KISS）和XML密鑰註冊服務規範（XML Key Registration Service Specification，X-KRSS）。 X-KISS定義了包含在XML-SIG元素中的用於驗證公鑰信息合法性的信任服務規範；使用X-KISS規範，XML應用程序可通過網絡委託可信的第三方CA處理有關認證簽名、查詢、驗證、綁定公鑰信息等服務。 X-KRSS則定義了一種可通過網絡接受公鑰註冊、撤銷、恢復的服務規範；XML應用程序建立的密鑰對，可通過X-KRSS規範將公鑰部分及其它有關的身份信息發給可信的第三方CA註冊。 X-KISS和X-KRSS規範都按照XML Schema 結構化語言定義，使用簡單對象訪問協議（SOAP V1.1）進行通信，其服務與消息的語法定義遵循Web服務定義語言（WSDL V1.0）。目前XKMS已成為W3C的推薦標準，並已被微軟、VeriSign等公司集成於他們的產品中（微軟已在ASP.net中集成了XKMS，VeriSign已發布了基於Java的信任服務集成工具包TSIK）。&lt;br /&gt;CA中心普遍採用的規範是X.509[13]系列和PKCS系列，其中主要應用到了以下規範：&lt;br /&gt;1． X.209（1988）&lt;br /&gt;ASN.1是描述在網絡上傳輸信息格式的標準方法。它有兩部分：第一部份（ISO 8824/ITU X.208）描述信息內的數據、數據類型及序列格式，也就是數據的語法；第二部分（ISO 8825/ITU X.209）描述如何將各部分數據組成消息，也就是數據的基本編碼規則。&lt;br /&gt;ASN.1原來是作為X.409的一部分而開發的，後來才獨立地成為一個標準。這兩個協議除了在PKI體系中被應用外，還被廣泛應用於通信和計算機的其他領域。&lt;br /&gt;2． X.500（1993）&lt;br /&gt;X.500是一套已經被國際標準化組織（ISO）接受的目錄服務系統標準，它定義了一個機構如何在全局範圍內共享其名字和與之相關的對象。 X.500是層次性的，其中的管理域（機構、分支、部門和工作組）可以提供這些域內的用戶和資源信息。在PKI體系中，X.500被用來惟一標識一個實體，該實體可以是機構、組織、個人或一台服務器。 X.500被認為是實現目錄服務的最佳途徑，但X.​​500的實現需要較大的投資，並且比其他方式速度慢;而其優勢具有信息模型、多功能和開放性。&lt;br /&gt;3． X.509（1993）&lt;br /&gt;X.509是由國際電信聯盟（ITU-T）制定的數字證書標準。在X.500確保用戶名稱惟一性的基礎上，X.509為X.500用戶名稱提供了通信實體的鑑別機制，並規定了實體鑑別過程中廣泛適用的證書語法和數據接口。&lt;br /&gt;X.509的最初版本公佈於1988年。 X.509證書由用戶公共密鑰和用戶標識符組成。此外還包括版本號、證書序列號、CA標識符、簽名算法標識、簽發者名稱、證書有效期等信息。這一標準的最新版本是X.509 v3，它定義了包含擴展信息的數字證書。該版數字證書提供了一個擴展信息字段，用來提供更多的靈活性及特殊應用環境下所需的信息傳送。&lt;br /&gt;4． PKCS系列標準&lt;br /&gt;PKCS是由美國RSA數據安全公司及其合作夥伴制定的一組公鑰密碼學標準，其中包括證書申請、證書更新、證書作廢表發布、擴展證書內容以及數字簽名、數字信封的格式等方面的一系列相關協議。到1999年底，PKCS已經公佈了以下標準：&lt;br /&gt;PKCS#1：定義RSA公開密鑰算法加密和簽名機制，主要用於組織PKCS#7中所描述的數字簽名和數字信封。&lt;br /&gt;PKCS#3：定義Diffie-Hellman密鑰交換協議。&lt;br /&gt;PKCS#5：描述一種利用從口令派生出來的安全密鑰加密字符串的方法。使用MD2或MD5 從口令中派生密鑰，並採用DES-CBC模式加密。主要用於加密從一個計算機傳送到另一個計算機的私人密鑰，不能用於加密消息。&lt;br /&gt;PKCS#6：描述了公鑰證書的標準語法，主要描述X.509證書的擴展格式。&lt;br /&gt;PKCS#7：定義一種通用的消息語法，包括數字簽名和加密等用於增強的加密機制，PKCS#7與PEM兼容，所以不需其他密碼操作，就可以將加密的消息轉換成PEM消息。&lt;br /&gt;PKCS#8：描述私有密鑰信息格式，該信息包括公開密鑰算法的私有密鑰以及可選的屬性集等。&lt;br /&gt;PKCS#9：定義一些用於PKCS#6證書擴展、PKCS#7數字簽名和PKCS#8私鑰加密信息的屬性類型。&lt;br /&gt;PKCS#10：描述證書請求語法。&lt;br /&gt;PKCS#11：稱為Cyptoki，定義了一套獨立於技術的程序設計接口，用於智能卡和PCMCIA卡之類的加密設備。&lt;br /&gt;PKCS#12：描述個人信息交換語法標準。描述了將用戶公鑰、私鑰、證書和其他相關信息打包的語法。&lt;br /&gt;PKCS#13：橢圓曲線密碼體制標準。&lt;br /&gt;PKCS#14：偽隨機數生成標準。&lt;br /&gt;PKCS#15：密碼令牌信息格式標準。&lt;br /&gt;5． OCSP在線證書狀態協議&lt;br /&gt;OCSP（Online Certificate Status Protocol）[14]是IETF頒布的用於檢查數字證書在某一交易時刻是否仍然有效的標準。該標準提供給PKI用戶一條方便快捷的數字證書狀態查詢通道，使PKI體系能夠更有效、更安全地在各個領域中被廣泛應用。&lt;br /&gt;6． LDAP 輕量級目錄訪問協議&lt;br /&gt;LDAP規範（RFC1487）簡化了笨重的X.500目錄訪問協議，並且在功能性、數據表示、編碼和傳輸方面都進行了相應的修改。 1997年，LDAP第3版本成為互聯網標準。目前，LDAP v3已經在PKI體系中被廣泛應用於證書信息發布、CRL信息發布、CA政策以及與信息發布相關的各個方面。&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;source: &lt;/div&gt;&lt;div&gt;&lt;a href="http://topic.csdn.net/u/20071015/18/37a2bffb-2354-493e-b5a9-b96ab28063ae.html"&gt;http://topic.csdn.net/u/20071015/18/37a2bffb-2354-493e-b5a9-b96ab28063ae.html&lt;/a&gt;&lt;/div&gt;&lt;div&gt;&lt;a href="http://hi.baidu.com/twmp/blog/item/661e9e3fa78764c97d1e71d1.html"&gt;http://hi.baidu.com/twmp/blog/item/661e9e3fa78764c97d1e71d1.html&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/272429821527780388-6673446710590619530?l=codestandup.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/qEdEkP60-RW_bnqlv2FiRCKmTBY/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/qEdEkP60-RW_bnqlv2FiRCKmTBY/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/qEdEkP60-RW_bnqlv2FiRCKmTBY/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/qEdEkP60-RW_bnqlv2FiRCKmTBY/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Code-standup/~4/k_WMUgPaWqc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://codestandup.blogspot.com/feeds/6673446710590619530/comments/default" title="張貼意見" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=272429821527780388&amp;postID=6673446710590619530" title="0 個意見" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/272429821527780388/posts/default/6673446710590619530?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/272429821527780388/posts/default/6673446710590619530?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Code-standup/~3/k_WMUgPaWqc/x509pkcs7pkcs12.html" title="x509,pkcs7和Pkcs12之間關係" /><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14778696620700587607" /></author><thr:total>0</thr:total><feedburner:origLink>http://codestandup.blogspot.com/2011/07/x509pkcs7pkcs12.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CE8ER3g5cSp7ImA9WhZaFEQ.&quot;"><id>tag:blogger.com,1999:blog-272429821527780388.post-5830703976652903774</id><published>2011-06-30T20:53:00.000-07:00</published><updated>2011-06-30T21:00:06.629-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-06-30T21:00:06.629-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><title>JAVA和C＃3DES加密解密</title><content type="html">&lt;span class="Apple-style-span"&gt;&lt;p style="margin-top: 5px; margin-right: auto; margin-left: auto; margin-bottom: 5px; text-indent: 0px; "&gt;&lt;span class="Apple-style-span"&gt;&lt;span title="" style="background-color: rgb(230, 236, 249); color: rgb(0, 0, 0); "&gt;一個項目.net 要調用JAVA的WEB&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;SERVICE，數據採用3DES加密，涉及到兩種語言3DES一致性的問題，&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;下面分享一下，&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;這裡的KEY採用Base64編碼，便用分發，因為Java的Byte範圍為-128至127，c#的Byte範圍是0-255&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;核心是確定Mode和Padding，關於這兩個的意思可以搜索3DES算法相關文章&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;一個是C#採用CBC&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;Mode，PKCS7 Padding,Java採用CBC Mode，PKCS5Padding Padding,&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;另一個是C#採用ECB&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;Mode，PKCS7 Padding,Java採用ECB Mode，PKCS5Padding&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;Padding,&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;Java的ECB模式不需要IV&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;對字符加密時，雙方採用的都是UTF-8編碼.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin-top: 5px; margin-right: auto; margin-left: auto; margin-bottom: 5px; text-indent: 0px; "&gt;&lt;span class="Apple-style-span"&gt;&lt;span title=""&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="margin-top: 5px; margin-right: auto; margin-left: auto; margin-bottom: 5px; text-indent: 0px; "&gt;&lt;span class="Apple-style-span"&gt;&lt;span title=""&gt;&lt;span title="主要差异如下：" style="background-color: rgb(255, 255, 255); "&gt;&lt;b&gt;主要差異如下： &lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title="1、 对于待加密解密的数据，各自的填充模式不一样" style="background-color: rgb(255, 255, 255); "&gt;1、 對於待加密解密的數據，各自的填充模式不一樣&lt;br /&gt;     &lt;/span&gt;&lt;span title="C#的模式有：ANSIX923、ISO10126、None、PKCS7、Zero，而Java有：NoPadding、PKCS5Padding、SSL3Padding" style="background-color: rgb(255, 255, 255); "&gt;C#的模式有：ANSIX923、ISO10126、None、PKCS7、Zero，而Java有：NoPadding、PKCS5Padding、SSL3Padding&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title="2、 各自默认的3DES实现，模式和填充方式不一样" style="background-color: rgb(255, 255, 255); "&gt;2、 各自默認的3DES實現，模式和填充方式不一樣&lt;br /&gt;&lt;/span&gt;&lt;span title="C#的默认模式为CBC,默认填充方式为PKCS7; java的默认模式为ECB，默认填充方式为PKCS5Padding" style="background-color: rgb(255, 255, 255); "&gt;C#的默認模式為CBC,默認填充方式為PKCS7; java的默認模式為ECB，默認填充方式為PKCS5Padding&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title="3、 各自的key的size不一样"&gt;3、 各自的key的size不一樣&lt;br /&gt;&lt;/span&gt;&lt;span title="C#中key的size为16和24均可；java中要求key的size必须为24；对于CBC模式下的向量iv的size两者均要求必须为8" style="background-color: rgb(255, 255, 255); "&gt;C#中key的size為16和24均可；java中要求key的size必須為24；對於CBC模式下的向量iv的size兩者均要求必須為8&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title="翻看了3DES的原理："&gt;翻看了3DES的原理：&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title="DES主要采用替换和移位的方法,用56位密钥对64位二进制数据块进行加密,每次加密可对64位的输入数据进行16轮编码,"&gt;DES主要採用替換和移位的方法,用56位密鑰對64位二進制數據塊進行加密,每次加密可對64位的輸入數據進行16輪編碼,&lt;br /&gt;&lt;/span&gt;&lt;span title="经一系列替换和移位后,输入的64位转换成安全不同的64的输出数据." style="background-color: rgb(255, 255, 255); "&gt;經一系列替換和移位後,輸入的64位轉換成安全不同的64的輸出數據.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title="3DES:是在DES的基础上采用三重DES,即用两个56位的密钥K1,K2,发送方用K1加密,K2解密,再使用K1加密.接收方使用K1解密,K2加密,再使用"&gt;3DES:是在DES的基礎上採用三重DES,即用兩個56位的密鑰K1,K2,發送方用K1加密,K2解密,再使用K1加密.接收方使用K1解密,K2加密,再使用&lt;/span&gt;&lt;span title="K1解密,"&gt;K1解密,&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title="其效果相当于密钥长度加倍."&gt;其效果相當於密鑰長度加倍.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title="于是尝试在java中，对key进行补位，即用前8个字节作为byte[24] 中的byte[16]~byte[23];发现与c#中加密的结果相同！"&gt;於是嘗試在java中，對key進行補位，即用前8個字節作為byte[24] 中的byte[16]~byte[23];發現與c#中加密的結果相同！&lt;/span&gt;&lt;span title="于是大胆假设C#中可能是检查key的size为16的时候" style="background-color: rgb(255, 255, 255); "&gt;於是大膽假設C#中可能是檢查key的size為16的時候&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title="自动将前8个字节作为k3进行了补位，而java没有实现这一点（因为java的3DES算法中强制要求key的size必须为24）。"&gt;自動將前8個字節作為k3進行了補位，而java沒有實現這一點（因為java的3DES算法中強制要求key的size必須為24）。&lt;/span&gt;&lt;span title="这样的情况下，可能就是发送方用k1加密、k2解密、k3再加密；接受方k3解密、k2加密、再k1解密来实现。" style="background-color: rgb(255, 255, 255); "&gt;這樣的情況下，可能就是發送方用k1加密、k2解密、k3再加密；接受方k3解密、k2加密、再k1解密來實現。&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title="最终经过编码验证，确认key大小为24时，java和c#的加密解密结果相一致。" style="background-color: rgb(255, 255, 255); "&gt;最終經過編碼驗證，確認key大小為24時，java和c#的加密解密結果相一致。&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title="Java中实现时，只要注意对大小不足24的key进行补位，和采用CBC模式，填充模式为PKCS5Padding即可。" style="background-color: rgb(255, 255, 255); "&gt;Java中實現時，只要注意對大小不足24的key進行補位，和採用CBC模式，填充模式為PKCS5Padding即可。&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title="还有一种让Java和.Net兼容的方式,在.Net中指定模式为ECB，填充为PKCS7,然后在Java中采用其默认的模式（DESede/ECB/PKCS5Padding）即可,注意双方约定key的size" style="background-color: rgb(255, 255, 255); "&gt;還有一種讓Java和.Net兼容的方式,在.Net中指定模式為ECB，填充為PKCS7,然後在Java中採用其默認的模式（DESede/ECB/PKCS5Padding）即可,注意雙方約定key的size&lt;/span&gt;&lt;span title="为24个字节。"&gt;為24個字節。&lt;/span&gt;&lt;span title="建议双方对key以base64编码字符串进行告知，因为java和.net中byte字节的范围不相同(前者-128~127,后者0~255)，避免不必要的处理。" style="background-color: rgb(255, 255, 255); "&gt;建議雙方對key以base64編碼字符串進行告知，因為java和.net中byte字節的範圍不相同(前者-128~127,後者0~255)，避免不必要的處理。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: Arial; font-size: 14px; line-height: 25px; margin-top: 5px; margin-right: auto; margin-left: auto; margin-bottom: 5px; text-indent: 0px; "&gt;&lt;span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 16px; line-height: normal; "&gt;&lt;span title="Click for alternate translations" class=""&gt;&lt;span title="Click for alternate translations" class=""&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style="font-family: Arial; font-size: 14px; line-height: 25px; margin-top: 5px; margin-right: auto; margin-left: auto; margin-bottom: 5px; text-indent: 0px; "&gt;&lt;b&gt;下面是C#代码&lt;/b&gt;&lt;/p&gt;&lt;p style="font-family: Arial; font-size: 14px; line-height: 25px; margin-top: 5px; margin-right: auto; margin-left: auto; margin-bottom: 5px; text-indent: 0px; "&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="font-family: Arial; font-size: 14px; line-height: 25px; margin-top: 5px; margin-right: auto; margin-left: auto; margin-bottom: 5px; text-indent: 0px; "&gt;&lt;/p&gt;&lt;div class="cnblogs_code" style="line-height: 25px; background-color: rgb(245, 245, 245); font-family: 'Courier New'; font-size: 13px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-bottom-color: rgb(204, 204, 204); border-left-color: rgb(204, 204, 204); padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; word-break: break-all; overflow-x: auto; overflow-y: auto; "&gt;&lt;div&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;  &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;///&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;summary&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;///&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; DES3加密解密&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;///&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;/span&gt;&lt;/summary&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;    &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;public&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;class&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; Des3&lt;br /&gt;  {&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;#region&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; CBC模式**&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;///&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;summary&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;///&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; DES3 CBC模式加密&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;///&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;/span&gt;&lt;/summary&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;///&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;param name="key"&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;密钥&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;///&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;param name="iv"&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;IV&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;///&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;param name="data"&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;明文的byte数组&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;///&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;returns&gt;&lt;/returns&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;密文的byte数组&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;        &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;public&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;static&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] Des3EncodeCBC( &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] key, &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] iv, &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] data )&lt;br /&gt;      {&lt;br /&gt;          &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;//&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;复制于MSDN&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;&lt;br /&gt;          &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;try&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;&lt;br /&gt;          {&lt;br /&gt;              &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;//&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; Create a MemoryStream.&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;                MemoryStream mStream &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;new&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; MemoryStream();&lt;br /&gt;&lt;br /&gt;              TripleDESCryptoServiceProvider tdsp &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;new&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; TripleDESCryptoServiceProvider();&lt;br /&gt;              tdsp.Mode &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; CipherMode.CBC;             &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;//&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;默认值&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;                tdsp.Padding &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; PaddingMode.PKCS7;       &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;//&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;默认值&lt;br /&gt;&lt;br /&gt;              &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;//&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; Create a CryptoStream using the MemoryStream&lt;br /&gt;              &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;//&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; and the passed key and initialization vector (IV).&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;                CryptoStream cStream &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;new&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; CryptoStream( mStream,&lt;br /&gt;                  tdsp.CreateEncryptor( key, iv ),&lt;br /&gt;                  CryptoStreamMode.Write );&lt;br /&gt;&lt;br /&gt;              &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;//&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; Write the byte array to the crypto stream and flush it.&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;                cStream.Write( data, &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 0, 128); "&gt;0&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;, data.Length );&lt;br /&gt;              cStream.FlushFinalBlock();&lt;br /&gt;&lt;br /&gt;              &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;//&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; Get an array of bytes from the&lt;br /&gt;              &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;//&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; MemoryStream that holds the&lt;br /&gt;              &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;//&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; encrypted data.&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;                &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] ret &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; mStream.ToArray();&lt;br /&gt;&lt;br /&gt;              &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;//&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; Close the streams.&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;                cStream.Close();&lt;br /&gt;              mStream.Close();&lt;br /&gt;&lt;br /&gt;              &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;//&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; Return the encrypted buffer.&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;                &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;return&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; ret;&lt;br /&gt;          }&lt;br /&gt;          &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;catch&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; ( CryptographicException e )&lt;br /&gt;          {&lt;br /&gt;              Console.WriteLine( &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 0, 0); "&gt;A Cryptographic error occurred: {0}&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;, e.Message );&lt;br /&gt;              &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;return&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;null&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;;&lt;br /&gt;          }&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;///&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;summary&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;///&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; DES3 CBC模式解密&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;///&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;/span&gt;&lt;/summary&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;///&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;param name="key"&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;密钥&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;///&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;param name="iv"&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;IV&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;///&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;param name="data"&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;密文的byte数组&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;///&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;returns&gt;&lt;/returns&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;明文的byte数组&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;        &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;public&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;static&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] Des3DecodeCBC( &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] key, &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] iv, &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] data )&lt;br /&gt;      {&lt;br /&gt;          &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;try&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;&lt;br /&gt;          {&lt;br /&gt;              &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;//&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; Create a new MemoryStream using the passed&lt;br /&gt;              &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;//&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; array of encrypted data.&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;                MemoryStream msDecrypt &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;new&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; MemoryStream( data );&lt;br /&gt;&lt;br /&gt;              TripleDESCryptoServiceProvider tdsp &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;new&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; TripleDESCryptoServiceProvider();&lt;br /&gt;              tdsp.Mode &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; CipherMode.CBC;&lt;br /&gt;              tdsp.Padding &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; PaddingMode.PKCS7;&lt;br /&gt;&lt;br /&gt;              &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;//&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; Create a CryptoStream using the MemoryStream&lt;br /&gt;              &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;//&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; and the passed key and initialization vector (IV).&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;                CryptoStream csDecrypt &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;new&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; CryptoStream( msDecrypt,&lt;br /&gt;                  tdsp.CreateDecryptor( key, iv ),&lt;br /&gt;                  CryptoStreamMode.Read );&lt;br /&gt;&lt;br /&gt;              &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;//&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; Create buffer to hold the decrypted data.&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;                &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] fromEncrypt &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;new&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[data.Length];&lt;br /&gt;&lt;br /&gt;              &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;//&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; Read the decrypted data out of the crypto stream&lt;br /&gt;              &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;//&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; and place it into the temporary buffer.&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;                csDecrypt.Read( fromEncrypt, &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 0, 128); "&gt;0&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;, fromEncrypt.Length );&lt;br /&gt;&lt;br /&gt;              &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;//&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;Convert the buffer into a string and return it.&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;                &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;return&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; fromEncrypt;&lt;br /&gt;          }&lt;br /&gt;          &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;catch&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; ( CryptographicException e )&lt;br /&gt;          {&lt;br /&gt;              Console.WriteLine( &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 0, 0); "&gt;A Cryptographic error occurred: {0}&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;, e.Message );&lt;br /&gt;              &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;return&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;null&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;;&lt;br /&gt;          }&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;#endregion&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;#region&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; ECB模式&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;///&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;summary&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;///&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; DES3 ECB模式加密&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;///&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;/span&gt;&lt;/summary&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;///&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;param name="key"&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;密钥&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;///&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;param name="iv"&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;IV(当模式为ECB时，IV无用)&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;///&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;param name="str"&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;明文的byte数组&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;///&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;returns&gt;&lt;/returns&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;密文的byte数组&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;        &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;public&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;static&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] Des3EncodeECB( &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] key, &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] iv, &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] data )&lt;br /&gt;      {&lt;br /&gt;          &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;try&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;&lt;br /&gt;          {&lt;br /&gt;              &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;//&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; Create a MemoryStream.&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;                MemoryStream mStream &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;new&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; MemoryStream();&lt;br /&gt;&lt;br /&gt;              TripleDESCryptoServiceProvider tdsp &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;new&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; TripleDESCryptoServiceProvider();&lt;br /&gt;              tdsp.Mode &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; CipherMode.ECB;&lt;br /&gt;              tdsp.Padding &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; PaddingMode.PKCS7;&lt;br /&gt;              &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;//&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; Create a CryptoStream using the MemoryStream&lt;br /&gt;              &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;//&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; and the passed key and initialization vector (IV).&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;                CryptoStream cStream &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;new&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; CryptoStream( mStream,&lt;br /&gt;                  tdsp.CreateEncryptor( key, iv ),&lt;br /&gt;                  CryptoStreamMode.Write );&lt;br /&gt;&lt;br /&gt;              &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;//&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; Write the byte array to the crypto stream and flush it.&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;                cStream.Write( data, &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 0, 128); "&gt;0&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;, data.Length );&lt;br /&gt;              cStream.FlushFinalBlock();&lt;br /&gt;&lt;br /&gt;              &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;//&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; Get an array of bytes from the&lt;br /&gt;              &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;//&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; MemoryStream that holds the&lt;br /&gt;              &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;//&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; encrypted data.&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;                &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] ret &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; mStream.ToArray();&lt;br /&gt;&lt;br /&gt;              &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;//&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; Close the streams.&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;                cStream.Close();&lt;br /&gt;              mStream.Close();&lt;br /&gt;&lt;br /&gt;              &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;//&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; Return the encrypted buffer.&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;                &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;return&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; ret;&lt;br /&gt;          }&lt;br /&gt;          &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;catch&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; ( CryptographicException e )&lt;br /&gt;          {&lt;br /&gt;              Console.WriteLine( &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 0, 0); "&gt;A Cryptographic error occurred: {0}&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;, e.Message );&lt;br /&gt;              &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;return&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;null&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;;&lt;br /&gt;          }&lt;br /&gt;&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;///&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;summary&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;///&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; DES3 ECB模式解密&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;///&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;/span&gt;&lt;/summary&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;///&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;param name="key"&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;密钥&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;///&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;param name="iv"&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;IV(当模式为ECB时，IV无用)&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;///&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;param name="str"&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;密文的byte数组&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;///&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;returns&gt;&lt;/returns&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;明文的byte数组&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;        &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;public&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;static&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] Des3DecodeECB( &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] key, &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] iv, &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] data )&lt;br /&gt;      {&lt;br /&gt;          &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;try&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;&lt;br /&gt;          {&lt;br /&gt;              &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;//&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; Create a new MemoryStream using the passed&lt;br /&gt;              &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;//&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; array of encrypted data.&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;                MemoryStream msDecrypt &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;new&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; MemoryStream( data );&lt;br /&gt;&lt;br /&gt;              TripleDESCryptoServiceProvider tdsp &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;new&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; TripleDESCryptoServiceProvider();&lt;br /&gt;              tdsp.Mode &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; CipherMode.ECB;&lt;br /&gt;              tdsp.Padding &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; PaddingMode.PKCS7;&lt;br /&gt;&lt;br /&gt;              &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;//&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; Create a CryptoStream using the MemoryStream&lt;br /&gt;              &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;//&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; and the passed key and initialization vector (IV).&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;                CryptoStream csDecrypt &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;new&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; CryptoStream( msDecrypt,&lt;br /&gt;                  tdsp.CreateDecryptor( key, iv ),&lt;br /&gt;                  CryptoStreamMode.Read );&lt;br /&gt;&lt;br /&gt;              &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;//&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; Create buffer to hold the decrypted data.&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;                &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] fromEncrypt &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;new&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[data.Length];&lt;br /&gt;&lt;br /&gt;              &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;//&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; Read the decrypted data out of the crypto stream&lt;br /&gt;              &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;//&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; and place it into the temporary buffer.&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;                csDecrypt.Read( fromEncrypt, &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 0, 128); "&gt;0&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;, fromEncrypt.Length );&lt;br /&gt;&lt;br /&gt;              &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;//&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;Convert the buffer into a string and return it.&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;                &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;return&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; fromEncrypt;&lt;br /&gt;          }&lt;br /&gt;          &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;catch&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; ( CryptographicException e )&lt;br /&gt;          {&lt;br /&gt;              Console.WriteLine( &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 0, 0); "&gt;A Cryptographic error occurred: {0}&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;, e.Message );&lt;br /&gt;              &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;return&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;null&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;;&lt;br /&gt;          }&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;#endregion&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;///&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;summary&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;///&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; 类测试&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;///&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;/span&gt;&lt;/summary&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;        &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;public&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;static&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;void&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; Test()&lt;br /&gt;      {&lt;br /&gt;          System.Text.Encoding utf8 &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; System.Text.Encoding.UTF8;&lt;br /&gt;&lt;br /&gt;          &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;//&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;key为abcdefghijklmnopqrstuvwx的Base64编码&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;            &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] key &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; Convert.FromBase64String( &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 0, 0); "&gt;YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; );&lt;br /&gt;          &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] iv &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;new&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] { &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 0, 128); "&gt;1&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;, &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 0, 128); "&gt;2&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;, &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 0, 128); "&gt;3&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;, &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 0, 128); "&gt;4&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;, &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 0, 128); "&gt;5&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;, &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 0, 128); "&gt;6&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;, &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 0, 128); "&gt;7&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;, &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 0, 128); "&gt;8&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; };      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;//&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;当模式为ECB时，IV无用&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;            &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] data &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; utf8.GetBytes( &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 0, 0); "&gt;中国ABCabc123&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; );&lt;br /&gt;&lt;br /&gt;          System.Console.WriteLine( &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 0, 0); "&gt;ECB模式:&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; );&lt;br /&gt;          &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] str1 &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; Des3.Des3EncodeECB( key, iv, data );&lt;br /&gt;          &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] str2 &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; Des3.Des3DecodeECB( key, iv, str1 );&lt;br /&gt;          System.Console.WriteLine( Convert.ToBase64String( str1 ) );&lt;br /&gt;          System.Console.WriteLine( System.Text.Encoding.UTF8.GetString( str2 ) );&lt;br /&gt;&lt;br /&gt;          System.Console.WriteLine();&lt;br /&gt;&lt;br /&gt;          System.Console.WriteLine( &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 0, 0); "&gt;CBC模式:&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; );&lt;br /&gt;          &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] str3 &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; Des3.Des3EncodeCBC( key, iv, data );&lt;br /&gt;          &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] str4 &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; Des3.Des3DecodeCBC( key, iv, str3 );&lt;br /&gt;          System.Console.WriteLine( Convert.ToBase64String( str3 ) );&lt;br /&gt;          System.Console.WriteLine( utf8.GetString( str4 ) );&lt;br /&gt;&lt;br /&gt;          System.Console.WriteLine();&lt;br /&gt;&lt;br /&gt;      }&lt;br /&gt;&lt;br /&gt;  }&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style="font-family: Arial; font-size: 14px; line-height: 25px; margin-top: 5px; margin-right: auto; margin-left: auto; margin-bottom: 5px; text-indent: 0px; "&gt; &lt;/p&gt;&lt;p style="font-family: Arial; font-size: 14px; line-height: 25px; margin-top: 5px; margin-right: auto; margin-left: auto; margin-bottom: 5px; text-indent: 0px; "&gt; &lt;/p&gt;&lt;p style="font-family: Arial; font-size: 14px; line-height: 25px; margin-top: 5px; margin-right: auto; margin-left: auto; margin-bottom: 5px; text-indent: 0px; "&gt; &lt;/p&gt;&lt;p style="font-family: Arial; font-size: 14px; line-height: 25px; margin-top: 5px; margin-right: auto; margin-left: auto; margin-bottom: 5px; text-indent: 0px; "&gt;接着是Java代码&lt;/p&gt;&lt;p style="font-family: Arial; font-size: 14px; line-height: 25px; margin-top: 5px; margin-right: auto; margin-left: auto; margin-bottom: 5px; text-indent: 0px; "&gt; &lt;/p&gt;&lt;div class="cnblogs_code" style="line-height: 25px; background-color: rgb(245, 245, 245); font-family: 'Courier New'; font-size: 13px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-bottom-color: rgb(204, 204, 204); border-left-color: rgb(204, 204, 204); padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; word-break: break-all; overflow-x: auto; overflow-y: auto; "&gt;&lt;div&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;import&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; java.security.Key;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;import&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; javax.crypto.Cipher;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;import&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; javax.crypto.SecretKeyFactory;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;import&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; javax.crypto.spec.DESedeKeySpec;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;import&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; javax.crypto.spec.IvParameterSpec;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;import&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; sun.misc.BASE64Decoder;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;import&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; sun.misc.BASE64Encoder;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;public&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;class&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; Des3 {&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;public&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;static&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;void&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; main(String[] args) &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;throws&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; Exception {&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] key&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;new&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; BASE64Decoder().decodeBuffer(&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;YWJjZGVmZ2hpamtsbW5vcHFyc3R1dnd4&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;);&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] keyiv &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; { &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;1&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;, &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;2&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;, &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;3&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;, &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;4&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;, &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;5&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;, &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;6&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;, &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;7&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;, &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;8&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; };&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] data&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;中国ABCabc123&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;.getBytes(&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;UTF-8&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;);&lt;br /&gt;   &lt;br /&gt;      System.out.println(&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;ECB加密解密&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;);&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] str3 &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; des3EncodeECB(key,data );&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] str4 &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; ees3DecodeECB(key, str3);&lt;br /&gt;      System.out.println(&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;new&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; BASE64Encoder().encode(str3));&lt;br /&gt;      System.out.println(&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;new&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; String(str4, &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;UTF-8&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;));&lt;br /&gt;&lt;br /&gt;      System.out.println();&lt;br /&gt;&lt;br /&gt;      System.out.println(&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;CBC加密解密&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;);&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] str5 &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; des3EncodeCBC(key, keyiv, data);&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] str6 &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; des3DecodeCBC(key, keyiv, str5);&lt;br /&gt;      System.out.println(&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;new&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; BASE64Encoder().encode(str5));&lt;br /&gt;      System.out.println(&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;new&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; String(str6, &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;UTF-8&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;));&lt;br /&gt;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;/**&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;   * ECB加密,不要IV&lt;br /&gt;   * &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;@param&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; key 密钥&lt;br /&gt;   * &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;@param&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; data 明文&lt;br /&gt;   * &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;@return&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; Base64编码的密文&lt;br /&gt;   * &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;@throws&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; Exception&lt;br /&gt;   &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;*/&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;public&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;static&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] des3EncodeECB(&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] key, &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] data)&lt;br /&gt;          &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;throws&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; Exception {&lt;br /&gt;&lt;br /&gt;      Key deskey &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;null&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;;&lt;br /&gt;      DESedeKeySpec spec &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;new&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; DESedeKeySpec(key);&lt;br /&gt;      SecretKeyFactory keyfactory &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; SecretKeyFactory.getInstance(&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;desede&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;);&lt;br /&gt;      deskey &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; keyfactory.generateSecret(spec);&lt;br /&gt;&lt;br /&gt;      Cipher cipher &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; Cipher.getInstance(&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;desede&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;+&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;/ECB/PKCS5Padding&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;);&lt;br /&gt;&lt;br /&gt;      cipher.init(Cipher.ENCRYPT_MODE, deskey);&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] bOut &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; cipher.doFinal(data);&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;return&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; bOut;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;/**&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;   * ECB解密,不要IV&lt;br /&gt;   * &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;@param&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; key 密钥&lt;br /&gt;   * &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;@param&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; data Base64编码的密文&lt;br /&gt;   * &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;@return&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; 明文&lt;br /&gt;   * &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;@throws&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; Exception&lt;br /&gt;   &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;*/&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;public&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;static&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] ees3DecodeECB(&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] key, &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] data)&lt;br /&gt;          &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;throws&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; Exception {&lt;br /&gt;&lt;br /&gt;      Key deskey &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;null&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;;&lt;br /&gt;      DESedeKeySpec spec &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;new&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; DESedeKeySpec(key);&lt;br /&gt;      SecretKeyFactory keyfactory &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; SecretKeyFactory.getInstance(&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;desede&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;);&lt;br /&gt;      deskey &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; keyfactory.generateSecret(spec);&lt;br /&gt;&lt;br /&gt;      Cipher cipher &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; Cipher.getInstance(&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;desede&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;+&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;/ECB/PKCS5Padding&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;);&lt;br /&gt;&lt;br /&gt;      cipher.init(Cipher.DECRYPT_MODE, deskey);&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] bOut &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; cipher.doFinal(data);&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;return&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; bOut;&lt;br /&gt;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;/**&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;   * CBC加密&lt;br /&gt;   * &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;@param&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; key 密钥&lt;br /&gt;   * &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;@param&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; keyiv IV&lt;br /&gt;   * &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;@param&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; data 明文&lt;br /&gt;   * &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;@return&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; Base64编码的密文&lt;br /&gt;   * &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;@throws&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; Exception&lt;br /&gt;   &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;*/&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;public&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;static&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] des3EncodeCBC(&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] key, &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] keyiv, &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] data)&lt;br /&gt;          &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;throws&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; Exception {&lt;br /&gt;&lt;br /&gt;      Key deskey &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;null&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;;&lt;br /&gt;      DESedeKeySpec spec &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;new&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; DESedeKeySpec(key);&lt;br /&gt;      SecretKeyFactory keyfactory &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; SecretKeyFactory.getInstance(&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;desede&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;);&lt;br /&gt;      deskey &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; keyfactory.generateSecret(spec);&lt;br /&gt;&lt;br /&gt;      Cipher cipher &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; Cipher.getInstance(&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;desede&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;+&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;/CBC/PKCS5Padding&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;);&lt;br /&gt;      IvParameterSpec ips &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;new&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; IvParameterSpec(keyiv);&lt;br /&gt;      cipher.init(Cipher.ENCRYPT_MODE, deskey, ips);&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] bOut &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; cipher.doFinal(data);&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;return&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; bOut;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;/**&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;&lt;br /&gt;   * CBC解密&lt;br /&gt;   * &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;@param&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; key 密钥&lt;br /&gt;   * &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;@param&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; keyiv IV&lt;br /&gt;   * &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;@param&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; data Base64编码的密文&lt;br /&gt;   * &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;@return&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; 明文&lt;br /&gt;   * &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(128, 128, 128); "&gt;@throws&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt; Exception&lt;br /&gt;   &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 128, 0); "&gt;*/&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;&lt;br /&gt;  &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;public&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;static&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] des3DecodeCBC(&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] key, &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] keyiv, &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] data)&lt;br /&gt;          &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;throws&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; Exception {&lt;br /&gt;&lt;br /&gt;      Key deskey &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;null&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;;&lt;br /&gt;      DESedeKeySpec spec &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;new&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; DESedeKeySpec(key);&lt;br /&gt;      SecretKeyFactory keyfactory &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; SecretKeyFactory.getInstance(&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;desede&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;);&lt;br /&gt;      deskey &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; keyfactory.generateSecret(spec);&lt;br /&gt;&lt;br /&gt;      Cipher cipher &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; Cipher.getInstance(&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;desede&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;+&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;/CBC/PKCS5Padding&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;);&lt;br /&gt;      IvParameterSpec ips &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;new&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; IvParameterSpec(keyiv);&lt;br /&gt;&lt;br /&gt;      cipher.init(Cipher.DECRYPT_MODE, deskey, ips);&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;byte&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;[] bOut &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; cipher.doFinal(data);&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 255); "&gt;return&lt;/span&gt;&lt;span style="font-family: 'Courier New'; color: rgb(0, 0, 0); "&gt; bOut;&lt;br /&gt;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;p style="font-family: Arial; font-size: 14px; line-height: 25px; margin-top: 5px; margin-right: auto; margin-left: auto; margin-bottom: 5px; text-indent: 0px; "&gt; &lt;/p&gt;&lt;p style="font-family: Arial; font-size: 14px; line-height: 25px; margin-top: 5px; margin-right: auto; margin-left: auto; margin-bottom: 5px; text-indent: 0px; "&gt; &lt;/p&gt;&lt;p style="font-family: Arial; font-size: 14px; line-height: 25px; margin-top: 5px; margin-right: auto; margin-left: auto; margin-bottom: 5px; text-indent: 0px; "&gt;下面是运行结果&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;ECB模式:&lt;br /&gt;rmWB4+r9Ug93WI0KAEuMig==&lt;br /&gt;中国ABCabc123&lt;br /&gt;&lt;br /&gt;CBC模式:&lt;br /&gt;4aabWF8UFour/vNfnzJrjw==&lt;br /&gt;中国ABCabc123&lt;/p&gt;&lt;p style="font-family: Arial; font-size: 14px; line-height: 25px; margin-top: 5px; margin-right: auto; margin-left: auto; margin-bottom: 5px; text-indent: 0px; "&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="font-family: Arial; font-size: 14px; line-height: 25px; margin-top: 5px; margin-right: auto; margin-left: auto; margin-bottom: 5px; text-indent: 0px; "&gt;source: &lt;/p&gt;&lt;p style="font-family: Arial; font-size: 14px; line-height: 25px; margin-top: 5px; margin-right: auto; margin-left: auto; margin-bottom: 5px; text-indent: 0px; "&gt;&lt;a href="http://www.cnblogs.com/neil-zhao/archive/2011/06/01/2066058.html"&gt;http://www.cnblogs.com/neil-zhao/archive/2011/06/01/2066058.html&lt;/a&gt;&lt;/p&gt;&lt;p style="font-family: Arial; font-size: 14px; line-height: 25px; margin-top: 5px; margin-right: auto; margin-left: auto; margin-bottom: 5px; text-indent: 0px; "&gt;&lt;a href="http://gaoge2000.blog.hexun.com/18731819_d.html"&gt;http://gaoge2000.blog.hexun.com/18731819_d.html&lt;/a&gt;&lt;/p&gt;&lt;p style="font-family: Arial; font-size: 14px; line-height: 25px; "&gt;&lt;/p&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/272429821527780388-5830703976652903774?l=codestandup.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/8whKRFWkVPsFR07NFts52KDMtHs/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/8whKRFWkVPsFR07NFts52KDMtHs/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/8whKRFWkVPsFR07NFts52KDMtHs/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/8whKRFWkVPsFR07NFts52KDMtHs/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Code-standup/~4/BlufvEk5ZY8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://codestandup.blogspot.com/feeds/5830703976652903774/comments/default" title="張貼意見" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=272429821527780388&amp;postID=5830703976652903774" title="0 個意見" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/272429821527780388/posts/default/5830703976652903774?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/272429821527780388/posts/default/5830703976652903774?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Code-standup/~3/BlufvEk5ZY8/javac3des.html" title="JAVA和C＃3DES加密解密" /><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14778696620700587607" /></author><thr:total>0</thr:total><feedburner:origLink>http://codestandup.blogspot.com/2011/06/javac3des.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEcEQXY5fCp7ImA9WhdTEUw.&quot;"><id>tag:blogger.com,1999:blog-272429821527780388.post-4725811511699602609</id><published>2011-06-14T19:35:00.000-07:00</published><updated>2011-07-08T01:00:00.824-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-07-08T01:00:00.824-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="C#" /><title>Certificate Encryption/Decryption Example on C#</title><content type="html">The following are example functions using a PKCS12 cert. (It has both public and private keys) and the result is encoded/decoded by base64.&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;font-family:'Times New Roman';font-size:medium;"&gt;static string&lt;span class="Apple-converted-space"&gt; &lt;/span&gt;&lt;b style="color: black; background-color: rgb(255, 153, 153);"&gt;Decrypt&lt;/b&gt;(string data)&lt;br /&gt;      {&lt;br /&gt;         &lt;span class="Apple-converted-space"&gt; &lt;/span&gt;&lt;b style="color: black; background-color: rgb(255, 255, 102);"&gt;X509Certificate2&lt;/b&gt;&lt;span class="Apple-converted-space"&gt; &lt;/span&gt;myCertificate = new&lt;span class="Apple-converted-space"&gt; &lt;/span&gt;&lt;b style="color: black; background-color: rgb(255, 255, 102);"&gt;X509Certificate2&lt;/b&gt;("c:\\temp&lt;wbr&gt;\\mycerts.&lt;wbr&gt;p12","1234&lt;wbr&gt;56");&lt;br /&gt;         &lt;span class="Apple-converted-space"&gt; &lt;/span&gt;&lt;b style="color: black; background-color: rgb(153, 255, 153);"&gt;RSACryptoServiceProvider&lt;/b&gt;&lt;span class="Apple-converted-space"&gt; &lt;/span&gt;provider1 = (&lt;b style="color: black; background-color: rgb(153, 255, 153);"&gt;RSACryptoServiceProvider&lt;/b&gt;)&lt;wbr&gt;myCertific&lt;wbr&gt;ate.Privat&lt;wbr&gt;eKey;&lt;br /&gt;          byte[] buffer1 = Convert.FromBase64String(d&lt;wbr&gt;ata);&lt;br /&gt;          byte[] result = provider1.&lt;b style="color: black; background-color: rgb(255, 153, 153);"&gt;Decrypt&lt;/b&gt;(buffer1,&lt;wbr&gt;false);&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="orphans: 2; text-indent: 0px; widows: 2; "&gt;&lt;span class="Apple-style-span"  &gt;return Encoding.UTF8.GetString(result);&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  &gt;//return (new UnicodeEncoding()).GetStri&lt;/span&gt;&lt;wbr&gt;&lt;span class="Apple-style-span"  &gt;ng(result)&lt;/span&gt;&lt;wbr&gt;&lt;span class="Apple-style-span"  &gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  &gt;       }&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  &gt;       static string Encrypt(string data)&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  &gt;       {&lt;/span&gt;&lt;br /&gt;         &lt;span class="Apple-converted-space" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; "&gt; &lt;/span&gt;&lt;b style="border-collapse: separate; font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; color: black; background-color: rgb(255, 255, 102); "&gt;X509Certificate2&lt;/b&gt;&lt;span class="Apple-converted-space" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; "&gt; &lt;/span&gt;&lt;span class="Apple-style-span"  &gt;myCertificate = new&lt;/span&gt;&lt;span class="Apple-converted-space" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; "&gt; &lt;/span&gt;&lt;b style="border-collapse: separate; font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; color: black; background-color: rgb(255, 255, 102); "&gt;X509Certificate2&lt;/b&gt;&lt;span class="Apple-style-span"  &gt;("c:\\temp&lt;/span&gt;&lt;wbr&gt;&lt;span class="Apple-style-span"  &gt;\\mycerts.&lt;/span&gt;&lt;wbr&gt;&lt;span class="Apple-style-span"  &gt;p12", "123456");&lt;/span&gt;&lt;br /&gt;         &lt;span class="Apple-converted-space" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; "&gt; &lt;/span&gt;&lt;b style="border-collapse: separate; font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; color: black; background-color: rgb(153, 255, 153); "&gt;RSACryptoServiceProvider&lt;/b&gt;&lt;span class="Apple-converted-space" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; "&gt; &lt;/span&gt;&lt;span class="Apple-style-span"  &gt;provider1 = (&lt;/span&gt;&lt;b style="border-collapse: separate; font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; color: black; background-color: rgb(153, 255, 153); "&gt;RSACryptoServiceProvider&lt;/b&gt;&lt;span class="Apple-style-span"  &gt;)&lt;/span&gt;&lt;wbr&gt;&lt;span class="Apple-style-span"  &gt;myCertific&lt;/span&gt;&lt;wbr&gt;&lt;span class="Apple-style-span"  &gt;ate.Public&lt;/span&gt;&lt;wbr&gt;&lt;span class="Apple-style-span"  &gt;Key.Key;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  &gt;//byte[] buffer1 = (new UnicodeEncoding()).GetByte&lt;/span&gt;&lt;wbr&gt;&lt;span class="Apple-style-span"  &gt;s(data);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="orphans: 2; text-indent: 0px; widows: 2; "&gt;&lt;span class="Apple-style-span"  &gt;byte[] buffer1 = Encoding.UTF8.GetBytes(data);&lt;br /&gt;          byte[] result = provider1.Encrypt(buffer1,&lt;/span&gt;&lt;wbr&gt;&lt;span class="Apple-converted-space" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; "&gt; &lt;/span&gt;&lt;span class="Apple-style-span"  &gt;false);&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  &gt;           string b64s = Convert.ToBase64String(res&lt;/span&gt;&lt;wbr&gt;&lt;span class="Apple-style-span"  &gt;ult);&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  &gt;           return b64s;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  &gt;       }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  &gt;       static bool VerifyData(string data, string signature)&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  &gt;       {&lt;/span&gt;&lt;br /&gt;         &lt;span class="Apple-converted-space" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; "&gt; &lt;/span&gt;&lt;b style="border-collapse: separate; font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; color: black; background-color: rgb(255, 255, 102); "&gt;X509Certificate2&lt;/b&gt;&lt;span class="Apple-converted-space" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; "&gt; &lt;/span&gt;&lt;span class="Apple-style-span"  &gt;myCertificate = new&lt;/span&gt;&lt;span class="Apple-converted-space" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; "&gt; &lt;/span&gt;&lt;b style="border-collapse: separate; font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; color: black; background-color: rgb(255, 255, 102); "&gt;X509Certificate2&lt;/b&gt;&lt;span class="Apple-style-span"  &gt;("c:\\temp&lt;/span&gt;&lt;wbr&gt;&lt;span class="Apple-style-span"  &gt;\\mycerts.&lt;/span&gt;&lt;wbr&gt;&lt;span class="Apple-style-span"  &gt;p12", "123456");&lt;/span&gt;&lt;br /&gt;         &lt;span class="Apple-converted-space" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; "&gt; &lt;/span&gt;&lt;b style="border-collapse: separate; font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; color: black; background-color: rgb(153, 255, 153); "&gt;RSACryptoServiceProvider&lt;/b&gt;&lt;span class="Apple-converted-space" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; "&gt; &lt;/span&gt;&lt;span class="Apple-style-span"  &gt;provider1 = (&lt;/span&gt;&lt;b style="border-collapse: separate; font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; color: black; background-color: rgb(153, 255, 153); "&gt;RSACryptoServiceProvider&lt;/b&gt;&lt;span class="Apple-style-span"  &gt;)&lt;/span&gt;&lt;wbr&gt;&lt;span class="Apple-style-span"  &gt;myCertific&lt;/span&gt;&lt;wbr&gt;&lt;span class="Apple-style-span"  &gt;ate.Public&lt;/span&gt;&lt;wbr&gt;&lt;span class="Apple-style-span"  &gt;Key.Key;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  &gt;           byte[] sb = Convert.FromBase64String(s&lt;/span&gt;&lt;wbr&gt;&lt;span class="Apple-style-span"  &gt;ignature);&lt;/span&gt;&lt;wbr&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  &gt;&lt;div&gt;//byte[] db = (new ASCIIEncoding()).GetBytes(data);&lt;/div&gt;&lt;div&gt;  byte[] db = Encoding.UTF8.GetBytes(data);&lt;/div&gt;          return provider1.VerifyData(db, new SHA1CryptoServiceProvider(&lt;/span&gt;&lt;wbr&gt;&lt;span class="Apple-style-span"  &gt;), sb);&lt;/span&gt;&lt;span class="Apple-converted-space" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; "&gt; &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  &gt;        }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  &gt;       static string SignData(string data)&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  &gt;       {&lt;/span&gt;&lt;br /&gt;         &lt;span class="Apple-converted-space" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; "&gt; &lt;/span&gt;&lt;b style="border-collapse: separate; font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; color: black; background-color: rgb(255, 255, 102); "&gt;X509Certificate2&lt;/b&gt;&lt;span class="Apple-converted-space" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; "&gt; &lt;/span&gt;&lt;span class="Apple-style-span"  &gt;myCertificate = new&lt;/span&gt;&lt;span class="Apple-converted-space" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; "&gt; &lt;/span&gt;&lt;b style="border-collapse: separate; font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; color: black; background-color: rgb(255, 255, 102); "&gt;X509Certificate2&lt;/b&gt;&lt;span class="Apple-style-span"  &gt;("c:\\temp&lt;/span&gt;&lt;wbr&gt;&lt;span class="Apple-style-span"  &gt;\\mycerts.&lt;/span&gt;&lt;wbr&gt;&lt;span class="Apple-style-span"  &gt;p12", "123456");&lt;/span&gt;&lt;br /&gt;         &lt;span class="Apple-converted-space" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; "&gt; &lt;/span&gt;&lt;b style="border-collapse: separate; font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; color: black; background-color: rgb(153, 255, 153); "&gt;RSACryptoServiceProvider&lt;/b&gt;&lt;span class="Apple-converted-space" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; "&gt; &lt;/span&gt;&lt;span class="Apple-style-span"  &gt;provider1 = (&lt;/span&gt;&lt;b style="border-collapse: separate; font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; color: black; background-color: rgb(153, 255, 153); "&gt;RSACryptoServiceProvider&lt;/b&gt;&lt;span class="Apple-style-span"  &gt;)&lt;/span&gt;&lt;wbr&gt;&lt;span class="Apple-style-span"  &gt;myCertific&lt;/span&gt;&lt;wbr&gt;&lt;span class="Apple-style-span"  &gt;ate.Privat&lt;/span&gt;&lt;wbr&gt;&lt;span class="Apple-style-span"  &gt;eKey;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman'; font-size: medium; "&gt;//byte[] db = (new ASCIIEncoding()).GetBytes(data);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="orphans: 2; text-indent: 0px; widows: 2; "&gt;&lt;span class="Apple-style-span"  &gt;&lt;div&gt;byte[] db = Encoding.UTF8.GetBytes(data);&lt;/div&gt;            byte[] sb = provider1.SignData(db, new SHA1CryptoServiceProvider(&lt;/span&gt;&lt;wbr&gt;&lt;span class="Apple-style-span"  &gt;));&lt;/span&gt;&lt;span class="Apple-converted-space" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-transform: none; white-space: normal; word-spacing: 0px; font-size: medium; "&gt; &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  &gt;            return Convert.ToBase64String(sb)&lt;/span&gt;&lt;wbr&gt;&lt;span class="Apple-style-span"  &gt;;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  &gt;       }&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/272429821527780388-4725811511699602609?l=codestandup.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/dP8dLxgcv4JnP8CzKlDLMmb-yXM/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/dP8dLxgcv4JnP8CzKlDLMmb-yXM/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/dP8dLxgcv4JnP8CzKlDLMmb-yXM/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/dP8dLxgcv4JnP8CzKlDLMmb-yXM/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Code-standup/~4/h23l2j56kS0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://codestandup.blogspot.com/feeds/4725811511699602609/comments/default" title="張貼意見" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=272429821527780388&amp;postID=4725811511699602609" title="0 個意見" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/272429821527780388/posts/default/4725811511699602609?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/272429821527780388/posts/default/4725811511699602609?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Code-standup/~3/h23l2j56kS0/x509certificate2-encrypt-decrypt-using.html" title="Certificate Encryption/Decryption Example on C#" /><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14778696620700587607" /></author><thr:total>0</thr:total><feedburner:origLink>http://codestandup.blogspot.com/2011/06/x509certificate2-encrypt-decrypt-using.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUAAQn88eyp7ImA9WhZVE0U.&quot;"><id>tag:blogger.com,1999:blog-272429821527780388.post-325106467345406500</id><published>2011-05-25T21:21:00.001-07:00</published><updated>2011-05-25T21:22:23.173-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-05-25T21:22:23.173-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><title>Java的編碼問題匯總</title><content type="html">&lt;span class="Apple-style-span" style="font-family: arial, sans-serif; " &gt;&lt;span title=""&gt;&lt;br /&gt;   &lt;/span&gt;&lt;span title=""&gt;問題一：在JAVA中讀取文件時應該採用什麼編碼？&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;Java的讀取文件的方式總體可以分為兩類：按字節讀取和按字符讀取。按字節讀取就是採用 InputStream.read（）執行方法來讀取字節，然後保存到一個字節 []&lt;/span&gt;&lt;span title=""&gt;數組中，最後經常用新的字符串（字節 []）;把字節數組轉換成字符串。在最後一步隱藏了一個編碼的細節，新的字符串（字節 []）;會使用操作系統默認的字符集來解碼&lt;/span&gt;&lt;span title=""&gt;字節數組，中文操作系統就是GBK的。而我們從輸入流裡讀取的字節很可能就不是GBK的編碼的，因為從輸入流裡讀取的字節編碼取決於被讀取的文件自身的編碼&lt;/span&gt;&lt;span title=""&gt;。舉個例子：我們在ð：盤新建一個名為 demo.txt的文件，寫入“我們。”並保存。此時 demo.txt編碼是ANSI和中文操作系統下就是GBK的。此時我們用&lt;/span&gt;&lt;span title=""&gt;輸入字節流讀取該文件所得到的字節就是使用GBK的方式編碼的字節。那麼我們最終新的字符串（字節 []）;時採用平台默認的GBK的來編碼成字符串也是沒有問題的（字節&lt;/span&gt;&lt;span title=""&gt;編碼和默認解碼一致）。試想一下，如果在保存demo.txt文件時，我們選擇的UTF - 8編碼，那麼該文件的編碼就不在是的ANSI了，而變成了UTF - 8的。仍然採用輸入字節&lt;/span&gt;&lt;span title=""&gt;流來讀取，那麼此時讀取的字節和上一次就不一樣了，這次的字節是使用UTF - 8編碼的字節。兩次的字節顯然不一樣，一個很明顯的區別就是&lt;/span&gt;&lt;span title=""&gt;：GBK的每個漢字兩個字節，而UTF - 8的每個漢字三個字節。如何我們最後還使用新字符串（字節 []）;來構造字符串對象，則會出現亂碼，原因很簡單，因為&lt;/span&gt;&lt;span title=""&gt;構造時採用的默認解碼 GBK的，而我們的字節是使用UTF - 8字節。正確的辦法就是使用新的字符串（字節 []“的UTF - 8”）;來構造的String對象。此時我們的字節&lt;/span&gt;&lt;span title=""&gt;編碼和構造使用的解碼是一致的，不會出現亂碼問題了。&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;說完字節輸入流，再來說說字節輸出流。&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;我們知道如果採用字節輸出流把字節輸出到某個文件，我們是無法指定生成文件的編碼的（假設文件以前不存在），那麼生成的文件是什麼編碼的呢？經過測試發現，其實這&lt;/span&gt;&lt;span title=""&gt;取決於寫入的字節編碼格式。比如以下代碼：&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;OutputStream的輸出 =新FileOutputStream（為“D：\ \ demo.txt”）;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;out.write（“我們”。getBytes（）構造）;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;getBytes（）構造會採用操作系統默認的字符集來編碼字節，這裡就是GBK的，所以我們寫入文件的是GBK的demo.txt編碼的字節。那麼這個文件的編碼就是GBK的。如果稍微修改一下程序： &lt;/span&gt;&lt;span title=""&gt;out.write（“我們”。的GetBytes（“使用UTF - 8”））;此時我們寫入的字節就是使用UTF - 8的，那麼 demo.txt文件編碼就是使用UTF - 8。這裡還有一點，如果把&lt;/span&gt;&lt;span title=""&gt;“我們”換成 123或農業銀行之類的的ASCII碼字符，那麼無論是採用的GetBytes（）或者的GetBytes（“使用UTF - 8”），那麼生成的文件都將是GBK的編碼的。&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;這裡可以總結一下，輸入流中的字節編碼取決文件本身的編碼，而OutputStream的生成文件的編碼取決於字節的編碼。&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;下面說說採用字符輸入流來讀取文件。&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;首先，我們需要理解一下字符流。其實字符流可以看做是一種包裝流，它的底層還是採用字節流來讀取字節，然後它使用指定的編碼方式將讀取字節解碼為字符&lt;/span&gt;&lt;span title=""&gt;。說起字符流，不得不提的就是的InputStreamReader。以下是Java API的對它的說明：的InputStreamReader是字節流通向字符流的橋樑：它使用指定的字符集讀取字節並將其解碼為字符。它&lt;/span&gt;&lt;span title=""&gt;使用的字符集可以由名稱指定或顯式給定，否則可能接受平台默認的字符集。說到這裡其實很明白了，的InputStreamReader在底層還是採用字節流來讀取字節，讀取字節後&lt;/span&gt;&lt;span title=""&gt;它需要一個編碼格式來解碼讀取的字節，如果我們在構造的InputStreamReader沒有傳入編碼方式，那麼會採用操作系統默認的GBK的來解碼讀取的字節。demo.txt還用上面的例子，假設&lt;/span&gt;&lt;span title=""&gt;編碼方式為 GBK的demo.txt，我們使用如下代碼來讀取文件：&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;在新的InputStreamReader的InputStreamReader =（新FileInputStream的（“demo.txt”））;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;那麼我們讀取不會產生亂碼，因為文件採用 GBK的編碼，所以讀出的字節也是GBK的編碼的，而的InputStreamReader默認採用解碼也是GBK的。如果把demo.txt編碼方式換成 UTF - 8的，那麼我們採用&lt;/span&gt;&lt;span title=""&gt;這種方式讀取就會產生亂碼。這是因為字節編碼（使用UTF - 8）和我們的解碼編碼（GBK的）造成的。解決辦法如下：&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;在新的InputStreamReader的InputStreamReader =（新FileInputStream的（“demo.txt”），“使用UTF - 8”）;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;給的InputStreamReader指定解碼編碼，這樣二者統一就不會出現亂碼了。&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;下面說說字符輸出流。&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;字符輸出流的原理和字符輸入流的原理一樣，也可以看做是包裝流，其底層還是採用字節輸出流來寫文件。只是字符輸出流根據指定的編碼將字符轉換為字節的。字符&lt;/span&gt;&lt;span title=""&gt;輸出流的主要類是：OutputStreamWriter。Java API的解釋如下：OutputStreamWriter是字符流通向字節流的橋樑：使用指定的字符集將要向其寫入的字符編碼為字節。它使用的字符集可以由名稱指定&lt;/span&gt;&lt;span title=""&gt;或顯式給定，否則可能接受平台默認的字符集。說的很明白了，它需要一個編碼將寫入的字符轉換為字節，如果沒有指定則採用 GBK的編碼，那麼輸出的字節都將&lt;/span&gt;&lt;span title=""&gt;是GBK的編碼，生成的文件也是GBK的編碼的。如果採用以下方式構造 OutputStreamWriter：&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;OutputStreamWriter輸出 =新OutputStreamWriter（新FileOutputStream（“dd.txt”），“使用UTF - 8”）;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;那麼寫入的字符將被編碼為 UTF - 8編碼的字節，生成的文件也將是使用UTF - 8格式的。&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;問題二：既然讀文件要使用和文件編碼一致的編碼，那麼 javac的編譯文件也需要讀取文件，它使用什麼編碼呢？&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span title=""&gt;這個問題從來就沒想過，也從沒當做是什麼問題。正是因為問題一而引發的思考，其實這裡還是有東西可以挖掘的。下面分三種情況來探討，這三種情況也是我們常用&lt;/span&gt;&lt;span title=""&gt;的編譯的Java源文件的方法。&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span title=""&gt;1.javac在控制台編譯的Java類文件。&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span title=""&gt;通常我們手動建立一個 java的文件Demo.java，並保存。此時 Demo.java文件的編碼為 ANSI和中文操作系統下就是GBK的。然後使用javac的命令來編譯該源文件。“javac的Demo.java”。javac的&lt;/span&gt;&lt;span title=""&gt;也需要讀取的Java文件，那麼 javac的是使用什麼編碼來解碼我們讀取的字節呢？其實 javac的採用了操作系統默認的GBK的編碼解碼我們讀取的字節，這個編碼正好也是Demo.java文件的&lt;/span&gt;&lt;span title=""&gt;編碼，二者一致，所以不會出現亂碼情況。讓我們來做點手腳，在保存Demo.java文件時，我們選擇的UTF - 8保存。此時 Demo.java文件編碼就是UTF - 8的了。我們再&lt;/span&gt;&lt;span title=""&gt;使用“javac的Demo.java”來編譯，如果Demo.java裡含有中文字符，此時控制台會出現警告信息，也出現了亂碼。究其原因，就是因為採用了GBK的javac的編碼解碼我們讀取的字&lt;/span&gt;&lt;span title=""&gt;節。因為我們的字節是使用UTF - 8編碼的，所以會出現亂碼。如果不信的話你可以自己試試。那麼解決辦法呢？解決辦法就是使用的javac的編碼參數來制定我們的解碼編碼。如下： &lt;/span&gt;&lt;span title=""&gt;javac的編碼的UTF - 8 Demo.java。這裡我們指定了使用的UTF - 8來解碼讀取的字節，由於這個編碼和Demo.java文件編碼一致，所以不會出現亂碼情況了。&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span title=""&gt;2.Eclipse中編譯的Java文件。&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span title=""&gt;我習慣把Eclipse中的編碼設置成UTF - 8的。那麼每個項目中的Java的源文件的編碼就是使用UTF - 8。這樣編譯也從沒有問題，也沒有出現過亂碼。正是因為這樣才掩蓋了使用javac的&lt;/span&gt;&lt;span title=""&gt;可能出現的亂碼。那麼 Eclipse的是如何正確編譯文件編碼為 UTF - 8編碼的Java的源文件的呢？唯一的解釋就是Eclipse的自動識別了我們的Java源文件的文件編碼，然後採取了正確的編碼參數來編譯&lt;/span&gt;&lt;span title=""&gt;我們的Java的源文件。功勞都歸功於 IDE中的強大了。&lt;br /&gt;&lt;br /&gt;   &lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span title=""&gt;3。使用的Ant來編譯的Java文件。&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span title=""&gt;螞蟻也是我常用的編譯的Java文件的工具。首先，必須知道螞蟻在後台其實也是採用的javac來編譯的Java源文件的，那麼可想而知，一會出現的問題在螞蟻中也會存在。如果我們使用&lt;/span&gt;&lt;span title=""&gt;螞蟻來編譯的UTF - 8編碼的Java的源文件，並且不指定如何編碼，那麼也會出現亂碼的情況。所以螞蟻的編譯命令&lt;javac&gt;有一個屬性“編碼”允許我們指定編碼，如果我們要編譯源&lt;/javac&gt;&lt;/span&gt;&lt;span title=""&gt;文件編碼為 UTF - 8編碼的java的文件，那麼我們的命令應該如下：&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span title=""&gt;&lt;javac的了destdir utf="" span=""&gt;&lt;span title=""&gt;“&amp;gt;&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span title=""&gt;指定了編碼也就相當於“javac的編碼”了，所以不會出現亂碼了。&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;問題三：tomcat的中編譯的JSP的情況。&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span title=""&gt;這個話題也是由問題二引出的。既然javac的編譯的Java源文件需要採用正確的編碼，那麼 Tomcat的編譯的JSP時也要讀取文件，此時的Tomcat採用什麼編碼來讀取文件？會出現亂碼情況嗎？下面&lt;/span&gt;&lt;span title=""&gt;我們來分析。&lt;br /&gt;&lt;br /&gt;      &lt;/span&gt;&lt;span title=""&gt;我們通常會在jsp的開頭寫上如下代碼：&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;&amp;lt;％@網頁的語言 =“爪哇”的contentType =“text / html的，字符集= UTF - 8”pageEncoding =“的UTF - 8”％&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;我常常不寫 pageEncoding這個屬於，也不明白它的作用，但是不寫也沒出現過亂碼情況。其實這個屬性就是告訴 tomcat的採用什麼編碼來讀取 JSP的文件的。它應該和jsp的文件本身的編碼一致&lt;/span&gt;&lt;span title=""&gt;。比如我們新建個 jsp的文件，設置文件編碼為 GBK的，那麼此時我們的pageEncoding應該設置為 GBK的，這樣我們寫入文件的字符就是GBK的編碼的，Tomcat的讀取文件時採用也是GBK的編碼，所以能保證&lt;/span&gt;&lt;span title=""&gt;正確的解碼讀取的字節。不會出現亂碼。如果把pageEncoding設置為 UTF - 8的，那麼讀取的jsp文件過程中轉碼就出現了亂碼。上面說我常常不寫 pageEncoding這個屬性，但是也沒出現&lt;/span&gt;&lt;span title=""&gt;過亂碼，這是怎麼回事呢？那是因為如果沒有 pageEncoding屬性中，Tomcat會採用的contentType中字符集編碼來讀取 jsp的文件，我的jsp的文件編碼通常設置為 UTF - 8編碼，字符集的contentType的也設置為使用UTF &lt;/span&gt;&lt;span title=""&gt;-8，這樣的Tomcat使用的UTF - 8編碼來解碼讀取的jsp的文件，二者編碼一致也不會出現亂碼。這只是中的contentType字符集的一個作用，它還有兩個作用，後面再說。可能有人會&lt;/span&gt;&lt;span title=""&gt;問：如果我既不設置 pageEncoding屬性，也不設置的contentType的字符集屬性，那麼 Tomcat的會採取什麼編碼來解碼讀取的jsp的文件呢？答案是異 - 8859 - 1，這是Tomcat的讀取文件採用的默認&lt;/span&gt;&lt;span title=""&gt;編碼，如果用這種編碼來讀取文件顯然會出現亂碼。&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   &lt;/span&gt;&lt;span title=""&gt;問題四：輸出。&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;問題二和問題三分析的過程其實就是從源文件àclass文件過程中的轉碼情況。最終的類文件都是以Unicode的編碼的，我們前面所做的工作就是把各種不同的編碼轉換為 Unicode的編碼&lt;/span&gt;&lt;span title=""&gt;，比如從 GBK的轉換為 Unicode編碼，從使用UTF - 8轉換為 Unicode的。因為只有採用正確的編碼來轉碼才能保證不出現亂碼。在jvm在運行時其內部都是採用的Unicode編碼的，其實在輸出時，又&lt;/span&gt;&lt;span title=""&gt;會做一次編碼的轉換。讓我們分兩種情況來討論。&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;1.java中採用 Sysout.out.println輸出。&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;比如：Sysout.out.println（“我們”）。經過正確的解碼後“我們”是unicode的保存在內存中的，但是在向標準輸出（控制台）輸出時，jvm的又做了一次轉碼，它&lt;/span&gt;&lt;span title=""&gt;會採用操作系統默認編碼（中文操​​作系統是GBK的），將內存中的Unicode的編碼轉換為 GBK的編碼，然後輸出到控制台。因為我們操作系統是中文系統，所以往終端顯示設備上打印字符時使用的&lt;/span&gt;&lt;span title=""&gt;也是GBK的編碼。因為終端的編碼無法手動改變，所以這個過程對我們來說是透明的，只要編譯時能正確轉碼，最終的輸出都將是正確的，不會出現亂碼。在Eclipse中中可以設置&lt;/span&gt;&lt;span title=""&gt;控制台的字符編碼，具體位置在運行配置對話框的通用標籤裡，我們可以試著設置為 UTF - 8的，此時的輸出就是亂碼了。因為輸出時是採用 GBK的編碼的，而顯示卻是使用&lt;/span&gt;&lt;span title=""&gt;使用UTF - 8，編碼不同，所以出現亂碼。&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;2.jsp中使用out.println（）輸出到客戶端瀏覽器。&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;JSP的編譯成類後，如果輸出到客戶端，也有個轉碼的過程。爪哇會採用操作系統默認的編碼來轉碼，那麼 Tomcat的採用什麼編碼來轉碼呢？其實 tomcat的是根據 &amp;lt;％@網頁的語言&lt;/span&gt;&lt;span title=""&gt;=“爪哇”的contentType =“text / html的，字符集= UTF - 8”pageEncoding =“的UTF - 8”％&amp;gt;中的contentType的字符集參數來轉碼的，用來設置的contentType Tomcat的往瀏覽器發送的HTML內容所使用的&lt;/span&gt;&lt;span title=""&gt;編碼。Tomcat的根據這個編碼來轉碼內存中的Unicode的。經過轉碼後的Tomcat輸出到客戶端的字符編碼就是utf - 8的了。那麼瀏覽器怎麼知道採取什麼編碼格式來顯示接收到的內容呢？這就是&lt;/span&gt;&lt;span title=""&gt;contentType中的字符集屬性的第三個作用了：這個編碼會在HTTP的響應頭中指定以通知瀏覽器。瀏覽器使用的HTTP響應頭的contentType中的字符集屬性來顯示接收到的內容。&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;總結一下的contentType字符集的三個作用：&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;1）。在沒有 pageEncoding屬性時，Tomcat的使用它來解碼讀取的jsp的文件。&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;2）。Tomcat的向客戶端輸出時，使用它來編碼發送的內容。&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;3）。通知瀏覽器，應該以什麼編碼來顯示接收到的內容。&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;為了能更好的理解上面所說的解碼和轉碼過程，我們舉一個例子。&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;新建一個 index.jsp的文件，該文件編碼為 GBK的，在jsp的開頭我們寫上如下代碼：&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;&amp;lt;％@網頁的語言 =“爪哇”的contentType =“text / html的，字符集= UTF - 8”pageEncoding =“GBK的”％&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;span title=""&gt;這裡的字符集和pageEncoding不同，但是也不會出現亂碼，我來解釋一下。首先Tomcat的讀取 jsp的內容，並根據 pageEncoding指定的GBK的編碼將讀取的GBK的字節解碼並轉換為 Unicode的字節碼保存在&lt;/span&gt;&lt;span title=""&gt;類文件中。然後 tomcat的在輸出時（out.println（））使用字符集屬性將內存中的Unicode的轉換為 UTF - 8的編碼，並在響應頭中通知瀏覽器，瀏覽器以UTF - 8的顯示接收到的&lt;/span&gt;&lt;span title=""&gt;內容。整個過程沒有一次轉碼錯誤，所以就不會出現亂碼情況。&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;   &lt;/span&gt;&lt;span title=""&gt;問題五：屬性和ResourceBundle的使用的解碼編碼。&lt;br /&gt;&lt;br /&gt;              &lt;/span&gt;&lt;span title=""&gt;以上兩個是我們常用的類，他們在讀取文件過程中並不允許我們指定解碼編碼，那麼它們採取什麼解碼方式呢？查看源碼後發現都是採用異 - 8859 - 1編碼來解碼&lt;br /&gt;          &lt;/span&gt;&lt;span title=""&gt;的。這樣的話我們也不難理解我們寫的屬性文件為什麼都是異 - 8859 - 1的了。因為採取任何一個別的編碼都將產生亂碼。因為異 - 8859 - 1編碼是沒&lt;br /&gt;          &lt;/span&gt;&lt;span title="" style="background-color: rgb(235, 239, 249); "&gt;有中文的，所以我們輸入的中文要轉換為 unicode的，通常我們使用插件來完成，也可以使用的JDK自帶的native2ascii的工具。&lt;/span&gt;&lt;/javac的了destdir&gt;&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial, sans-serif; "&gt;&lt;span title="" style="background-color: rgb(235, 239, 249); "&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial, sans-serif; "&gt;&lt;span title="" style="background-color: rgb(235, 239, 249); "&gt;source : &lt;/span&gt;&lt;/span&gt;&lt;a href="http://www.blogjava.net/zhangchao/archive/2011/05/26/351051.html"&gt;http://www.blogjava.net/zhangchao/archive/2011/05/26/351051.html&lt;/a&gt;&lt;/div&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/272429821527780388-325106467345406500?l=codestandup.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/rhLPPWcUQ2VNyVLB-YEAH1XPALs/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/rhLPPWcUQ2VNyVLB-YEAH1XPALs/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/rhLPPWcUQ2VNyVLB-YEAH1XPALs/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/rhLPPWcUQ2VNyVLB-YEAH1XPALs/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Code-standup/~4/FTgj__niuDg" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://codestandup.blogspot.com/feeds/325106467345406500/comments/default" title="張貼意見" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=272429821527780388&amp;postID=325106467345406500" title="0 個意見" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/272429821527780388/posts/default/325106467345406500?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/272429821527780388/posts/default/325106467345406500?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Code-standup/~3/FTgj__niuDg/java.html" title="Java的編碼問題匯總" /><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14778696620700587607" /></author><thr:total>0</thr:total><feedburner:origLink>http://codestandup.blogspot.com/2011/05/java.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0cNQHc7fSp7ImA9WhZQF08.&quot;"><id>tag:blogger.com,1999:blog-272429821527780388.post-785219563319921458</id><published>2011-04-25T03:57:00.000-07:00</published><updated>2011-04-25T03:58:11.905-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-04-25T03:58:11.905-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="IOS" /><title>iOS開發中常用代碼解釋</title><content type="html">&lt;div&gt;#include  /* 说明 malloc, NULL, size_t */&lt;/div&gt;&lt;div&gt;#include  /* 说明 va_ 相关类型和函数 */&lt;/div&gt;&lt;div&gt;#include  /* 说明 strcat 等 */&lt;/div&gt;&lt;div&gt;char *vstrcat(const char *first, ...)&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;size_t len;&lt;/div&gt;&lt;div&gt;char *retbuf;&lt;/div&gt;&lt;div&gt;va_list argp;&lt;/div&gt;&lt;div&gt;char *p;&lt;/div&gt;&lt;div&gt;if(first == NULL)&lt;/div&gt;&lt;div&gt;return NULL;&lt;/div&gt;&lt;div&gt;len = strlen(first);&lt;/div&gt;&lt;div&gt;va_start(argp, first);&lt;/div&gt;&lt;div&gt;while((p = va_arg(argp, char *)) != NULL)&lt;/div&gt;&lt;div&gt;len += strlen(p);&lt;/div&gt;&lt;div&gt;va_end(argp);&lt;/div&gt;&lt;div&gt;retbuf = malloc(len + 1); /* +1 包含终止符 \0 */&lt;/div&gt;&lt;div&gt;if(retbuf == NULL)&lt;/div&gt;&lt;div&gt;return NULL; /* 出错 */&lt;/div&gt;&lt;div&gt;(void)strcpy(retbuf, first);&lt;/div&gt;&lt;div&gt;va_start(argp, first); /* 重新开始扫描 */&lt;/div&gt;&lt;div&gt;while((p = va_arg(argp, char *)) != NULL)&lt;/div&gt;&lt;div&gt;(void)strcat(retbuf, p);&lt;/div&gt;&lt;div&gt;va_end(argp);&lt;/div&gt;&lt;div&gt;retbuf = malloc(len + 1); /* +1 包含终止符 \0 */&lt;/div&gt;&lt;div&gt;if(retbuf == NULL)&lt;/div&gt;&lt;div&gt;return NULL; /* 出错 */&lt;/div&gt;&lt;div&gt;(void)strcpy(retbuf, first);&lt;/div&gt;&lt;div&gt;va_start(argp, first); /* 重新开始扫描 */&lt;/div&gt;&lt;div&gt;while((p = va_arg(argp, char *)) != NULL)&lt;/div&gt;&lt;div&gt;(void)strcat(retbuf, p);&lt;/div&gt;&lt;div&gt;va_end(argp);&lt;/div&gt;&lt;div&gt;return retbuf;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;%c 一个单一的字符&lt;/div&gt;&lt;div&gt;%d 一个十进制整数&lt;/div&gt;&lt;div&gt;%i 一个整数&lt;/div&gt;&lt;div&gt;%e, %f, %g 一个浮点数&lt;/div&gt;&lt;div&gt;%o 一个八进制数&lt;/div&gt;&lt;div&gt;%s 一个字符串&lt;/div&gt;&lt;div&gt;%x 一个十六进制数&lt;/div&gt;&lt;div&gt;%p 一个指针&lt;/div&gt;&lt;div&gt;%n 一个等于读取字符数量的整数&lt;/div&gt;&lt;div&gt;%u 一个无符号整数&lt;/div&gt;&lt;div&gt;%[] 一个字符集&lt;/div&gt;&lt;div&gt;%% 一个精度符号 &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;//一、NSString&lt;/div&gt;&lt;div&gt;    /*----------------创建字符串的方法----------------*/&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    1、创建常量字符串。&lt;/div&gt;&lt;div&gt;    NSString *astring = @"This is a String!";&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    2、创建空字符串，给予赋值。&lt;/div&gt;&lt;div&gt;    NSString *astring = [[NSString alloc] init];&lt;/div&gt;&lt;div&gt;    astring = @"This is a String!";&lt;/div&gt;&lt;div&gt;    NSLog(@"astring:%@",astring);&lt;/div&gt;&lt;div&gt;    [astring release];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    3、在以上方法中，提升速度:initWithString方法&lt;/div&gt;&lt;div&gt;    NSString *astring = [[NSString alloc] initWithString:@"This is a String!"];&lt;/div&gt;&lt;div&gt;    NSLog(@"astring:%@",astring);&lt;/div&gt;&lt;div&gt;    [astring release];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    4、用标准c创建字符串:initWithCString方法&lt;/div&gt;&lt;div&gt;    char *Cstring = "This is a String!";&lt;/div&gt;&lt;div&gt;    NSString *astring = [[NSString alloc] initWithCString:Cstring];&lt;/div&gt;&lt;div&gt;    NSLog(@"astring:%@",astring);&lt;/div&gt;&lt;div&gt;    [astring release];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    5、创建格式化字符串:占位符（由一个%加一个字符组成）&lt;/div&gt;&lt;div&gt;    int i = 1;&lt;/div&gt;&lt;div&gt;    int j = 2;&lt;/div&gt;&lt;div&gt;    NSString *astring = [[NSString alloc]&lt;/div&gt;&lt;div&gt;                        initWithString:[NSString stringWithFormat:@"%d.This is %i string!",i,j]];&lt;/div&gt;&lt;div&gt;    NSLog(@"astring:%@",astring);&lt;/div&gt;&lt;div&gt;    [astring release];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    6、创建临时字符串&lt;/div&gt;&lt;div&gt;    NSString *astring;&lt;/div&gt;&lt;div&gt;    astring = [NSString stringWithCString:"This is a temporary string"];&lt;/div&gt;&lt;div&gt;    NSLog(@"astring:%@",astring);&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    /*----------------从文件读取字符串:initWithContentsOfFile方法 ----------------*/&lt;/div&gt;&lt;div&gt;    NSString *path = @"astring.text";&lt;/div&gt;&lt;div&gt;    NSString *astring = [[NSString alloc] initWithContentsOfFile:path];&lt;/div&gt;&lt;div&gt;    NSLog(@"astring:%@",astring);&lt;/div&gt;&lt;div&gt;    [astring release];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    /*----------------写字符串到文件:writeToFile方法 ----------------*/&lt;/div&gt;&lt;div&gt;    NSString *astring = [[NSString alloc] initWithString:@"This is a String!"];&lt;/div&gt;&lt;div&gt;    NSLog(@"astring:%@",astring);&lt;/div&gt;&lt;div&gt;    NSString *path = @"astring.text";&lt;/div&gt;&lt;div&gt;    [astring writeToFile: path atomically: YES];&lt;/div&gt;&lt;div&gt;    [astring release];    &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    /*---------------- 比较两个字符串----------------*/&lt;/div&gt;&lt;div&gt;    用C比较:strcmp函数&lt;/div&gt;&lt;div&gt;    char string1[] = "string!";&lt;/div&gt;&lt;div&gt;    char string2[] = "string!";&lt;/div&gt;&lt;div&gt;    if(strcmp(string1, string2) = = 0)&lt;/div&gt;&lt;div&gt;    {&lt;/div&gt;&lt;div&gt;        NSLog(@"1");&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    isEqualToString方法&lt;/div&gt;&lt;div&gt;    NSString *astring01 = @"This is a String!";&lt;/div&gt;&lt;div&gt;    NSString *astring02 = @"This is a String!";&lt;/div&gt;&lt;div&gt;    BOOL result = [astring01 isEqualToString:astring02];&lt;/div&gt;&lt;div&gt;    NSLog(@"result:%d",result);&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    compare方法(comparer返回的三种值)&lt;/div&gt;&lt;div&gt;    NSString *astring01 = @"This is a String!";&lt;/div&gt;&lt;div&gt;    NSString *astring02 = @"This is a String!";&lt;/div&gt;&lt;div&gt;    BOOL result = [astring01 compare:astring02] = = NSOrderedSame;&lt;/div&gt;&lt;div&gt;    NSLog(@"result:%d",result);&lt;/div&gt;&lt;div&gt;    NSOrderedSame 判断两者内容是否相同&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    NSString *astring01 = @"This is a String!";&lt;/div&gt;&lt;div&gt;    NSString *astring02 = @"this is a String!";&lt;/div&gt;&lt;div&gt;    BOOL result = [astring01 compare:astring02] = = NSOrderedAscending;&lt;/div&gt;&lt;div&gt;    NSLog(@"result:%d",result);&lt;/div&gt;&lt;div&gt;    //NSOrderedAscending 判断两对象值的大小(按字母顺序进行比较，astring02大于astring01为真)&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    NSString *astring01 = @"this is a String!";&lt;/div&gt;&lt;div&gt;    NSString *astring02 = @"This is a String!";&lt;/div&gt;&lt;div&gt;    BOOL result = [astring01 compare:astring02] = = NSOrderedDescending;&lt;/div&gt;&lt;div&gt;    NSLog(@"result:%d",result);&lt;/div&gt;&lt;div&gt;    //NSOrderedDescending 判断两对象值的大小(按字母顺序进行比较，astring02小于astring01为真)&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    不考虑大 小写比较字符串1&lt;/div&gt;&lt;div&gt;    NSString *astring01 = @"this is a String!";&lt;/div&gt;&lt;div&gt;    NSString *astring02 = @"This is a String!";&lt;/div&gt;&lt;div&gt;    BOOL result = [astring01 caseInsensitiveCompare:astring02] = = NSOrderedSame;&lt;/div&gt;&lt;div&gt;    NSLog(@"result:%d",result);&lt;/div&gt;&lt;div&gt;    //NSOrderedDescending判断两对象值的大小(按字母顺序进行比较，astring02小于astring01为 真)&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    不考虑大小写比较字符串2&lt;/div&gt;&lt;div&gt;    NSString *astring01 = @"this is a String!";&lt;/div&gt;&lt;div&gt;    NSString *astring02 = @"This is a String!";&lt;/div&gt;&lt;div&gt;    BOOL result = [astring01 compare:astring02&lt;/div&gt;&lt;div&gt;                            options:NSCaseInsensitiveSearch | NSNumericSearch] = = NSOrderedSame;&lt;/div&gt;&lt;div&gt;    NSLog(@"result:%d",result);     &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    //NSCaseInsensitiveSearch:不区分大小写比较 NSLiteralSearch:进行完全比较，区分大小写 NSNumericSearch:比较字符串的字符个数，而不是字符值。&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    /*----------------改变字符串的大小写----------------*/&lt;/div&gt;&lt;div&gt;    NSString *string1 = @"A String";&lt;/div&gt;&lt;div&gt;    NSString *string2 = @"String";&lt;/div&gt;&lt;div&gt;    NSLog(@"string1:%@",[string1 uppercaseString]);//大写&lt;/div&gt;&lt;div&gt;    NSLog(@"string2:%@",[string2 lowercaseString]);//小写&lt;/div&gt;&lt;div&gt;    NSLog(@"string2:%@",[string2 capitalizedString]);//首字母大小&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    /*----------------在串中搜索子串 ----------------*/&lt;/div&gt;&lt;div&gt;    NSString *string1 = @"This is a string";&lt;/div&gt;&lt;div&gt;    NSString *string2 = @"string";&lt;/div&gt;&lt;div&gt;    NSRange range = [string1 rangeOfString:string2];&lt;/div&gt;&lt;div&gt;    int location = range.location;&lt;/div&gt;&lt;div&gt;    int leight = range.length;&lt;/div&gt;&lt;div&gt;    NSString *astring = [[NSString alloc]&lt;/div&gt;&lt;div&gt;                        initWithString:[NSString stringWithFormat:@"Location:%i,Leight:%i"&lt;/div&gt;&lt;div&gt;                        ,location,leight]];&lt;/div&gt;&lt;div&gt;    NSLog(@"astring:%@",astring);&lt;/div&gt;&lt;div&gt;    [astring release];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    /*----------------抽取子串 ----------------*/&lt;/div&gt;&lt;div&gt;    -substringToIndex: 从字符串的开头一直截取到指定的位置，但不包括该位置的字符&lt;/div&gt;&lt;div&gt;    NSString *string1 = @"This is a string";&lt;/div&gt;&lt;div&gt;    NSString *string2 = [string1 substringToIndex:3];&lt;/div&gt;&lt;div&gt;    NSLog(@"string2:%@",string2);&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    -substringFromIndex: 以指定位置开始（包括指定位置的字符），并包括之后的全部字符&lt;/div&gt;&lt;div&gt;    NSString *string1 = @"This is a string";&lt;/div&gt;&lt;div&gt;    NSString *string2 = [string1 substringFromIndex:3];&lt;/div&gt;&lt;div&gt;    NSLog(@"string2:%@",string2);&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    -substringWithRange: //按照所给出的位置，长度，任意地从字符串中截取子串&lt;/div&gt;&lt;div&gt;    NSString *string1 = @"This is a string";&lt;/div&gt;&lt;div&gt;    NSString *string2 = [string1 substringWithRange:NSMakeRange(0, 4)];&lt;/div&gt;&lt;div&gt;    NSLog(@"string2:%@",string2); &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;const char *fieldValue = [value  cStringUsingEncoding:NSUTF8StringEncoding];&lt;/div&gt;&lt;div&gt;const char *fieldValue = [value UTF8String];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;NSString 转 NSData&lt;/div&gt;&lt;div&gt;NSString* str= @"kilonet";&lt;/div&gt;&lt;div&gt;NSData* data=[str dataUsingEncoding:NSUTF8StringEncoding]; &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;   Date format用法：&lt;/div&gt;&lt;div&gt;  -(NSString *) getDay:(NSDate *) d&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;    NSString *s ;&lt;/div&gt;&lt;div&gt;    NSDateFormatter *format = [[NSDateFormatter alloc] init];&lt;/div&gt;&lt;div&gt;    [format setDateFormat:@"YYYY/MM/dd hh:mm:ss"];&lt;/div&gt;&lt;div&gt;    s = [format stringFromDate:d];&lt;/div&gt;&lt;div&gt;    [format release];&lt;/div&gt;&lt;div&gt;    return s;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;各地时区获取：&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;NSDate *nowDate = [NSDate new];&lt;/div&gt;&lt;div&gt;    NSDateFormatter *formatter    =  [[NSDateFormatter alloc] init];&lt;/div&gt;&lt;div&gt;    [formatter    setDateFormat:@"yyyy/MM/dd HH:mm:ss"];&lt;/div&gt;&lt;div&gt;    //    根据时区名字获取当前时间，如果该时区不存在，默认获取系统当前时区的时间&lt;/div&gt;&lt;div&gt;    //    NSTimeZone* timeZone = [NSTimeZone timeZoneWithName:@"Europe/Andorra"];&lt;/div&gt;&lt;div&gt;    //    [formatter setTimeZone:timeZone];&lt;/div&gt;&lt;div&gt;    //获取所有的时区名字&lt;/div&gt;&lt;div&gt;    NSArray *array = [NSTimeZone knownTimeZoneNames];&lt;/div&gt;&lt;div&gt;    //    NSLog(@"array:%@",array);&lt;/div&gt;&lt;div&gt;    //for循环&lt;/div&gt;&lt;div&gt;    //    for(int i=0;i&amp;lt;[array count];i++)&lt;/div&gt;&lt;div&gt;    //    {&lt;/div&gt;&lt;div&gt;    //        NSTimeZone* timeZone = [NSTimeZone timeZoneWithName:[array objectAtIndex:i]];&lt;/div&gt;&lt;div&gt;    //        [formatter setTimeZone:timeZone];&lt;/div&gt;&lt;div&gt;    //        NSString *locationTime = [formatter stringFromDate:nowDate];&lt;/div&gt;&lt;div&gt;    //        NSLog(@"时区名字:%@   : 时区当前时间: %@",[array objectAtIndex:i],locationTime);&lt;/div&gt;&lt;div&gt;    //        //NSLog(@"timezone name is:%@",[array objectAtIndex:i]);&lt;/div&gt;&lt;div&gt;    //    }&lt;/div&gt;&lt;div&gt;    //快速枚举法&lt;/div&gt;&lt;div&gt;    for(NSString *timeZoneName in array){&lt;/div&gt;&lt;div&gt;        [formatter setTimeZone:[NSTimeZone timeZoneWithName:timeZoneName]];&lt;/div&gt;&lt;div&gt;        NSLog(@"%@,%@",timeZoneName,[formatter stringFromDate:nowDate]);&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    [formatter release];&lt;/div&gt;&lt;div&gt;    [nowDate release];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt; NSCalendar用法：&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt; -(NSString *) getWeek:(NSDate *) d {&lt;/div&gt;&lt;div&gt;    NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];&lt;/div&gt;&lt;div&gt;    unsigned units = NSYearCalendarUnit | NSMonthCalendarUnit |  NSDayCalendarUnit | NSWeekdayCalendarUnit;&lt;/div&gt;&lt;div&gt;    NSDateComponents *components = [calendar components:units fromDate:d];&lt;/div&gt;&lt;div&gt;    [calendar release];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    switch ([components weekday]) {&lt;/div&gt;&lt;div&gt;        case 2:&lt;/div&gt;&lt;div&gt;            return @"Monday";&lt;/div&gt;&lt;div&gt;            break;&lt;/div&gt;&lt;div&gt;        case 3:&lt;/div&gt;&lt;div&gt;            return @"Tuesday";&lt;/div&gt;&lt;div&gt;            break;&lt;/div&gt;&lt;div&gt;        case 4:&lt;/div&gt;&lt;div&gt;            return @"Wednesday";&lt;/div&gt;&lt;div&gt;            break;&lt;/div&gt;&lt;div&gt;        case 5:&lt;/div&gt;&lt;div&gt;           return @"Thursday";&lt;/div&gt;&lt;div&gt;            break;&lt;/div&gt;&lt;div&gt;        case 6:&lt;/div&gt;&lt;div&gt;            return  @"Friday";&lt;/div&gt;&lt;div&gt;            break;&lt;/div&gt;&lt;div&gt;        case 7:&lt;/div&gt;&lt;div&gt;            return  @"Saturday";&lt;/div&gt;&lt;div&gt;            break;&lt;/div&gt;&lt;div&gt;        case 1:&lt;/div&gt;&lt;div&gt;            return @"Sunday";&lt;/div&gt;&lt;div&gt;            break;&lt;/div&gt;&lt;div&gt;        default:&lt;/div&gt;&lt;div&gt;            return @"No Week";&lt;/div&gt;&lt;div&gt;            break;&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    // 用components，我们可以读取其他更多的数据。&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;4. 用Get方式读取网络数据：&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;将网络数读取为字符串&lt;/div&gt;&lt;div&gt;- (NSString *) getDataByURL:(NSString *) url {&lt;/div&gt;&lt;div&gt;    return [[NSString alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]] encoding:NSUTF8StringEncoding];&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;//读取网络图片&lt;/div&gt;&lt;div&gt;- (UIImage *) getImageByURL:(NSString *) url {&lt;/div&gt;&lt;div&gt;    return [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[url stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]]];&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;多线程&lt;/div&gt;&lt;div&gt;[NSThread detachNewThreadSelector:@selector(scheduleTask) toTarget:self withObject:nil];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;-(void) scheduleTask {&lt;/div&gt;&lt;div&gt;    //create a pool&lt;/div&gt;&lt;div&gt;    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    //release the pool;&lt;/div&gt;&lt;div&gt;    [pool release];&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;//如果有参数，则这么使用：&lt;/div&gt;&lt;div&gt;[NSThread detachNewThreadSelector:@selector(scheduleTask:) toTarget:self withObject:[NSDate date]];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;-(void) scheduleTask:(NSDate *) mdate {&lt;/div&gt;&lt;div&gt;    //create a pool&lt;/div&gt;&lt;div&gt;    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    //release the pool;&lt;/div&gt;&lt;div&gt;    [pool release];&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;//注意selector里有冒号。&lt;/div&gt;&lt;div&gt;    //在线程里运行主线程里的方法 &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    [self performSelectorOnMainThread:@selector(moveToMain) withObject:nil waitUntilDone:FALSE];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;6. 定时器NSTimer用法:&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;代码&lt;/div&gt;&lt;div&gt;  // 一个可以自动关闭的Alert窗口&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil&lt;/div&gt;&lt;div&gt;                                                    message:[@"一个可以自动关闭的Alert窗口"&lt;/div&gt;&lt;div&gt;                                                   delegate:nil&lt;/div&gt;&lt;div&gt;                                          cancelButtonTitle:nil //NSLocalizedString(@"OK", @"OK")   //取消任何按钮&lt;/div&gt;&lt;div&gt;                                          otherButtonTitles:nil];&lt;/div&gt;&lt;div&gt;    //[alert setBounds:CGRectMake&lt;/div&gt;&lt;div&gt;      (alert.bounds.origin.x, alert.bounds.origin.y,&lt;/div&gt;&lt;div&gt;      alert.bounds.size.width, alert.bounds.size.height+30.0)];&lt;/div&gt;&lt;div&gt;    [alert show];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    // Adjust the indicator so it is up a few pixels from the bottom of the alert&lt;/div&gt;&lt;div&gt;    indicator.center = CGPointMake(alert.bounds.size.width/2,  alert.bounds.size.height-40.0);&lt;/div&gt;&lt;div&gt;    [indicator startAnimating];&lt;/div&gt;&lt;div&gt;    [alert insertSubview:indicator atIndex:0];&lt;/div&gt;&lt;div&gt;    [indicator release];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    [NSTimer scheduledTimerWithTimeInterval:3.0f&lt;/div&gt;&lt;div&gt;                                     target:self&lt;/div&gt;&lt;div&gt;                                   selector:@selector(dismissAlert:)&lt;/div&gt;&lt;div&gt;                                   userInfo:[NSDictionary dictionaryWithObjectsAndKeys:alert,&lt;/div&gt;&lt;div&gt;                   @"alert", @"testing ", @"key" ,nil]  //如果不用传递参数，那么可以将此项设置为nil.&lt;/div&gt;&lt;div&gt;                                    repeats:NO];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    NSLog(@"release alert");&lt;/div&gt;&lt;div&gt;    [alert release];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;-(void) dismissAlert:(NSTimer *)timer{&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    NSLog(@"release timer");&lt;/div&gt;&lt;div&gt;    NSLog([[timer userInfo]  objectForKey:@"key"]);&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    UIAlertView *alert = [[timer userInfo]  objectForKey:@"alert"];&lt;/div&gt;&lt;div&gt;    [alert dismissWithClickedButtonIndex:0 animated:YES];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;定时器停止使用：&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;[timer invalidate];&lt;/div&gt;&lt;div&gt;timer = nil;&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;     7. 用户缺省值NSUserDefaults读取：&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    //得到用户缺省值&lt;/div&gt;&lt;div&gt;    NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    //在缺省值中找到AppleLanguages, 返回值是一个数组&lt;/div&gt;&lt;div&gt;    NSArray* languages = [defs objectForKey:@"AppleLanguages"];&lt;/div&gt;&lt;div&gt;    NSLog(@"all language语言 is %@", languages);&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    //在得到的数组中的第一个项就是用户的首选语言了&lt;/div&gt;&lt;div&gt;    NSLog(@"首选语言 is %@",[languages objectAtIndex:0]);  &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    //get the language &amp;amp; country code&lt;/div&gt;&lt;div&gt;    NSLocale *currentLocale = [NSLocale currentLocale];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    NSLog(@"Language Code is %@", [currentLocale objectForKey:NSLocaleLanguageCode]);&lt;/div&gt;&lt;div&gt;    NSLog(@"Country Code is %@", [currentLocale objectForKey:NSLocaleCountryCode&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;8. View之间切换的动态效果设置：&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    SettingsController *settings = [[SettingsController alloc]initWithNibName:@"SettingsView" bundle:nil];&lt;/div&gt;&lt;div&gt;    settings.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;  //水平翻转&lt;/div&gt;&lt;div&gt;    [self presentModalViewController:settings animated:YES];&lt;/div&gt;&lt;div&gt;    [settings release];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;9.NSScrollView 滑动用法：&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;-(void) scrollViewDidScroll:(UIScrollView *)scrollView{&lt;/div&gt;&lt;div&gt;    NSLog(@"正在滑动中...");&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;//用户直接滑动NSScrollView，可以看到滑动条&lt;/div&gt;&lt;div&gt;-(void) scrollViewDidEndDecelerating:(UIScrollView *)scrollView {&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;// 通过其他控件触发NSScrollView滑动，看不到滑动条&lt;/div&gt;&lt;div&gt;- (void) scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView {&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    11.键盘处理系列&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt; //set the UIKeyboard to switch to a different text field when you press return&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;//switch textField to the name of your textfield&lt;/div&gt;&lt;div&gt;[textField becomeFirstResponder];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;srandom(time(NULL)); //随机数种子&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;id d = random(); // 随机数&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;   4. iPhone的系统目录:&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;//得到Document目录：&lt;/div&gt;&lt;div&gt;NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);&lt;/div&gt;&lt;div&gt;NSString *documentsDirectory = [paths objectAtIndex:0];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;//得到temp临时目录：&lt;/div&gt;&lt;div&gt;NSString *tempPath = NSTemporaryDirectory();&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;//得到目录上的文件地址：&lt;/div&gt;&lt;div&gt;NSString *文件地址 = [目录地址 stringByAppendingPathComponent:@"文件名.扩展名"];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt; 5. 状态栏显示Indicator：&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;[UIApplication sharedApplication].networkActivityIndicatorVisible = YES; &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;  6.app Icon显示数字：&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;- (void)applicationDidEnterBackground:(UIApplication *)application{&lt;/div&gt;&lt;div&gt;    [[UIApplication sharedApplication] setApplicationIconBadgeNumber:5];&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;   7.sqlite保存地址： &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;代码&lt;/div&gt;&lt;div&gt;    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);&lt;/div&gt;&lt;div&gt;    NSString *thePath = [paths objectAtIndex:0];&lt;/div&gt;&lt;div&gt;    NSString *filePath = [thePath stringByAppendingPathComponent:@"kilonet1.sqlite"];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    NSString *dbPath = [[[NSBundle mainBundle] resourcePath]&lt;/div&gt;&lt;div&gt;                        stringByAppendingPathComponent:@"kilonet2.sqlite"]; &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;   8.Application退出：exit(0);&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;      9. AlertView，ActionSheet的cancelButton点击事件：&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;代码&lt;/div&gt;&lt;div&gt;-(void) actionSheet :(UIActionSheet *) actionSheet didDismissWithButtonIndex:(NSInteger) buttonIndex {&lt;/div&gt;&lt;div&gt;    NSLog(@"cancel actionSheet........");&lt;/div&gt;&lt;div&gt;    //当用户按下cancel按钮&lt;/div&gt;&lt;div&gt;    if( buttonIndex == [actionSheet cancelButtonIndex]) {&lt;/div&gt;&lt;div&gt;        exit(0);&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;//    //当用户按下destructive按钮&lt;/div&gt;&lt;div&gt;//    if( buttonIndex == [actionSheet destructiveButtonIndex]) {&lt;/div&gt;&lt;div&gt;//        // DoSomething here.&lt;/div&gt;&lt;div&gt;//    }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;- (void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex {&lt;/div&gt;&lt;div&gt;     NSLog(@"cancel alertView........");&lt;/div&gt;&lt;div&gt;    if (buttonIndex == [alertView cancelButtonIndex]) {&lt;/div&gt;&lt;div&gt;        exit(0);&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;  10.给Window设置全局的背景图片：&lt;/div&gt;&lt;div&gt;window.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"coolblack.png"]];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    11. UITextField文本框显示及对键盘的控制:&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;代码&lt;/div&gt;&lt;div&gt;#pragma mark -&lt;/div&gt;&lt;div&gt;#pragma mark UITextFieldDelegate&lt;/div&gt;&lt;div&gt;//控制键盘跳转&lt;/div&gt;&lt;div&gt;- (BOOL)textFieldShouldReturn:(UITextField *)textField {&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    if (textField == _txtAccount) {&lt;/div&gt;&lt;div&gt;        if ([_txtAccount.text length]==0) {&lt;/div&gt;&lt;div&gt;            return NO;&lt;/div&gt;&lt;div&gt;        }&lt;/div&gt;&lt;div&gt;        [_txtPassword becomeFirstResponder];&lt;/div&gt;&lt;div&gt;    } else if (textField == _txtPassword) {&lt;/div&gt;&lt;div&gt;        [_txtPassword resignFirstResponder];&lt;/div&gt;&lt;div&gt;    }&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    return YES;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;//输入框背景更换&lt;/div&gt;&lt;div&gt;-(BOOL) textFieldShouldBeginEditing:(UITextField *)textField{&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    [textField setBackground:[UIImage imageNamed:@"ctext_field_02.png"]];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    return YES;&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;-(void) textFieldDidEndEditing:(UITextField *)textField{&lt;/div&gt;&lt;div&gt;    [textField setBackground:[UIImage imageNamed:@"ctext_field_01.png"]];&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;12.UITextField文本框前面空白宽度设置以及后面组合按钮设置：&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;代码&lt;/div&gt;&lt;div&gt;    //给文本输入框后面加入空白&lt;/div&gt;&lt;div&gt;    _txtAccount.rightView = _btnDropDown;&lt;/div&gt;&lt;div&gt;    _txtAccount.rightViewMode =  UITextFieldViewModeAlways;&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    //给文本输入框前面加入空白&lt;/div&gt;&lt;div&gt;    CGRect frame = [_txtAccount frame];&lt;/div&gt;&lt;div&gt;    frame.size.width = 5;&lt;/div&gt;&lt;div&gt;    UIView *leftview = [[UIView alloc] initWithFrame:frame];&lt;/div&gt;&lt;div&gt;    _txtAccount.leftViewMode = UITextFieldViewModeAlways;&lt;/div&gt;&lt;div&gt;    _txtAccount.leftView = leftview;&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;  13. UIScrollView 设置滑动不超出本身范围：&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt; [fcScrollView setBounces:NO]; &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt; 14. 在drawRect里画文字：&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;     UIFont * f = [UIFont systemFontOfSize:20]; &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    [[UIColor darkGrayColor] set]; &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    NSString * text = @"hi \nKiloNet"; &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    [text drawAtPoint:CGPointMake(center.x,center.y) withFont:f];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    15. NSArray查找是否存在对象时用indexOfObject,如果不存在则返回为NSNotFound.&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    16. NString与NSArray之间相互转换：&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;array = [string componentsSeparatedByString:@","];&lt;/div&gt;&lt;div&gt;string = [[array valueForKey:@"description"] componentsJoinedByString:@","];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;     17. TabController随意切换tab bar：&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;[self.tabBarController setSelectedIndex:tabIndex];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;或者 self.tabBarController.selectedIndex = tabIndex;&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;或者实现下面的delegate来扑捉tab bar的事件： &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;代码-(BOOL) tabBarController:(UITabBarController *)tabBarController&lt;/div&gt;&lt;div&gt;shouldSelectViewController:(UIViewController *)viewController&lt;/div&gt;&lt;div&gt;{        if ([viewController.tabBarItem.title isEqualToString: NSLocalizedString(@"Logout",nil)])&lt;/div&gt;&lt;div&gt;{        [self showLogout];        return NO;    }    return YES;}&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;    18. 自定义View之间切换动画：&lt;/div&gt;&lt;div&gt;代码&lt;/div&gt;&lt;div&gt;- (void) pushController: (UIViewController*) controller&lt;/div&gt;&lt;div&gt;         withTransition: (UIViewAnimationTransition) transition&lt;/div&gt;&lt;div&gt;{&lt;/div&gt;&lt;div&gt;    [UIView beginAnimations:nil context:NULL];&lt;/div&gt;&lt;div&gt;    [self pushViewController:controller animated:NO];&lt;/div&gt;&lt;div&gt;    [UIView setAnimationDuration:.5];&lt;/div&gt;&lt;div&gt;    [UIView setAnimationBeginsFromCurrentState:YES];&lt;/div&gt;&lt;div&gt;    [UIView setAnimationTransition:transition forView:self.view cache:YES];&lt;/div&gt;&lt;div&gt;    [UIView commitAnimations];&lt;/div&gt;&lt;div&gt;}&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;CATransition *transition = [CATransition animation];&lt;/div&gt;&lt;div&gt;transition.duration = kAnimationDuration;&lt;/div&gt;&lt;div&gt;transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];&lt;/div&gt;&lt;div&gt;transition.type = kCATransitionPush;&lt;/div&gt;&lt;div&gt;transition.subtype = kCATransitionFromTop;&lt;/div&gt;&lt;div&gt;transitioning = YES;&lt;/div&gt;&lt;div&gt;transition.delegate = self;&lt;/div&gt;&lt;div&gt;[self.navigationController.view.layer addAnimation:transition forKey:nil];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;self.navigationController.navigationBarHidden = NO;&lt;/div&gt;&lt;div&gt;[self.navigationController pushViewController:tableViewController animated:YES];&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;     20.计算字符串长度：&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;CGFloat w = [title sizeWithFont:[UIFont fontWithName:@"Arial" size:18]].width; &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;  23.在使用UISearchBar时，将背景色设定为clearColor，或者将translucent设为YES，都不能使背景透明，经过一番研究，发现了一种超级简单和实用的方法：&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;1&lt;/div&gt;&lt;div&gt; [[searchbar.subviews objectAtIndex:0]removeFromSuperview]; &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;背景完全消除了，只剩下搜索框本身了。 &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;  24.  图像与缓存 :&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;UIImageView *wallpaper = [[UIImageView alloc] initWithImage:&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;        [UIImage imageNamed:@"icon.png"]]; // 会缓存图片&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;UIImageView *wallpaper = [[UIImageView alloc] initWithImage:&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;        [UIImage imageWithContentsOfFile:@"icon.png"]]; // 不会缓存图片 &lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;  25. iphone-常用的对视图图层(layer)的操作&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;对图层的操作：&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;(1.给图层添加背景图片：&lt;/div&gt;&lt;div&gt;myView.layer.contents = (id)[UIImage imageNamed:@"view_BG.png"].CGImage;&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;(2.将图层的边框设置为圆脚&lt;/div&gt;&lt;div&gt;myWebView.layer.cornerRadius = 8;&lt;/div&gt;&lt;div&gt;myWebView.layer.masksToBounds = YES;&lt;/div&gt;&lt;div&gt; &lt;/div&gt;&lt;div&gt;(3.给图层添加一个有色边框&lt;/div&gt;&lt;div&gt;myWebView.layer.borderWidth = 5;&lt;/div&gt;&lt;div&gt;myWebView.layer.borderColor = [[UIColor colorWithRed:0.52 green:0.09 blue:0.07 alpha:1] CGColor];&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;source: &lt;a href="http://www.codeios.com/forum.php?mod=viewthread&amp;amp;tid=98&amp;amp;page=1"&gt;http://www.codeios.com/forum.php?mod=viewthread&amp;amp;tid=98&amp;amp;page=1&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/272429821527780388-785219563319921458?l=codestandup.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/tDC5Ul6audliE7ZvuASmVdeJpgw/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/tDC5Ul6audliE7ZvuASmVdeJpgw/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/tDC5Ul6audliE7ZvuASmVdeJpgw/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/tDC5Ul6audliE7ZvuASmVdeJpgw/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Code-standup/~4/1lKOJgbBJk0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://codestandup.blogspot.com/feeds/785219563319921458/comments/default" title="張貼意見" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=272429821527780388&amp;postID=785219563319921458" title="0 個意見" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/272429821527780388/posts/default/785219563319921458?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/272429821527780388/posts/default/785219563319921458?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Code-standup/~3/1lKOJgbBJk0/ios.html" title="iOS開發中常用代碼解釋" /><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14778696620700587607" /></author><thr:total>0</thr:total><feedburner:origLink>http://codestandup.blogspot.com/2011/04/ios.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0UGSHw5eCp7ImA9WhZQFEQ.&quot;"><id>tag:blogger.com,1999:blog-272429821527780388.post-1147633746551826303</id><published>2011-04-22T10:59:00.000-07:00</published><updated>2011-04-22T11:00:29.220-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-04-22T11:00:29.220-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET" /><title>關於.NET Framework / ASP.NET這條路</title><content type="html">.NET Framework歷史版本及功能，第6點是我自己整理。&lt;br /&gt;.NET Framework 1.0&lt;br /&gt;.NET Framework 1.1&lt;br /&gt;.NET Framework 2.0&lt;br /&gt;CLR + Windows forms + Web Services + ASP.NET&lt;br /&gt;.NET Framework 3.0&lt;br /&gt;.NET Framework 2.0 + WCF + WF + WPF + CardSpace&lt;br /&gt;.NET Framework 3.5&lt;br /&gt;.NET Framework 3.0 + LINQ + AJAX + REST&lt;br /&gt;.NET Framework 4.0&lt;br /&gt;.NET Framework 3.5 + Entity Framework + ASP.NET MVC + Parallel&lt;br /&gt;先說結論，再說故事。&lt;br /&gt;&lt;br /&gt;結論&lt;br /&gt;通常第一版都是實驗性質或有很大的改進空間，不管是多好的東西都一樣。從第二版開始，似乎是個不錯的開始。&lt;br /&gt;&lt;br /&gt;故事1--.NET Framework 2.0&lt;br /&gt;&lt;br /&gt;現在的資訊爆炸，但這些資訊你可以不看。但就資訊技術人員而言，技術更新的速度才是一大挑戰，以前一個技術能讓你十年有飯吃，現在一個技術能讓你三年有飯吃就很不錯了，技術更新的速度讓人「怕怕的」，我實在很敬佩那些永遠走在資訊前端的前輩，有著過人的領悟力與學習力。&lt;br /&gt;&lt;br /&gt;話說從前，我是學習Visual Basic 6與ASP，為什學這兩樣？也沒有什麼特別的原因，學校教什麼，我們就學什麼，而且從Visual Basic 6接ASP(VB Script)還很順，所以在使用ASP上還算順手。&lt;br /&gt;&lt;br /&gt;後來，微軟登高一呼：「我們要進入.NET的世界！」然後推出了.NET Framework 1.0，那時的ASP由2.0到3.0，ASP 3.0之後微軟也很明確表示，ASP不再更新維護了，因為微軟要全力推「.NET」這個…產品嗎？概念嗎？程式語言嗎？反正那時候認為是新一代的ASP就是了。&lt;br /&gt;&lt;br /&gt;我還很認真的去買書來看，結果一個月後我就放棄了，那ASP.NET 1.0是什麼鬼東西，看不懂，結果我又回到ASP的身邊，反正工作上也只用的到ASP，會不會ASP.NET也不影響工作。&lt;br /&gt;&lt;br /&gt;一段時間又過去了，突然發現，怎麼大家又在推「ASP.NET 2.0」，而且這一次好像又不一樣了，Survey之後發現，.NET Framework 2.0是個全新的改版，不同於.NET Framework 1.0 / 1.1，而且微軟似乎也發現開發人員的辛苦，承諾未來的改版會使用「積木式」方式來改版，就是說，你學了.NET Framework 2.0的東西，拿到.NET Framework 3.0 / 3.5 / 4.0上一樣都可以使用，讓你不會天天做打掉重練的工作。就是這一點，讓我試著相信它，開始學習著ASP.NET 2.0。&lt;br /&gt;&lt;br /&gt;另外在.NET Framework 2.0還有一項重要事，那就是開發工具的完備，那是在.NET Framework 1.0 / 1.1所沒有的。在.NET Framework 2.0有Visual Studio 2005 / 2008兩個版本，我學ASP.NET 2.0時已經是Visual Studio 2008版本，就Visual Studio 2008來開發ASP.NET 2.0而言，還蠻快樂的。&lt;br /&gt;&lt;br /&gt;[Key Point 1].NET Framework → .NET Framework 2.0&lt;br /&gt;&lt;br /&gt;故事2--LINQ to SQL&lt;br /&gt;&lt;br /&gt;時間飛快，在學習.NET Framework 2.0不久，.NET Framwork 3.0推出，3.0還沒有什麼感覺，又不久之後，馬上再推出.NET Framework 3.5，這個3.5版的推出又是一個高潮 ，因為它提供了幾個重要的元素「LINQ + AJAX + REST」，其中最紅的就是LINQ(Language-Integrated Query)，LINQ是個統稱，內容幾項重要的技術內容LINQ to Object、LINQ to ADO.NET(LINQ to DataSet、LINQ to SQL)、LINQ to XML、LINQ to Entities。&lt;br /&gt;&lt;br /&gt;如果有學LINQ，我相信其中的LINQ to SQL會是你的一項主力。不過，就在2008一篇「Update on LINQ to SQL and LINQ to Entities Roadmap」的微軟官方文章，給所有有學LINQ to SQL的人一顆炸彈，他們的一句「他們會很認真的聽取 LINQ to SQL 社群的聲音，然後好好的來加強我們的 Entity Framework 產品」嚇死了一堆人。&lt;br /&gt;&lt;br /&gt;很明顯，他們將主力放在Entity Framework上面(可看成LINQ to Entities這一項)，那LINQ to SQL呢？在.NET Framework 4.0有做一些錯誤修正，但請注意，他們已經很明顯未來會不斷加強的是Entity Framework，目前在.NET Framework 4.0裡的是Entity Framework 4.0，現在已經有Entity Framework 4.1版本可以下載安裝使用。&lt;br /&gt;&lt;br /&gt;[Key Point 2] LINQ to SQL → LINQ to Entities → Entity Famework&lt;br /&gt;&lt;br /&gt;故事3--Web Service&lt;br /&gt;&lt;br /&gt;在ASP.NET 2.0時，提供了一個很棒的Web Services服務，也就是說，我可以把相關Function透過伺服器分享出來，分享給網路上其他需要的人使用。使用者只要引用我的Web Services，就可以立即擁有我所提供的服務。&lt;br /&gt;&lt;br /&gt;Web Services好是好，但也是有一些問題，所以Microsoft在.NET Framework 3.5又提出了一個 REST，董大偉老師有篇介紹 REST 文章，可以知一二。&lt;br /&gt;&lt;br /&gt;[Key Point 3] Web Service → REST&lt;br /&gt;&lt;br /&gt;故事4-- ASP.NET MVC 2.0&lt;br /&gt;&lt;br /&gt;在Visual Studio 2008 + .NET Framework 3.5時，微軟還推出了一個很重要的Web技術，即ASP.NET MVC 1.0，老實說，ASP.NET MVC 1.0我連碰都沒碰過，但我碰了ASP.NET MVC 2.0。ASP.NET MVC 2.0對我而言，感覺又回到寫ASP，再強調一下，是「感覺」，不是「回到寫ASP」，什麼感覺，是一種「操之在我」的感覺，但靈活度是ASP及ASP.NET完全比不上的感覺。&lt;br /&gt;&lt;br /&gt;ASP.NET Web Form入門而言，實在好學好用，但當你要深入一些時，會發現就沒那怎容易，當你想把你的魔手伸的越深入，你就會發現Web Form的控制項越複雜。但一切一切問題在ASP.NET MVC身上都沒有，因為它根本沒有控制項！&lt;br /&gt;&lt;br /&gt;不過想要學習、使用ASP.NET MVC，就我個人認為，不是件簡單的事，因為有許多觀念必須先行建立，物件導向程式設計、Visual Basic 9/10語法熟悉度、LINQ、.NET Framework Class…這些都會了，再學習ASP.NET MVC會比較輕鬆，不然走一步算一步是比較辛苦點。&lt;br /&gt;&lt;br /&gt;最近，ASP.NET MVC 3又正式推出，在ASP.NET MVC 3裡有一個重點Razor View Engine，Razor是一個新的View Engine，在我們撰寫ASP.NET MVC 3時，它提供了更簡潔的語法。不過馬上就有人指出，使用Razor怪怪的，因為它會破壞MVC的規則，將Controller的內容放到View裡。但Razor也讓我們在撰寫View提供了很好的規範，不會整個畫面裡都是&lt;% ~ %&gt;的符號。&lt;br /&gt;&lt;br /&gt;Razor最早是與另一套微軟免費入門網頁開發軟體WebMatrix所採用，後來可能覺的很不錯，所以在ASP.NET MVC 3.0也加入了Razor的支援。所以到了ASP.NET MVC 3.0你可以選擇使用&lt;% ~ %&gt;的Visual Basic語法，也可以使用Razor的@Code ~ End Code或@ViewData()之類的語法。&lt;br /&gt;&lt;br /&gt;[Key Point 4] ASP.NET MVC 1.0 →  ASP.NET MVC 2.0 / 3.0, Razor View Engine&lt;br /&gt;&lt;br /&gt;整理一下Key Point&lt;br /&gt;&lt;br /&gt;[Key Point 1] .NET Framework 1.0 → .NET Framework 2.0&lt;br /&gt;[Key Point 2] LINQ to SQL → LINQ to Entities&lt;br /&gt;[Key Point 3] Web Services → REST&lt;br /&gt;[Key Point 4] Web Form → ASP.NET MVC&lt;br /&gt;每個技術背景都有故事，在.NET Framework的裡的每個進步，都是為了解決一些前一代的一些問題或提供更好的解決方案。我們不能怪微軟說，為什麼說放就放，說改就改，而是要去思考及了解前因後果，當然不是每件事的回答或解釋都讓開發人員滿意。&lt;br /&gt;&lt;br /&gt;由以上來看，.NET Framework到目前為止，所推出的第一代技術都會被第二代技術替代，其實這是必然的結果，只是改的太兇，苦的是這是程式開發人員。但我們在每一項新技術推出之時，每篇文章、專欄、ABC大會、XYZ研討會…你都只會聽到「優點」，但我在意的是「缺點」呢？例如，這一篇「對Entity Framework Performance 抱怨以及建議」，說明Entity Framework 1.0版實在不怎麼樣，但現在的Entity Framework 4.0到是沒聽到這種聲音了，原因前提過了，Entity Framework是現在的主力。而缺點，通常會在一段時間，實際使用於專案上之後，才會出現。&lt;br /&gt;&lt;br /&gt;如果你現在才要進入.NET Framework的世界，我個人是建議，如果是那種「最新」的技術，有精力再去研究，如果是第二版之後改進的技術，通常是可以上場見世面了。了解每一項技術所提供的優點及缺點，所以當我聽完優點後，會靜一靜，等等看市場上有沒有其他聲音。以上是我個人就我在.NET Framework/ASP.NET的學習上的驗經談。我的時間、精力有限，所以在.NET Framework/ASP.NET這條路，我是選擇走「老二哲學」。&lt;br /&gt;&lt;br /&gt;source: http://kkbruce.blogspot.com/2011/04/net-framework-aspnet.html?utm_source=feedburner&amp;utm_medium=feed&amp;utm_campaign=Feed%3A+KingkongBruce+%28KingKong+Bruce%E8%A8%98%E4%BA%8B%29&amp;utm_content=Google+Reader&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/272429821527780388-1147633746551826303?l=codestandup.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/Aiv3UbfS3irbez-vlVyaIX1Sjks/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Aiv3UbfS3irbez-vlVyaIX1Sjks/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/Aiv3UbfS3irbez-vlVyaIX1Sjks/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Aiv3UbfS3irbez-vlVyaIX1Sjks/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Code-standup/~4/a6dGfbhBQoU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://codestandup.blogspot.com/feeds/1147633746551826303/comments/default" title="張貼意見" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=272429821527780388&amp;postID=1147633746551826303" title="0 個意見" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/272429821527780388/posts/default/1147633746551826303?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/272429821527780388/posts/default/1147633746551826303?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Code-standup/~3/a6dGfbhBQoU/net-framework-aspnet.html" title="關於.NET Framework / ASP.NET這條路" /><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14778696620700587607" /></author><thr:total>0</thr:total><feedburner:origLink>http://codestandup.blogspot.com/2011/04/net-framework-aspnet.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ck4AQ3k9eip7ImA9Wx9bFk8.&quot;"><id>tag:blogger.com,1999:blog-272429821527780388.post-8012452799353112292</id><published>2011-02-25T00:01:00.000-08:00</published><updated>2011-02-25T00:02:22.762-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-02-25T00:02:22.762-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Database" /><category scheme="http://www.blogger.com/atom/ns#" term="MSSQL" /><title>Moving SQL NVarchar to ORACLE NVarchar2</title><content type="html">&lt;span class="Apple-style-span" style="font-family: Geneva, Verdana, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 12px; "&gt;&lt;p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;之前用SSIS在做ORACLE與SQL間資料搬移時，最痛恨遇到NVarchar跟Unicode Code問題了。&lt;/p&gt;&lt;p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;明明是NVarchar(SQL)搬到NVarchar2(ORACLE)，兩邊都Support Unicode，但SSIS都老會要求指定Data Flow Destination的Code Page，接著又會嚷著SQL中得到的Unicode不能直接轉成Non-Unicode，所以就得很可笑地在Nvarchar與NVarchar2兩個Unicode欄位中加上一個Data Conversion。如下圖:&lt;/p&gt;&lt;p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;&lt;img src="http://blog.darkthread.net/photos/darkthread/images/775/original.aspx" id="id4047881723381579" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; " /&gt;&lt;/p&gt;&lt;p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;不過，苦難還沒有結束... 如果很不幸地，NVarchar中還真的放了Unicode字元，則在轉換時，會出現以下的錯誤訊息。&lt;/p&gt;&lt;p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;Error: 0xC02020C5 at Data Flow Task Failure Sample, Data Conversion [543]: Data conversion failed while converting column "UnicodeField" (505) to column "UnicodeFieldMapping" (557). &lt;span style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;The conversion returned status value 4 and status text "Text was truncated or one or more characters had no match in the target code page.".&lt;br /&gt;&lt;/span&gt;Error: 0xC020902A at Data Flow Task Failure Sample, Data Conversion [543]: The "output column "UnicodeFieldMapping" (557)" failed because truncation occurred, and the truncation row disposition on "output column "UnicodeFieldMapping" (557)" specifies failure on truncation. A truncation error occurred on the specified object of the specified component.&lt;/p&gt;&lt;p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;這問題讓我很困擾，不過因為遇到時都是做些一次性的資料搬移，所以我都很鄉愿地繞路解決(最愛用的一招是回去改用SQL 2000 DTS，很奇怪，用DTS搬資料時，幾乎不曾為Enocding傷過腦筋)，未曾認真與它對決過。&lt;/p&gt;&lt;p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;最近同事想用SSIS來做重要的日常資料搬移，就卡在這個問題上，由於搬移是每天要跑的，繞路的成本就會高出許多，這回我總算被迫要收服這隻妖怪。東試西試之餘，忽然想到之前使用&lt;a href="http://blog.darkthread.net/blogs/darkthreadtw/archive/2006/12/28/kb-oracle-9i-nvarchar.aspx" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "&gt;Query Express&lt;/a&gt;的經驗，Oracle的OLE DB Driver才能正確顯示Unicode，Microsft的OLE DB for Oracle反而不行，所以我試著把Data Flow Destination的OLE DB換成Oracle版。&lt;/p&gt;&lt;p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;美妙的事出現了!!  使用Oracle Provider for OLE DB後，連Data Conversion都不用了，直接對Unicode對Unicode，一次搞定。&lt;/p&gt;&lt;p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;&lt;img src="http://blog.darkthread.net/photos/darkthread/images/774/original.aspx" id="id693252686643973" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; " /&gt;&lt;/p&gt;&lt;p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;看一下令人興奮的結果，SQL裡的六頭牛被搬到ORACLE裡了，NVarchar --&gt; NVarchar2，萬牛奔騰的感覺豈是一個爽字可以形容，哈!!&lt;/p&gt;&lt;p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;&lt;img src="http://blog.darkthread.net/photos/darkthread/images/773/original.aspx" id="id08236012165434659" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; " /&gt;&lt;/p&gt;&lt;p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;&lt;br /&gt;&lt;/p&gt;&lt;p style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 1em; margin-right: 0px; margin-bottom: 1em; margin-left: 0px; "&gt;source: &lt;span class="Apple-style-span" style="font-family: Georgia, serif; line-height: normal; font-size: 16px; "&gt;&lt;a href="http://blog.darkthread.net/post-2007-05-17-kb-ssis-moving-sql-nvarchar-to-oracle-nvarchar2.aspx"&gt;http://blog.darkthread.net/post-2007-05-17-kb-ssis-moving-sql-nvarchar-to-oracle-nvarchar2.aspx&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/272429821527780388-8012452799353112292?l=codestandup.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/vhqL-50KoXC-9O2DtV6_o7BVbZs/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/vhqL-50KoXC-9O2DtV6_o7BVbZs/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/vhqL-50KoXC-9O2DtV6_o7BVbZs/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/vhqL-50KoXC-9O2DtV6_o7BVbZs/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Code-standup/~4/SZghA9JuZv8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://codestandup.blogspot.com/feeds/8012452799353112292/comments/default" title="張貼意見" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=272429821527780388&amp;postID=8012452799353112292" title="0 個意見" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/272429821527780388/posts/default/8012452799353112292?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/272429821527780388/posts/default/8012452799353112292?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Code-standup/~3/SZghA9JuZv8/moving-sql-nvarchar-to-oracle-nvarchar2.html" title="Moving SQL NVarchar to ORACLE NVarchar2" /><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14778696620700587607" /></author><thr:total>0</thr:total><feedburner:origLink>http://codestandup.blogspot.com/2011/02/moving-sql-nvarchar-to-oracle-nvarchar2.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUQERnc4cSp7ImA9Wx9bEU8.&quot;"><id>tag:blogger.com,1999:blog-272429821527780388.post-5611205603121089424</id><published>2011-02-19T06:53:00.000-08:00</published><updated>2011-02-19T06:55:07.939-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-02-19T06:55:07.939-08:00</app:edited><title>Google App Engine for Java下的URL編碼轉換問題</title><content type="html">&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;meta equiv="Content-Type" content="text/html; charset=UTF-8"&gt; &lt;meta equiv="Content-Style-Type" content="text/css"&gt; &lt;title&gt;&lt;/title&gt; &lt;meta name="Generator" content="Cocoa HTML Writer"&gt; &lt;meta name="CocoaVersion" content="1038.35"&gt; &lt;style type="text/css"&gt; p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 19.0px; font: 13.0px Verdana} &lt;/style&gt;   &lt;p class="p1"&gt;&lt;b&gt;URL编码问题&lt;/b&gt;&lt;/p&gt;&lt;/div&gt;&lt;div&gt;&lt;meta equiv="Content-Type" content="text/html; charset=UTF-8"&gt; &lt;meta equiv="Content-Style-Type" content="text/css"&gt; &lt;title&gt;&lt;/title&gt; &lt;meta name="Generator" content="Cocoa HTML Writer"&gt; &lt;meta name="CocoaVersion" content="1038.35"&gt; &lt;style type="text/css"&gt; p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 19.0px; font: 13.0px Verdana; color: #333233} p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 19.0px; font: 13.0px Verdana; color: #0166aa} p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 19.0px; font: 13.0px Verdana; color: #333233; min-height: 16.0px} p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 19.0px; font: 13.0px Verdana; color: #333300} p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 19.0px; font: 13.0px Verdana} p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 19.0px; font: 13.0px Courier; color: #333233} p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 19.0px; font: 19.0px 'Comic Sans MS'} p.p8 {margin: 0.0px 0.0px 0.0px 0.0px; text-align: right; line-height: 19.0px; font: 12.0px Courier} p.p9 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 19.0px; font: 16.0px Courier} p.p10 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 19.0px; font: 16.0px 'Times New Roman'} p.p11 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 19.0px; font: 13.0px 'Courier New'; background-color: #f5f5f5} p.p12 {margin: 0.0px 0.0px 0.0px 0.0px; text-align: right; line-height: 19.0px; font: 12.0px Courier; color: #333233} p.p13 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 19.0px; font: 13.0px Courier; color: #0166aa} li.li2 {margin: 0.0px 0.0px 0.0px 0.0px; line-height: 19.0px; font: 13.0px Verdana; color: #0166aa} span.s1 {color: #333233} span.s2 {color: #0166aa} span.s3 {font: 16.0px 'Times New Roman'} span.s4 {color: #00807f} span.s5 {font: 13.0px Courier; color: #0166aa} span.s6 {font: 13.0px Verdana; color: #333233} span.s7 {font: 13.0px Verdana} table.t1 {width: 776.0px; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #808080 #808080 #808080 #808080} td.td1 {width: 774.0px; background-color: #ccccff; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #808080 #808080 #808080 #808080} td.td2 {width: 161.0px; background-color: #ffffff; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #808080 #808080 #808080 #808080} td.td3 {width: 611.0px; background-color: #ffffff; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #808080 #808080 #808080 #808080} td.td4 {width: 91.0px; background-color: #ffffff; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #808080 #808080 #808080 #808080} td.td5 {width: 681.0px; background-color: #ffffff; border-style: solid; border-width: 1.0px 1.0px 1.0px 1.0px; border-color: #808080 #808080 #808080 #808080} ul.ul1 {list-style-type: disc} &lt;/style&gt;   &lt;p class="p1"&gt;此部分参考英文资料：&lt;/p&gt; &lt;ul class="ul1"&gt; &lt;li class="li2"&gt;&lt;a href="http://www.blooberry.com/indexdot/html/topics/urlencoding.htm"&gt;http://www.blooberry.com/indexdot/html/topics/urlencoding.htm&lt;/a&gt;&lt;/li&gt; &lt;li class="li2"&gt;&lt;a href="http://www.w3schools.com/TAGS/ref_urlencode.asp"&gt;http://www.w3schools.com/TAGS/ref_urlencode.asp&lt;/a&gt;&lt;/li&gt; &lt;li class="li2"&gt;&lt;a href="http://www.rfc-editor.org/rfc/rfc2396.txt"&gt;http://www.rfc-editor.org/rfc/rfc2396.txt&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;p class="p1"&gt;在HTTP客户端使用get方法通过URL向服务器发送参数里，由于URL里面只可以包含允许的字符（也称为合法字符），所以一旦参数里面存在非法字符，就必须通过某种手段对其进行合法化转换，在服务器端再将其转换回来，&lt;/p&gt; &lt;p class="p1"&gt;在RFC1738：Uniform Resource Locators (URL) 规范中，指出URL只能包含AscII集中的一个子集中的字符，这个子集也称作AscII character-set，原文写道：&lt;/p&gt; &lt;p class="p1"&gt;&lt;i&gt;"...Only alphanumerics [0-9a-zA-Z], the special characters "$-_.+!*'()," &lt;/i&gt;&lt;b&gt;&lt;i&gt;[not including the quotes - ed]&lt;/i&gt;&lt;/b&gt;&lt;i&gt;, and reserved characters used for their reserved purposes may be used unencoded within a URL."&lt;/i&gt;&lt;/p&gt; &lt;p class="p1"&gt;实际上URL规范中，字符包括保留字符，非保留字符两种，RFC2396中定义了URL中的保留(reserved)字符为：&lt;/p&gt; &lt;p class="p3"&gt;
&lt;br /&gt;&lt;/p&gt; &lt;p class="p1"&gt;Reserved&lt;/p&gt; &lt;p class="p4"&gt;reserved    = ";" | "/" | "?" | ":" | "@" | "&amp;amp;" | "=" | "+" |&lt;/p&gt; &lt;p class="p4"&gt;                    "$" | ","&lt;/p&gt; &lt;p class="p1"&gt;非保留字符为：&lt;/p&gt; &lt;p class="p1"&gt;Unreserved&lt;/p&gt; &lt;p class="p1"&gt;unreserved  = alphanum | mark&lt;/p&gt; &lt;p class="p3"&gt;
&lt;br /&gt;&lt;/p&gt; &lt;p class="p1"&gt;      mark        = "-" | "_" | "." | "!" | "~" | "*" | "'" | "(" | ")"&lt;/p&gt; &lt;p class="p1"&gt; &lt;/p&gt; &lt;p class="p1"&gt;实际上非保留字符就是AscII character-set，此集合之外的字符都被称为非法字符（invalid character)或不安全字符(unsafe character)，这些字符都将被编码转换为合法字符(valid character)或叫安全字符(safe charactor)，转换的动作在英文常表示为escape。&lt;/p&gt; &lt;p class="p1"&gt;escape的方式如下规范中所述：&lt;/p&gt; &lt;p class="p1"&gt; &lt;/p&gt; &lt;p class="p1"&gt;Escaped Encoding&lt;/p&gt; &lt;p class="p1"&gt;An escaped octet is encoded as a character triplet, consisting of the&lt;/p&gt; &lt;p class="p1"&gt;   percent character "%" followed by the two hexadecimal digits&lt;/p&gt; &lt;p class="p1"&gt;   representing the octet code. For example, "%20" is the escaped&lt;/p&gt; &lt;p class="p1"&gt;   encoding for the US-ASCII space character.&lt;/p&gt; &lt;p class="p3"&gt;
&lt;br /&gt;&lt;/p&gt; &lt;p class="p1"&gt;      escaped     = "%" hex hex&lt;/p&gt; &lt;p class="p1"&gt;      hex         = digit | "A" | "B" | "C" | "D" | "E" | "F" |&lt;/p&gt; &lt;p class="p1"&gt;                            "a" | "b" | "c" | "d" | "e" | "f"&lt;/p&gt; &lt;p class="p1"&gt; &lt;/p&gt; &lt;p class="p1"&gt;转换时使用的字符集为ISO-8859-1也称为ISO-Latin或Latin-1，注意不是Unicode，这就引起了新的问题，对于不在ISO-Latin中的符号，就没有一个安全的途径进行编码，因为根据RFC2396（注意这是URI规范，但是对URL适用，因为URL是URI的子集，有兴趣的读者请查阅URL和URI之间的关系），URL里还无法指定自定义的字符集(比如UTF-8)。&lt;/p&gt; &lt;p class="p1"&gt;虽然根据标准，在URL中我们无法使用非ISO-Latin字符集以外的字符，但是在现实中，为了解决实际问题，大家都有事实上的标准那就是Unicode编码，现行的为UTF-8，现在浏览器都支持UTF-8的URL编码转换，当然，这个时候的转换动作不再叫escape，而是称为URIEncode。另外，UTF-8与Latin-1是兼容的，相关的信息可参考：&lt;/p&gt; &lt;ul class="ul1"&gt; &lt;li class="li2"&gt;&lt;a href="http://www.stanford.edu/~laurik/fsmbook/faq/utf8.html"&gt;http://www.stanford.edu/~laurik/fsmbook/faq/utf8.html&lt;/a&gt;&lt;/li&gt; &lt;li class="li2"&gt;&lt;a href="http://baike.baidu.com/view/25412.htm"&gt;http://baike.baidu.com/view/25412.htm&lt;/a&gt;&lt;/li&gt; &lt;li class="li2"&gt;&lt;a href="http://www.permadi.com/tutorial/urlEncoding/"&gt;http://www.permadi.com/tutorial/urlEncoding/&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; &lt;p class="p2"&gt;&lt;span class="s1"&gt;PHP与Javascript相关的URIEncode操作请参见：&lt;a href="http://blog.verymore.com/show-989-1.html"&gt;&lt;span class="s2"&gt;http://blog.verymore.com/show-989-1.html&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt; &lt;p class="p5"&gt;&lt;b&gt;GWT的URL编码与解码&lt;/b&gt;&lt;/p&gt; &lt;p class="p1"&gt;使用URL类中的静态方法URL.decode 和 URL.encode来进行。&lt;/p&gt; &lt;p class="p6"&gt;java.lang.Object&lt;/p&gt; &lt;p class="p6"&gt;  &lt;b&gt;com.google.gwt.http.client.URL&lt;/b&gt; &lt;/p&gt; &lt;table width="776.0" cellspacing="0" cellpadding="0" class="t1"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td colspan="2" valign="middle" class="td1"&gt; &lt;p class="p7"&gt;&lt;b&gt;Method Summary&lt;/b&gt;&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" class="td2"&gt; &lt;p class="p8"&gt;static java.lang.String&lt;/p&gt; &lt;/td&gt; &lt;td valign="middle" class="td3"&gt; &lt;p class="p9"&gt;&lt;span class="s2"&gt;&lt;a href="http://www.cnblogs.com/com/google/gwt/http/client/URL.html#decode(java.lang.String)"&gt;&lt;b&gt;decode&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;(java.lang.String encodedURL)&lt;span class="s3"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p class="p10"&gt;          Returns a string where all URL escape sequences have been converted back to their original character representations.&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" class="td2"&gt; &lt;p class="p8"&gt;static java.lang.String&lt;/p&gt; &lt;/td&gt; &lt;td valign="middle" class="td3"&gt; &lt;p class="p9"&gt;&lt;span class="s2"&gt;&lt;a href="http://www.cnblogs.com/com/google/gwt/http/client/URL.html#decodeComponent(java.lang.String)"&gt;&lt;b&gt;decodeComponent&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;(java.lang.String encodedURLComponent)&lt;span class="s3"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p class="p10"&gt;          Returns a string where all URL component escape sequences have been converted back to their original character representations.&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" class="td2"&gt; &lt;p class="p8"&gt;static java.lang.String&lt;/p&gt; &lt;/td&gt; &lt;td valign="middle" class="td3"&gt; &lt;p class="p9"&gt;&lt;span class="s2"&gt;&lt;a href="http://www.cnblogs.com/com/google/gwt/http/client/URL.html#encode(java.lang.String)"&gt;&lt;b&gt;encode&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;(java.lang.String decodedURL)&lt;span class="s3"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p class="p10"&gt;          Returns a string where all characters that are not valid for a complete URL have been escaped.&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" class="td2"&gt; &lt;p class="p8"&gt;static java.lang.String&lt;/p&gt; &lt;/td&gt; &lt;td valign="middle" class="td3"&gt; &lt;p class="p9"&gt;&lt;span class="s2"&gt;&lt;a href="http://www.cnblogs.com/com/google/gwt/http/client/URL.html#encodeComponent(java.lang.String)"&gt;&lt;b&gt;encodeComponent&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;(java.lang.String decodedURLComponent)&lt;span class="s3"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p class="p10"&gt;          Returns a string where all characters that are not valid for a URL component have been escaped.&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;p class="p5"&gt;&lt;b&gt;GAE4Java的编码与解码&lt;/b&gt;&lt;/p&gt; &lt;p class="p2"&gt;&lt;span class="s1"&gt;实际上，由于写本文的初衷是作者在这个环境下开发程序时想理清这个问题，所以将服务器环境定位为GAE，实际上就是Java下的URL编码问题，可以参考：&lt;a href="http://china.manufacturer.com/article/study_for_character_encoding_java.htm"&gt;&lt;span class="s2"&gt;http://china.manufacturer.com/article/study_for_character_encoding_java.htm&lt;/span&gt;&lt;/a&gt;。&lt;/span&gt;&lt;/p&gt; &lt;p class="p1"&gt;Java中URI Encoding的相关类为URLEncoder，URLDecoder&lt;/p&gt; &lt;p class="p1"&gt;示例：&lt;/p&gt; &lt;p class="p11"&gt;&lt;span class="s4"&gt;1&lt;/span&gt;&lt;span class="s1"&gt; &lt;/span&gt;String text = java.net.URLEncoder.encode("编码转换", "utf-8");&lt;/p&gt; &lt;p class="p1"&gt; &lt;/p&gt; &lt;p class="p1"&gt;&lt;span class="s2"&gt;&lt;a href="http://gceclub.sun.com.cn/Java_Docs/html/zh_CN/api/java/lang/Object.html"&gt;java.lang.Object&lt;/a&gt;&lt;/span&gt;
&lt;br /&gt;&lt;b&gt;java.net.URLEncoder&lt;/b&gt;&lt;/p&gt; &lt;p class="p3"&gt;
&lt;br /&gt;&lt;/p&gt; &lt;table width="776.0" cellspacing="0" cellpadding="0" class="t1"&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td colspan="2" valign="middle" class="td1"&gt; &lt;p class="p7"&gt;&lt;b&gt;Method Summary&lt;/b&gt;&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td valign="top" class="td4"&gt; &lt;p class="p12"&gt;static &lt;a href="http://gceclub.sun.com.cn/Java_Docs/html/zh_CN/api/java/lang/String.html"&gt;&lt;span class="s2"&gt;String&lt;/span&gt;&lt;/a&gt;&lt;/p&gt; &lt;/td&gt; &lt;td valign="middle" class="td5"&gt; &lt;p class="p13"&gt;&lt;a href="http://gceclub.sun.com.cn/Java_Docs/html/zh_CN/api/java/net/URLEncoder.html#encode(java.lang.String,%20java.lang.String)"&gt;&lt;b&gt;encode&lt;/b&gt;&lt;/a&gt;&lt;span class="s1"&gt;(&lt;a href="http://gceclub.sun.com.cn/Java_Docs/html/zh_CN/api/java/lang/String.html"&gt;&lt;span class="s5"&gt;String&lt;/span&gt;&lt;/a&gt; s, &lt;a href="http://gceclub.sun.com.cn/Java_Docs/html/zh_CN/api/java/lang/String.html"&gt;&lt;span class="s5"&gt;String&lt;/span&gt;&lt;/a&gt; enc)&lt;/span&gt;&lt;span class="s6"&gt; &lt;/span&gt;&lt;/p&gt; &lt;p class="p6"&gt;&lt;span class="s7"&gt;          使用指定的编码机制将字符串转换为 &lt;/span&gt;application/x-www-form-urlencoded&lt;span class="s7"&gt; 格式。&lt;/span&gt;&lt;/p&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;p class="p3"&gt;
&lt;br /&gt;&lt;/p&gt; &lt;p class="p1"&gt;URLDecoder此处略去，同上。&lt;/p&gt; &lt;p class="p1"&gt;【完】&lt;/p&gt;&lt;/div&gt;source: &lt;div&gt;http://www.cnblogs.com/dengfanxin/archive/2009/04/16/GAE_UrlEncoding.html&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/272429821527780388-5611205603121089424?l=codestandup.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/r3ehBKVCY4G92XSp4-MYAMb8mjY/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/r3ehBKVCY4G92XSp4-MYAMb8mjY/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/r3ehBKVCY4G92XSp4-MYAMb8mjY/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/r3ehBKVCY4G92XSp4-MYAMb8mjY/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Code-standup/~4/t129yOSymiA" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://codestandup.blogspot.com/feeds/5611205603121089424/comments/default" title="張貼意見" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=272429821527780388&amp;postID=5611205603121089424" title="0 個意見" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/272429821527780388/posts/default/5611205603121089424?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/272429821527780388/posts/default/5611205603121089424?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Code-standup/~3/t129yOSymiA/google-app-engine-for-javaurl.html" title="Google App Engine for Java下的URL編碼轉換問題" /><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14778696620700587607" /></author><thr:total>0</thr:total><feedburner:origLink>http://codestandup.blogspot.com/2011/02/google-app-engine-for-javaurl.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0QBQXo7fCp7ImA9Wx9UGE8.&quot;"><id>tag:blogger.com,1999:blog-272429821527780388.post-2251310430432806959</id><published>2011-02-15T19:01:00.000-08:00</published><updated>2011-02-15T19:02:30.404-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-02-15T19:02:30.404-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><title>房产地图google map的初步应用点滴.1)</title><content type="html">&lt;span class="Apple-style-span" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 17px; "&gt;以前的房产地图一直都是使用有道地图，虽然有道地图是很好，但是为了更好，还是决定使用google地图来重新开发^_^，下面是一个开发完毕的简单应用http://xf.house.163.com/gz/map/000B.html
&lt;br /&gt;
&lt;br /&gt;&lt;strong&gt;1)整合Google Maps JavaScript API V3 与 Google Local Search API&lt;/strong&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;strong&gt;Google Maps JavaScript API V3 &lt;/strong&gt;
&lt;br /&gt;地址 http://code.google.com/intl/zh-CN/apis/maps/documentation/javascript/
&lt;br /&gt;
&lt;br /&gt;Google Maps JavaScript API V3 文档读起来真的是很清晰，各种demo也很齐全，并且论坛的拥有巨大的论坛支持，对比了一下Google Maps JavaScript API V3 和 V2 的版本，虽然第3版的 Google Maps API 看上去跟第2版挺相识，但在内在机制上有了较大的变化，尤其在对移动浏览器的支持上，专门针对iphone和android设备的开发。V2版本google已经宣布不再予以继续支持，所以还是选择了V3版本。
&lt;br /&gt;
&lt;br /&gt;&lt;strong&gt;Google Local Search API&lt;/strong&gt;
&lt;br /&gt;地址 http://code.google.com/intl/zh-CN/apis/maps/documentation/localsearch/index.html
&lt;br /&gt;
&lt;br /&gt;上面的地址是目前Local Search的最新地址，但郁闷的是居然挂上了 Deprecated ，一样的文档也相当齐全，在应用之前需要先为你的域名申请一个API key，这个是注册地址http://code.google.com/intl/zh-CN/apis/maps/signup.html，很简单，按照提示很快就搞定了。
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;在整合Google Maps JavaScript API V3和Google Local Search API发现这两个版本是不兼容的，Local Search API实际上还是沿用了Maps V2的接口，为了解决这个问题，需要中间一个跳板使得两者兼容，所以选择了iframe，父页面使用Google Maps V3，子页面使用Local Search API，当需要应用到本地搜索时，父页面向子页面传递查询条件，子窗口应用Local Search API获得查询的result后返回给父页面，这样就形成一个跳板，避免了两者因为版本问题而产生的冲突，当然还有其他的办法，不过iframe应该是比较简单处理，下面是一个demo
&lt;br /&gt;
&lt;br /&gt;&lt;img alt="" src="http://www.blogjava.net/images/blogjava_net/dongbule/map/map1.png" /&gt;
&lt;br /&gt;
&lt;br /&gt;父页面 : 使用的是Google Maps JavaScript API V3，http://maps.google.com/maps/api/js 网址指向 Javascript 文件所在的位置，该文件会载入使用第 3 版 Google Maps API 所需的全部符号和定义。
&lt;br /&gt;
&lt;br /&gt;&lt;div style="background-color: rgb(238, 238, 238); font-size: 13px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-bottom-color: rgb(204, 204, 204); border-left-color: rgb(204, 204, 204); padding-top: 4px; padding-right: 5px; padding-bottom: 4px; padding-left: 4px; width: 629px; "&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&lt;!&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(255, 0, 255); "&gt;DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); "&gt;
&lt;br /&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&lt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); "&gt;html &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); "&gt;xmlns&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;="http://www.w3.org/1999/xhtml"&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); "&gt;
&lt;br /&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&lt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); "&gt;head&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); "&gt;
&lt;br /&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&lt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); "&gt;meta &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); "&gt;http-equiv&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;="content-type"&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); "&gt; content&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;="text/html; charset=GBK"&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;/&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); "&gt;
&lt;br /&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&lt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); "&gt;title&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); "&gt;Google AJAX Search API Sample&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&lt;/&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); "&gt;title&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); "&gt;
&lt;br /&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&lt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); "&gt;style &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); "&gt;type&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;="text/css"&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(128, 0, 0); "&gt;
&lt;br /&gt;@import url("http://www.google.com/uds/css/gsearch.css");
&lt;br /&gt;@import url("http://www.google.com/uds/solutions/localsearch/gmlocalsearch.css");
&lt;br /&gt;@import url("http://www.google.com/uds/css/gsearch.css");
&lt;br /&gt;@import url("http://www.google.com/uds/solutions/localsearch/gmlocalsearch.css");
&lt;br /&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&lt;/&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); "&gt;style&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); "&gt;
&lt;br /&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&lt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); "&gt;script &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); "&gt;type&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;="text/javascript"&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); "&gt; src&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;="http://xf.house.163.com/product/js/jquery.js"&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&gt;&lt;/&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); "&gt;script&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); "&gt;
&lt;br /&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&lt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); "&gt;script &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); "&gt;type&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;="text/javascript"&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); "&gt; src&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;="http://maps.google.com/maps/api/js?sensor=false"&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&gt;&lt;/&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); "&gt;script&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); "&gt;
&lt;br /&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&lt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); "&gt;script &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); "&gt;type&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;="text/javascript"&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;
&lt;br /&gt;      &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); "&gt;var&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; map;
&lt;br /&gt;      &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); "&gt;var&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; lat &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;23.116193&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;;
&lt;br /&gt;      &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); "&gt;var&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; lng &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;113.374525&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;;
&lt;br /&gt;      &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); "&gt;var&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; markersArray &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; [];
&lt;br /&gt;      &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); "&gt;var&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; windowArray &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; [];
&lt;br /&gt;      &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); "&gt;function&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; initialize() {
&lt;br /&gt;        &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); "&gt;var&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; mapDiv &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; document.getElementById('map&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;-&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;canvas');
&lt;br /&gt;          map &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); "&gt;new&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; google.maps.Map(mapDiv, {
&lt;br /&gt;          center: &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); "&gt;new&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; google.maps.LatLng(lat,lng),
&lt;br /&gt;          zoom: &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;15&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;,
&lt;br /&gt;          mapTypeId: google.maps.MapTypeId.ROADMAP
&lt;br /&gt;        });
&lt;br /&gt;      }
&lt;br /&gt;
&lt;br /&gt;      &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 128, 0); "&gt;//&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 128, 0); "&gt;删除叠加层&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 128, 0); "&gt;
&lt;br /&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;      &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); "&gt;function&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; deleteOverlays() {
&lt;br /&gt;          &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); "&gt;if&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; (markersArray) {
&lt;br /&gt;            &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); "&gt;for&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; (i &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); "&gt;in&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; markersArray) {
&lt;br /&gt;              markersArray[i].setMap(&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); "&gt;null&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;);
&lt;br /&gt;            }
&lt;br /&gt;            markersArray.length &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;0&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;;
&lt;br /&gt;          }
&lt;br /&gt;      }
&lt;br /&gt;
&lt;br /&gt;      &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 128, 0); "&gt;//&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 128, 0); "&gt;关闭信息提示窗口&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 128, 0); "&gt;
&lt;br /&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;      &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); "&gt;function&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; closeWindows() {
&lt;br /&gt;          &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); "&gt;if&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; (windowArray) {
&lt;br /&gt;            &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); "&gt;for&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; (i &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); "&gt;in&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; windowArray) {
&lt;br /&gt;                windowArray[i].close();
&lt;br /&gt;            }
&lt;br /&gt;          }
&lt;br /&gt;         }
&lt;br /&gt;     
&lt;br /&gt;      &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); "&gt;function&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; show(results){
&lt;br /&gt;          parent.deleteOverlays();
&lt;br /&gt;          windowArray.length &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;0&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;;
&lt;br /&gt;          &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); "&gt;for&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; (&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); "&gt;var&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; i &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;0&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;; results &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; i &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;&lt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; results.length; i&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;++&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;) {
&lt;br /&gt;              showOne(results[i]);
&lt;br /&gt;          }
&lt;br /&gt;      }
&lt;br /&gt;      &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); "&gt;function&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; showOne(result){
&lt;br /&gt;          &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 128, 0); "&gt;//&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 128, 0); "&gt;console.debug(result.title+","+result.lat+":" + result.lng +","+result.streetAddress+","+result.city+","+result.url);&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 128, 0); "&gt;
&lt;br /&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;          &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); "&gt;var&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; infowindow &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); "&gt;new&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; google.maps.InfoWindow({
&lt;br /&gt;              content: result.html
&lt;br /&gt;            });
&lt;br /&gt;            &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); "&gt;var&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; marker &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); "&gt;new&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; google.maps.Marker({
&lt;br /&gt;                position: &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); "&gt;new&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; google.maps.LatLng(result.lat,result.lng),
&lt;br /&gt;              map: map
&lt;br /&gt;            });
&lt;br /&gt;            markersArray.push(marker);
&lt;br /&gt;            windowArray.push(infowindow);
&lt;br /&gt;            google.maps.event.addListener(marker, 'click', &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); "&gt;function&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;() {
&lt;br /&gt;              closeWindows();
&lt;br /&gt;                infowindow.open(map,marker);
&lt;br /&gt;            });
&lt;br /&gt;      }
&lt;br /&gt;      &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); "&gt;function&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; searchMap(){
&lt;br /&gt;          &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); "&gt;var&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; keyWord &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; document.getElementById(&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;keyWord&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;"&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;).value;
&lt;br /&gt;          mapIframe.window.loadMap(&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;23.116193&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;,&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;113.374525&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;,keyWord);
&lt;br /&gt;      }
&lt;br /&gt;      google.maps.event.addDomListener(window, 'load', initialize);
&lt;br /&gt;    &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&lt;/&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); "&gt;script&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); "&gt;
&lt;br /&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&lt;/&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); "&gt;head&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); "&gt;
&lt;br /&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&lt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); "&gt;body &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); "&gt;style&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;=""&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); "&gt;
&lt;br /&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&lt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); "&gt;div &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); "&gt;id&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;="map-canvas"&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); "&gt; style&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;="width: 600px; height: 500px"&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&gt;&lt;/&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); "&gt;div&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); "&gt;
&lt;br /&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&lt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); "&gt;input &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); "&gt;type&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;="text"&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); "&gt; name&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;="keyWord"&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); "&gt; id&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;="keyWord"&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;/&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); "&gt;
&lt;br /&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&lt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); "&gt;input &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); "&gt;type&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;="button"&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); "&gt; onclick&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;="searchMap();"&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); "&gt; value&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;="查询"&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); "&gt; id&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;="btn"&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;/&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); "&gt;
&lt;br /&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 128, 0); "&gt;&lt;!--&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 128, 0); "&gt; 子页面 &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 128, 0); "&gt;--&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); "&gt;
&lt;br /&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&lt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); "&gt;iframe &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); "&gt;name&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;="mapIframe"&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); "&gt; id&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;="mapIframe"&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); "&gt; style&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;="display:none"&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); "&gt; src&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;="local.html"&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&gt;&lt;/&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); "&gt;iframe&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); "&gt;
&lt;br /&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&lt;/&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); "&gt;body&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); "&gt;
&lt;br /&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&lt;/&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); "&gt;html&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;子页面：http://www.google.com/jsapi?key 需要在google进行申请与域名绑定
&lt;br /&gt;
&lt;br /&gt;&lt;div style="background-color: rgb(238, 238, 238); font-size: 13px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(204, 204, 204); border-right-color: rgb(204, 204, 204); border-bottom-color: rgb(204, 204, 204); border-left-color: rgb(204, 204, 204); padding-top: 4px; padding-right: 5px; padding-bottom: 4px; padding-left: 4px; width: 629px; "&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&lt;!&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(255, 0, 255); "&gt;DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); "&gt;
&lt;br /&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&lt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); "&gt;html &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); "&gt;xmlns&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;="http://www.w3.org/1999/xhtml"&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); "&gt;
&lt;br /&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&lt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); "&gt;head&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); "&gt;
&lt;br /&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&lt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); "&gt;meta &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); "&gt;http-equiv&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;="content-type"&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); "&gt; content&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;="text/html; charset=GBK"&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;/&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); "&gt;
&lt;br /&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 128, 0); "&gt;&lt;!--&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 128, 0); "&gt; 此api key为域名163.com &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 128, 0); "&gt;--&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); "&gt;
&lt;br /&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&lt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); "&gt;script &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); "&gt;src&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;="http://www.google.com/jsapi?key=ABQIAAAAtV_DTJOYJT-9cvTO-5KJ2BSnjw5qeDlzCnItJoREFggHbBwu_RQBEyFqvq_vMlzqsS4afIB8ZIvMkw"&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); "&gt; type&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;="text/javascript"&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&gt;&lt;/&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); "&gt;script&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); "&gt;
&lt;br /&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&lt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); "&gt;script &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(255, 0, 0); "&gt;type&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;="text/javascript"&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;
&lt;br /&gt;    google.load('search', '&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;1&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;');
&lt;br /&gt;    google.load('maps', '&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;2&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;');
&lt;br /&gt;
&lt;br /&gt;    &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); "&gt;function&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; loadMap(lat,lng,keyWord) {
&lt;br /&gt;        &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); "&gt;var&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; point &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); "&gt;new&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; GLatLng(lat,lng);
&lt;br /&gt;        searchMap(point,keyWord);
&lt;br /&gt;    }
&lt;br /&gt;       
&lt;br /&gt;    &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); "&gt;function&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; searchMap(point,keyWord){
&lt;br /&gt;        &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); "&gt;var&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; searcher &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;=&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); "&gt;new&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt; google.search.LocalSearch();
&lt;br /&gt;        searcher.setCenterPoint(point);
&lt;br /&gt;        searcher.setResultSetSize(&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;8&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;);
&lt;br /&gt;    &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 128, 0); "&gt;//&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 128, 0); "&gt;searcher.setRestriction(google.search.Search.RESTRICT_TYPE, google.search.LocalSearch.TYPE_KMLONLY_RESULTS)&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 128, 0); "&gt;
&lt;br /&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;        searcher.setSearchCompleteCallback(&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); "&gt;this&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;, &lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 255); "&gt;function&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; background-color: rgb(245, 245, 245); color: rgb(0, 0, 0); "&gt;() {
&lt;br /&gt;          parent.MapApi.showSearch_Markers(searcher.results,keyWord);
&lt;br /&gt;        });
&lt;br /&gt;        searcher.execute(keyWord);
&lt;br /&gt;    }
&lt;br /&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&lt;/&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); "&gt;script&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); "&gt;
&lt;br /&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&lt;/&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); "&gt;head&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); "&gt;
&lt;br /&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&lt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); "&gt;body&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&gt;&lt;/&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); "&gt;body&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); "&gt;
&lt;br /&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&lt;/&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(128, 0, 0); "&gt;html&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 255); "&gt;&gt;&lt;/span&gt;&lt;span style="line-height: 15px; font-size: 13px; color: rgb(0, 0, 0); "&gt;
&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;摘录几个常用的Local Search API Reference
&lt;br /&gt;
&lt;br /&gt;new google.search.LocalSearch() : 创建了一个LocalSearch的Service
&lt;br /&gt;
&lt;br /&gt;searcher.setCenterPoint(point) : 它接受单一变量，该变量可以是字符串、google.maps.Map2 或google.maps.LatLng。如果是字符串，会尝试将字符串解析为 google.maps.LatLng
&lt;br /&gt;
&lt;br /&gt;searcher.setResultSetSize(8) : 调用此方法以选择由每个搜索器返回的结果数
&lt;br /&gt;
&lt;br /&gt;searcher.setRestriction() : 设置搜索结构类型
&lt;br /&gt;
&lt;br /&gt;searcher.setSearchCompleteCallback() :　此方法用于注册对象和方法以通知搜索完成。应用程序可以通过使用 opt_arguments之后随意传入环境参数
&lt;br /&gt;
&lt;br /&gt;searcher.execute(keyWord) :  调用此方法以开始新的搜索　
&lt;br /&gt;
&lt;br /&gt;第一步解决了map和local search的版本冲突后，下面可以进行全部的开发，Google Maps JavaScript API提供的UI，EVENT相关接口非常之多，但不一定就能直接适用我们的需求，还需要使用继承基类MVCObject，OverlayView等继续封装。&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 17px; "&gt;
&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 17px; "&gt;source: &lt;a href="http://www.blogjava.net/dongbule/archive/2011/02/12/344141.html"&gt;http://www.blogjava.net/dongbule/archive/2011/02/12/344141.html&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/272429821527780388-2251310430432806959?l=codestandup.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/yPYYV5NTPAe_P0KcYyvc6obyhl0/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/yPYYV5NTPAe_P0KcYyvc6obyhl0/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/yPYYV5NTPAe_P0KcYyvc6obyhl0/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/yPYYV5NTPAe_P0KcYyvc6obyhl0/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Code-standup/~4/5yo9MY1GNLs" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://codestandup.blogspot.com/feeds/2251310430432806959/comments/default" title="張貼意見" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=272429821527780388&amp;postID=2251310430432806959" title="0 個意見" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/272429821527780388/posts/default/2251310430432806959?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/272429821527780388/posts/default/2251310430432806959?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Code-standup/~3/5yo9MY1GNLs/google-map1.html" title="房产地图google map的初步应用点滴.1)" /><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14778696620700587607" /></author><thr:total>0</thr:total><feedburner:origLink>http://codestandup.blogspot.com/2011/02/google-map1.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0UHRXY8eyp7ImA9Wx9XF0Q.&quot;"><id>tag:blogger.com,1999:blog-272429821527780388.post-8653704541913456183</id><published>2011-01-11T18:25:00.000-08:00</published><updated>2011-01-11T18:27:14.873-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-01-11T18:27:14.873-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Database" /><title>Oracle migrate to MySQL</title><content type="html">一、從Oracle移植到MySQL主要有六個方面的內容需要移植，一是表Table，包括表結構和數據，二是觸發器Trigger，三是存儲過程Procedure，函數function和包Package，四是任務Job ，五是用戶等其他方面的移植，六是具體應用程序通過SQL語句訪問時的細節差異克服。筆者用來移植測試的數據庫是：Oracle 9i ，MySQL 6.0，Windows 2000環境。 &lt;br /&gt;&lt;br /&gt;二、經過映射轉換，比如number會轉換為double，date轉換為timestamp等，請小心處理日期字段的默認值等，表的主鍵，表的索引(Oracle的位圖索引會被轉成BTree索引，另外表和字段的註釋會丟失)等信息。需要特別注意的是，Oracle的自增字段的處理。提供字段自增屬性。 &lt;br /&gt;三、觸發器的移植首先，MySQL在6.0以後才支持觸發器！觸發器的移植沒有現成工具，因為兩者之間的語法差異較大，您只能通過手工對照著原來的邏輯一個一個添加。 &lt;br /&gt;四、存儲過程，函數和程序包的移植程序包是Oracle用來組織邏輯功能的一個Object，MySQL不支持，因此需要將包裡的存儲過程﹑函數等全部放到該數據庫公有過程和函數里面。 &lt;br /&gt;&lt;br /&gt;五、Job的移植Job是Oracle的定時任務實現的方法，MySQL6中用Event實現，具體語法請參考MySQL手冊。 &lt;br /&gt;&lt;br /&gt;六、用戶的移植Oracle的用戶管理和MySQL下有較大區別，請分別建立用戶，並賦予合適的權限。 &lt;br /&gt;&lt;br /&gt;七、應用程序的移植由於語法細節上的差異，導致很多SQL語句需要改寫。筆者記下了所有移植過程中碰到的SQL語句細節差異,列出來以供參考： &lt;br /&gt;1）Oracle的to_char函數不能再使用，換用如CONCAT(14.3)的形式，為了提高應用程序兼容性，建議手工寫一個 &lt;br /&gt;2）Oracle的to_date函數不能再使用，建議手工寫一個添加到MySQL數據庫 &lt;br /&gt;   eg: &lt;br /&gt;to_char(sysdate,'yyyy-mm-dd')--&gt;date_format(sysdate(),'%Y-%m-%d'); &lt;br /&gt;to_date(sysdate,'yyyy-mm-dd')--&gt;STR_TO_DATE(sysdate(),'%Y-%m-%d'); &lt;br /&gt;to_char(add_months(to_date ('20000101','yyyymmdd'),1),'yyyy-mm-dd')--&gt;date_add('2000-01-01',interval 1 month); &lt;br /&gt;&lt;br /&gt;3）Oracle的decode函數不能再使用，換用SELECT CASE 1 WHEN 1 THEN 'one' WHEN 2 THEN 'two' ELSE 'more' END 的形式 &lt;br /&gt;4)nvl這樣的一些專用函數，MySQL是沒有的，可以把select nvl(to_char(num),'nothing') from t_equipment轉換成select case num when num then num else 'nothing' end from t_equipment &lt;br /&gt;5）instr之類的函數，函數名相同，但參數個數不同 &lt;br /&gt;6）Oracle的sysdate要寫成sysdate()的形式 &lt;br /&gt;7）包的形式已經取消，所以原來以包的方式調用的過程如xx_pack.xxx要寫成xxx() &lt;br /&gt;8）帶進製字符轉數字Oracle風格：TO_NUMBER(strTmp,'XX') TO_NUMBER（'9'）MySQL風格：CONV(strTmp,16,10) CONV('9',10,10) 如果字符串前後有加減操作，會隱含轉換成數字 &lt;br /&gt;9) 不能再有直接調用序列的形式，如果一定需要，可以模擬實現一個 &lt;br /&gt;10）日期直接加減的含義不同了，比如Oracle中sysdate + 1 變成了sysdate() + interval 1 day（注意如果寫成sysdate() + 1 語法還是正確的，但含義是錯誤的）查詢select sysdate() + 1 from dual 在MySQL得到比如20080223153234（= 20080223153233 + 1）的數而在Oracle中會得到第二天當前時刻。 &lt;br /&gt;11) MySQL單純的date類型只是日期不帶時間，DATETIME或TIMESTAMP帶有時間，用DATE_FORMAT函數可以控制顯示形式 &lt;br /&gt;12）select 'abc' || 'd' from dual 兩個數據執行的結果不同（語法都能通過），MySQL要寫成select concat('abc' , 'd')的形式 &lt;br /&gt;13) Oracle高級功能，如帶有暗示索引的select語句，MySQL是不支持的（語法可以通過） &lt;br /&gt;14）有些MySQL的保留字不能直接用在SQL語句裡,要加表名或別名限制，如select RIGHT FROM XX要改成select a.RIGHT FROM XX a &lt;br /&gt;15) Oracle的子查詢可以不起別名，但MySQL是必須的，比如下面的別名aa：select field1 from (select sysdate() as field1 from dual) as aa &lt;br /&gt;16）很多系統表名都是不同的,比如，列出某個表的信息：select * from tab where TName='T_TEST'改成select table_name,table_type from information_schema.tables where table_schema = 'user' and table_name= ' T_TEST ' &lt;br /&gt;17）MySQL下update時不能有本身的子查詢update T_TEST set Flag = 0 where field1 in &lt;br /&gt;(select distinct b.field1 from T_TEST b where b.flag=1) &lt;br /&gt;18）Oracle下''和null等價，而MySQL則不然select 1 from dual where '' is null在Oracle下可以取到記錄，在MySQL下不能dual表的使用，substr、trim等函數的主要使用方式和Oracle類似 &lt;br /&gt;&lt;br /&gt;八、小結和建議看起來，Oracle移植到MySQL似乎挺麻煩，有沒有一鍵完成的簡單辦法？呵呵，我沒有找到，除非您只使用基本表，只使用基本SQL語句訪問它。&lt;br /&gt;&lt;br /&gt;source: http://shshy39.javaeye.com/blog/342512&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/272429821527780388-8653704541913456183?l=codestandup.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/2KdM4837-2V81klPPjtwipVTEeM/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/2KdM4837-2V81klPPjtwipVTEeM/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/2KdM4837-2V81klPPjtwipVTEeM/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/2KdM4837-2V81klPPjtwipVTEeM/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Code-standup/~4/BmLTAx9Jr60" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://codestandup.blogspot.com/feeds/8653704541913456183/comments/default" title="張貼意見" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=272429821527780388&amp;postID=8653704541913456183" title="0 個意見" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/272429821527780388/posts/default/8653704541913456183?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/272429821527780388/posts/default/8653704541913456183?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Code-standup/~3/BmLTAx9Jr60/oracle-migrate-to-mysql.html" title="Oracle migrate to MySQL" /><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14778696620700587607" /></author><thr:total>0</thr:total><feedburner:origLink>http://codestandup.blogspot.com/2011/01/oracle-migrate-to-mysql.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0EAQH0yeyp7ImA9Wx9XE0s.&quot;"><id>tag:blogger.com,1999:blog-272429821527780388.post-6834962383505993516</id><published>2011-01-06T18:47:00.000-08:00</published><updated>2011-01-06T19:07:21.393-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-01-06T19:07:21.393-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Database" /><title>ORA-00031: session marked for kill 處理Oracle中殺不掉的鎖</title><content type="html">一些ORACLE中的進程被殺掉後，狀態被置為"killed"，但是鎖定的資源很長時間不釋放，有時實在沒辦法，只好重啟數據庫。現在提供一種方法解決這種問題，那就是在ORACLE中殺不掉的，在OS一級再殺。 &lt;br /&gt;&lt;br /&gt;1.下面的語句用來查詢哪些對像被鎖： &lt;br /&gt;&lt;br /&gt;select object_name,machine,s.sid,s.serial# &lt;br /&gt;from v$locked_object l,dba_objects o ,v$session s &lt;br /&gt;where l.object_id　=　o.object_id and l.session_id=s.sid; &lt;br /&gt;2.下面的語句用來殺死一個進程： &lt;br /&gt;alter system kill session '24,111'; (其中24,111分別是上面查詢出的sid,serial#) &lt;br /&gt;【注】以上兩步，可以通過Oracle的管理控制台來執行。 &lt;br /&gt;3.如果利用上面的命令殺死一個進程後，進程狀態被置為"killed"，但是鎖定的資源很長時間沒有被釋放，那麼可以在os一級再殺死相應的進程（線程），首先執行下面的語句獲得進程（線程）號： &lt;br /&gt;select p.spid, osuser, s.program &lt;br /&gt;from v$session s,v$process p &lt;br /&gt;where s.paddr=p.addr and s.sid=24 （24是上面的sid） &lt;br /&gt;4.在OS上殺死這個進程（線程）： &lt;br /&gt;1)在unix上，用root身份執行命令: &lt;br /&gt;#kill -9 12345（即第3步查詢出的spid） &lt;br /&gt;2)在windows（unix也適用）用orakill殺死線程，orakill是oracle提供的一個可執行命令，語法為： &lt;br /&gt;orakill sid thread &lt;br /&gt;其中： &lt;br /&gt;sid：表示要殺死的進程屬於的實例名 &lt;br /&gt;thread：是要殺掉的線程號，即第3步查詢出的spid。 &lt;br /&gt;例：c:&gt;orakill orcl 12345 &lt;br /&gt;&lt;br /&gt;ORA-00031: session marked for kill &lt;br /&gt;&lt;br /&gt;Cause: The session specified in an ALTER SYSTEM KILL SESSION command cannot be killed immediately (because it is rolling back or blocked on a network operation), but it has been marked for kill. This means it will be killed as soon as possible after its current uninterruptible operation is done. &lt;br /&gt;Action: No action is required for the session to be killed, but further executions of the ALTER SYSTEM KILL SESSION command on this session may cause the session to be killed sooner. &lt;br /&gt;  &lt;br /&gt;kill -9 12345&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;source: http://unixboy.javaeye.com/blog/168346&lt;br /&gt;http://www.oracle-base.com/articles/misc/KillingOracleSessions.php&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/272429821527780388-6834962383505993516?l=codestandup.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/G_iuEQk4LaaJ58h45GU7wfpdWOk/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/G_iuEQk4LaaJ58h45GU7wfpdWOk/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/G_iuEQk4LaaJ58h45GU7wfpdWOk/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/G_iuEQk4LaaJ58h45GU7wfpdWOk/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Code-standup/~4/icSwQdwgLrs" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://codestandup.blogspot.com/feeds/6834962383505993516/comments/default" title="張貼意見" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=272429821527780388&amp;postID=6834962383505993516" title="0 個意見" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/272429821527780388/posts/default/6834962383505993516?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/272429821527780388/posts/default/6834962383505993516?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Code-standup/~3/icSwQdwgLrs/ora-00031-session-marked-for-kill.html" title="ORA-00031: session marked for kill 處理Oracle中殺不掉的鎖" /><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14778696620700587607" /></author><thr:total>0</thr:total><feedburner:origLink>http://codestandup.blogspot.com/2011/01/ora-00031-session-marked-for-kill.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Dk4BQ3kzfyp7ImA9Wx9XEkw.&quot;"><id>tag:blogger.com,1999:blog-272429821527780388.post-8597696743139406248</id><published>2011-01-05T00:06:00.000-08:00</published><updated>2011-01-05T00:09:12.787-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-01-05T00:09:12.787-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Database" /><category scheme="http://www.blogger.com/atom/ns#" term="MSSQL" /><title>T-SQL While Loop</title><content type="html">declare @Part_Id int&lt;br /&gt; declare @Category_Id int&lt;br /&gt; declare @Desc varchar(50)&lt;br /&gt; create table PART (Part_Id int, Category_Id int, Description varchar(50))&lt;br /&gt; set @Part_Id = 0&lt;br /&gt; set @Category_Id = 0 &lt;br /&gt; while @Part_Id &lt; 2&lt;br /&gt; begin&lt;br /&gt;   set @Part_Id = @Part_Id + 1&lt;br /&gt;   while @Category_Id &lt; 3&lt;br /&gt;   begin &lt;br /&gt;     set @Category_Id = @Category_Id + 1&lt;br /&gt;     set @Desc = 'Part_Id is ' + cast(@Part_Id as char(1)) +&lt;br /&gt;                 ' Category_Id ' + cast(@Category_Id as char(1))&lt;br /&gt;     insert into PART values(@Part_Id, &lt;br /&gt;                             @Category_Id,&lt;br /&gt;                             @Desc )&lt;br /&gt;   end  &lt;br /&gt;   set @Category_Id = 0 &lt;br /&gt; end&lt;br /&gt; select * from PART&lt;br /&gt; drop table PART&lt;br /&gt;Here is the output from the SELECT statement at the bottom of this nested WHILE loop example.&lt;br /&gt;&lt;br /&gt; Part_Id     Category_Id Description                                        &lt;br /&gt; ----------- ----------- ----------------------------------------- &lt;br /&gt; 1           1           Part_Id is 1 Category_Id 1&lt;br /&gt; 1           2           Part_Id is 1 Category_Id 2&lt;br /&gt; 1           3           Part_Id is 1 Category_Id 3&lt;br /&gt; 2           1           Part_Id is 2 Category_Id 1&lt;br /&gt; 2           2           Part_Id is 2 Category_Id 2&lt;br /&gt; 2           3           Part_Id is 2 Category_Id 3&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/272429821527780388-8597696743139406248?l=codestandup.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/8Qpln15pN-I9TyBm1ppby-1SGvY/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/8Qpln15pN-I9TyBm1ppby-1SGvY/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/8Qpln15pN-I9TyBm1ppby-1SGvY/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/8Qpln15pN-I9TyBm1ppby-1SGvY/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Code-standup/~4/9ZPzlcUpBKI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://codestandup.blogspot.com/feeds/8597696743139406248/comments/default" title="張貼意見" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=272429821527780388&amp;postID=8597696743139406248" title="0 個意見" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/272429821527780388/posts/default/8597696743139406248?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/272429821527780388/posts/default/8597696743139406248?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Code-standup/~3/9ZPzlcUpBKI/t-sql-while-loop.html" title="T-SQL While Loop" /><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14778696620700587607" /></author><thr:total>0</thr:total><feedburner:origLink>http://codestandup.blogspot.com/2011/01/t-sql-while-loop.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkEMQnkzeSp7ImA9Wx9XEkw.&quot;"><id>tag:blogger.com,1999:blog-272429821527780388.post-3897596775885532542</id><published>2011-01-04T23:59:00.000-08:00</published><updated>2011-01-05T00:04:43.781-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-01-05T00:04:43.781-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Database" /><title>SQL Server日期函數CONVERT範例</title><content type="html">MS SQL Server中文版的預設日期datetime格式是yyyy-mm-dd hh:mm:ss.mmm&lt;br /&gt;&lt;br /&gt;例如:&lt;br /&gt;&lt;span class="Apple-style-span"  style="color:#000099;"&gt;select getdate()&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;2011-01-05 11:06:08.177&lt;br /&gt;&lt;br /&gt;SQL Server常用到日期格式轉換方式如下：&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;select CONVERT(varchar, getdate(), 120 )&lt;/span&gt;&lt;br /&gt;2004-09-12 11:06:08&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;select replace(replace(replace(CONVERT(varchar, getdate(), 120 ),’-',”),’ ‘,”),’:',”)&lt;/span&gt;&lt;br /&gt;20040912110608&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;select CONVERT(varchar(12) , getdate(), 111 )&lt;/span&gt;&lt;br /&gt;2004/09/12&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: large;"&gt;Text Convert to Datetime&lt;/span&gt;&lt;/b&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;SELECT  convert(datetime, '09/02/2010', 103)&lt;/span&gt;&lt;br /&gt;here 103-&gt;英國/法國標準&lt;br /&gt;&lt;br /&gt;source: &lt;a href="http://technet.microsoft.com/zh-tw/library/ms187928.aspx"&gt;http://technet.microsoft.com/zh-tw/library/ms187928.aspx&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/272429821527780388-3897596775885532542?l=codestandup.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/aw1GEMLSHZnz4mXMACzOGUjmRYE/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/aw1GEMLSHZnz4mXMACzOGUjmRYE/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/aw1GEMLSHZnz4mXMACzOGUjmRYE/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/aw1GEMLSHZnz4mXMACzOGUjmRYE/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Code-standup/~4/sT8fmkhIKiY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://codestandup.blogspot.com/feeds/3897596775885532542/comments/default" title="張貼意見" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=272429821527780388&amp;postID=3897596775885532542" title="0 個意見" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/272429821527780388/posts/default/3897596775885532542?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/272429821527780388/posts/default/3897596775885532542?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Code-standup/~3/sT8fmkhIKiY/sql-serverconvert.html" title="SQL Server日期函數CONVERT範例" /><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14778696620700587607" /></author><thr:total>0</thr:total><feedburner:origLink>http://codestandup.blogspot.com/2011/01/sql-serverconvert.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkIGQX06fCp7ImA9Wx9QFUU.&quot;"><id>tag:blogger.com,1999:blog-272429821527780388.post-5419208578222301437</id><published>2010-12-28T18:08:00.001-08:00</published><updated>2010-12-28T18:08:40.314-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-12-28T18:08:40.314-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Database" /><title>make a new schema in Oracle</title><content type="html">&lt;div&gt;CREATE USER seasonal IDENTIFIED BY test; &lt;/div&gt;&lt;div&gt;grant resource, connect to seasonal;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/272429821527780388-5419208578222301437?l=codestandup.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/nxHrSRceC5zFQHKw9RlidTZLeHE/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/nxHrSRceC5zFQHKw9RlidTZLeHE/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/nxHrSRceC5zFQHKw9RlidTZLeHE/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/nxHrSRceC5zFQHKw9RlidTZLeHE/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Code-standup/~4/0v_cbRgPFWg" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://codestandup.blogspot.com/feeds/5419208578222301437/comments/default" title="張貼意見" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=272429821527780388&amp;postID=5419208578222301437" title="0 個意見" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/272429821527780388/posts/default/5419208578222301437?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/272429821527780388/posts/default/5419208578222301437?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Code-standup/~3/0v_cbRgPFWg/make-new-schema-in-oracle.html" title="make a new schema in Oracle" /><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14778696620700587607" /></author><thr:total>0</thr:total><feedburner:origLink>http://codestandup.blogspot.com/2010/12/make-new-schema-in-oracle.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUICQ3gzeip7ImA9Wx9QFU8.&quot;"><id>tag:blogger.com,1999:blog-272429821527780388.post-5324786918211589629</id><published>2010-12-27T23:59:00.000-08:00</published><updated>2010-12-28T00:06:02.682-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-12-28T00:06:02.682-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Database" /><title>Administration - Session</title><content type="html">&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;b&gt;&lt;u&gt;Show all connected users&lt;/u&gt;&lt;/b&gt;&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;b&gt;&lt;u&gt;&lt;br /&gt;&lt;/u&gt;&lt;/b&gt;select username&lt;br /&gt;,      sid || ',' || serial# "ID"&lt;br /&gt;,      status&lt;br /&gt;,      last_call_et "Last Activity"&lt;br /&gt;from   v$session&lt;br /&gt;where  username is not null&lt;br /&gt;order by status desc&lt;br /&gt;,        last_call_et desc;&lt;br /&gt;&lt;br /&gt;--------------------------------------------------&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;u&gt;Time since last user activity&lt;/u&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;b&gt;&lt;u&gt;&lt;br /&gt;&lt;/u&gt;&lt;/b&gt;select username&lt;br /&gt;,      floor(last_call_et / 60) "Minutes"&lt;br /&gt;,      status&lt;br /&gt;from   v$session&lt;br /&gt;where  username is not null&lt;br /&gt;order by last_call_et&lt;br /&gt;--------------------------------------------------&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;u&gt;Sessions sorted by logon time&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;select  username&lt;br /&gt;, osuser&lt;br /&gt;, sid || ',' || serial# "ID"&lt;br /&gt;, status&lt;br /&gt;, to_char(logon_time, 'hh24:mi dd/mm/yy') login_time&lt;br /&gt;, last_call_et&lt;br /&gt;from v$session&lt;br /&gt;where username is not null&lt;br /&gt;order by login_time;&lt;br /&gt;--------------------------------------------------&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;u&gt;Show user info including os pid&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;select s.sid || ',' || s.serial# "SID/SERIAL"&lt;br /&gt;, s.username&lt;br /&gt;, s.osuser&lt;br /&gt;, p.spid "OS PID"&lt;br /&gt;, s.program&lt;br /&gt;from v$session s&lt;br /&gt;, v$process p&lt;br /&gt;Where s.paddr = p.addr&lt;br /&gt;order  by to_number(p.spid);&lt;br /&gt;--------------------------------------------------&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;u&gt;Show a users current sql&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Select sql_text&lt;br /&gt;from   v$sqlarea&lt;br /&gt;where  (address, hash_value) in&lt;br /&gt;(select sql_address, sql_hash_value&lt;br /&gt;       from v$session&lt;br /&gt;       where username like '&amp;amp;username');&lt;br /&gt;&lt;br /&gt;--------------------------------------------------&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;u&gt;Session status associated with the specified os process id&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;select s.username&lt;br /&gt;, s.sid&lt;br /&gt;, s.serial#&lt;br /&gt;, p.spid&lt;br /&gt;, last_call_et&lt;br /&gt;, status&lt;br /&gt;from  V$SESSION s&lt;br /&gt;, V$PROCESS p&lt;br /&gt;where s.PADDR = p.ADDR&lt;br /&gt;and p.spid='&amp;amp;pid';&lt;br /&gt;&lt;br /&gt;--------------------------------------------------&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;u&gt;All active sql&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;set feedback off&lt;br /&gt;set serveroutput on size 9999&lt;br /&gt;column username format a20&lt;br /&gt;column sql_text format a55 word_wrapped&lt;br /&gt;begin&lt;br /&gt; for x in&lt;br /&gt;  (select username||'('||sid||','||serial#||') ospid = '|| process ||&lt;br /&gt;   ' program = ' || program username,&lt;br /&gt;   to_char(LOGON_TIME,' Day HH24:MI') logon_time,&lt;br /&gt;   to_char(sysdate,' Day HH24:MI') current_time,&lt;br /&gt;   sql_address,&lt;br /&gt;   sql_hash_value&lt;br /&gt;  from v$session&lt;br /&gt;  where status = 'ACTIVE'&lt;br /&gt;  and rawtohex(sql_address) &lt;&gt; '00'&lt;br /&gt;  and username is not null ) loop&lt;br /&gt;  for y in (select sql_text&lt;br /&gt;  from v$sqlarea&lt;br /&gt;  where address = x.sql_address ) loop&lt;br /&gt;  if ( y.sql_text not like '%listener.get_cmd%' and&lt;br /&gt;   y.sql_text not like '%RAWTOHEX(SQL_ADDRESS)%' ) then&lt;br /&gt;   dbms_output.put_line( '--------------------' );&lt;br /&gt;   dbms_output.put_line( x.username );&lt;br /&gt;   dbms_output.put_line( x.logon_time || ' ' || x.current_time || ' SQL#=' || x.sql_hash_value);&lt;br /&gt;   dbms_output.put_line( substr( y.sql_text, 1, 250 ) );&lt;br /&gt;  end if;&lt;br /&gt; end loop;&lt;br /&gt;end loop;&lt;br /&gt;end;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;--------------------------------------------------&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;u&gt;Display any long operations&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;select username&lt;br /&gt;, to_char(start_time, 'hh24:mi:ss dd/mm/yy') started&lt;br /&gt;, time_remaining remaining&lt;br /&gt;, message&lt;br /&gt;from v$session_longops&lt;br /&gt;where time_remaining = 0&lt;br /&gt;order by time_remaining desc;&lt;br /&gt;&lt;br /&gt;--------------------------------------------------&lt;br /&gt;&lt;b&gt;&lt;u&gt;&lt;br /&gt;&lt;/u&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;b&gt;&lt;u&gt;List open cursors per user&lt;/u&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;select  sess.username&lt;br /&gt;, sess.sid&lt;br /&gt;, sess.serial#&lt;br /&gt;, stat.value cursors&lt;br /&gt;from v$sesstat stat&lt;br /&gt;, v$statname sn&lt;br /&gt;, v$session sess&lt;br /&gt;where sess.username is not null&lt;br /&gt;and sess.sid = stat.sid&lt;br /&gt;and stat.statistic# = sn.statistic#&lt;br /&gt;and sn.name = 'opened cursors current'&lt;br /&gt;order by value;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;&lt;i&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;Or alternatively... &lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;b&gt;&lt;i&gt;&lt;/i&gt;&lt;/b&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;select count(hash_value) cursors&lt;br /&gt;,      sid&lt;br /&gt;,      user_name&lt;br /&gt;from   v$open_cursor&lt;br /&gt;group by&lt;br /&gt;      sid&lt;br /&gt;,      user_name&lt;br /&gt;order by&lt;br /&gt;      cursors;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;source: http://www.shutdownabort.com/dbaqueries/Administration_Session.php#List-open-cursors-per-user&lt;/span&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/272429821527780388-5324786918211589629?l=codestandup.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/450IS39TUsuLupDYIS9DAfTGjIo/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/450IS39TUsuLupDYIS9DAfTGjIo/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/450IS39TUsuLupDYIS9DAfTGjIo/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/450IS39TUsuLupDYIS9DAfTGjIo/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Code-standup/~4/jXSClU9qpNU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://codestandup.blogspot.com/feeds/5324786918211589629/comments/default" title="張貼意見" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=272429821527780388&amp;postID=5324786918211589629" title="0 個意見" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/272429821527780388/posts/default/5324786918211589629?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/272429821527780388/posts/default/5324786918211589629?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Code-standup/~3/jXSClU9qpNU/administration-session.html" title="Administration - Session" /><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14778696620700587607" /></author><thr:total>0</thr:total><feedburner:origLink>http://codestandup.blogspot.com/2010/12/administration-session.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUUHQn89cSp7ImA9Wx9XEEk.&quot;"><id>tag:blogger.com,1999:blog-272429821527780388.post-812867597535456407</id><published>2010-12-22T23:56:00.000-08:00</published><updated>2011-01-03T01:33:53.169-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-01-03T01:33:53.169-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="JS" /><title>Google Map 的中文製作簡介V2</title><content type="html">source; http://dev.leck.com/gsupport/&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/272429821527780388-812867597535456407?l=codestandup.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/WFaVjI39X2RMvIZADYce248wW7I/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/WFaVjI39X2RMvIZADYce248wW7I/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/WFaVjI39X2RMvIZADYce248wW7I/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/WFaVjI39X2RMvIZADYce248wW7I/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Code-standup/~4/qJGOe665vzU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://codestandup.blogspot.com/feeds/812867597535456407/comments/default" title="張貼意見" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=272429821527780388&amp;postID=812867597535456407" title="0 個意見" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/272429821527780388/posts/default/812867597535456407?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/272429821527780388/posts/default/812867597535456407?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Code-standup/~3/qJGOe665vzU/google-map-v2.html" title="Google Map 的中文製作簡介V2" /><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14778696620700587607" /></author><thr:total>0</thr:total><feedburner:origLink>http://codestandup.blogspot.com/2010/12/google-map-v2.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ck4MQ3c_eSp7ImA9Wx9QEEo.&quot;"><id>tag:blogger.com,1999:blog-272429821527780388.post-5083793386713797744</id><published>2010-12-22T18:21:00.000-08:00</published><updated>2010-12-22T18:23:02.941-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-12-22T18:23:02.941-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="JS" /><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><title>DWR和jQuery的$符號衝突的問題</title><content type="html">DWR和jQuery都使用$符號來取得html中的元素，如果兩個一起用的話就會出現衝突。我在網上搜了一下都是用jQuery.noConflict()來替換jQuery中的$，但jQuery的插件太多，我不想在每個dwr調用之前都用noConflict來轉換一下，能不能把dwr的$符號替換一下呢？查了一下dwr的util.js源碼，發現下面這句：&lt;br /&gt;&lt;br /&gt;var $;&lt;br /&gt;if (!$) {&lt;br /&gt;  $ = dwr.util.byId;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;沒錯！這裡就是dwr定義$的地方，把這斷代碼屏掉，重新定義了一下&lt;br /&gt;&lt;br /&gt;var wwwju51com;&lt;br /&gt;if (!wwwju51com) {&lt;br /&gt;  wwwju51com = dwr.util.byId;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;OK，這樣你就能用wwwju51com來替換DWR中的$符號了。&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/272429821527780388-5083793386713797744?l=codestandup.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/r87y9tHumxtQwcJ6Se7Az6XvdUk/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/r87y9tHumxtQwcJ6Se7Az6XvdUk/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/r87y9tHumxtQwcJ6Se7Az6XvdUk/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/r87y9tHumxtQwcJ6Se7Az6XvdUk/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Code-standup/~4/w8hNFgtCVMs" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://codestandup.blogspot.com/feeds/5083793386713797744/comments/default" title="張貼意見" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=272429821527780388&amp;postID=5083793386713797744" title="0 個意見" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/272429821527780388/posts/default/5083793386713797744?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/272429821527780388/posts/default/5083793386713797744?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Code-standup/~3/w8hNFgtCVMs/dwrjquery.html" title="DWR和jQuery的$符號衝突的問題" /><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14778696620700587607" /></author><thr:total>0</thr:total><feedburner:origLink>http://codestandup.blogspot.com/2010/12/dwrjquery.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEcGSXs4fSp7ImA9Wx9RGEk.&quot;"><id>tag:blogger.com,1999:blog-272429821527780388.post-525378201604911513</id><published>2010-12-20T03:52:00.000-08:00</published><updated>2010-12-20T03:53:48.535-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-12-20T03:53:48.535-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Java" /><title>Apache日誌分析簡介</title><content type="html">apache日誌分析簡介&lt;br /&gt;上次因工作的需求對一台apache的log做了一次整體的分析,所以順便也對apache的日誌分析做下簡單的介紹,主要參考apache官網的Log Files,手冊參照http://httpd.apache .org/docs/2.2/logs.html&lt;br /&gt;&lt;br /&gt;一.日誌分析&lt;br /&gt;如果apache的安裝時採用默認的配置,那麼在/logs目錄下就會生成兩個文件,分別是access_log和error_log&lt;br /&gt;1.access_log&lt;br /&gt;access_log為訪問日誌,記錄所有對apache服務器進行請求的訪問,它的位置和內容由CustomLog指令控制,LogFormat指令可以用來簡化該日誌的內容和格式&lt;br /&gt;例如,我的其中一台服務器配置如下&lt;br /&gt;&lt;br /&gt;CustomLog "| /usr/sbin/rotatelogs /var/log/apache2/%Y_%m_%d_other_vhosts_access.log 86400 480" vhost_combined&lt;br /&gt;&lt;br /&gt;-rw-r--r-- 1 root root 22310750 12-05 23:59 2010_12_05_other_vhosts_access.log&lt;br /&gt;-rw-r--r-- 1 root root 26873180 12-06 23:59 2010_12_06_other_vhosts_access.log&lt;br /&gt;-rw-r--r-- 1 root root 26810003 12-07 23:59 2010_12_07_other_vhosts_access.log&lt;br /&gt;-rw-r--r-- 1 root root 24530219 12-08 23:59 2010_12_08_other_vhosts_access.log&lt;br /&gt;-rw-r--r-- 1 root root 24536681 12-09 23:59 2010_12_09_other_vhosts_access.log&lt;br /&gt;-rw-r--r-- 1 root root 14003409 12-10 14:57 2010_12_10_other_vhosts_access.log&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;通過CustomLog指令,每天一天生成一個獨立的日誌文件,同時也寫了定時器將一周前的日誌文件全部清除,這樣可以顯得更清晰,既可以分離每一天的日誌又可以清除一定時間以前的日誌通過制,LogFormat定義日誌的記錄格式&lt;br /&gt;&lt;br /&gt;LogFormat "%h %l %u %t \"%r\" %&gt;s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined&lt;br /&gt;LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %&gt;s %b \"%{Referer}i\" \"%{User-Agent}i\"" combinedproxy&lt;br /&gt;LogFormat "%h %l %u %t \"%r\" %&gt;s %b" common&lt;br /&gt;LogFormat "%{Referer}i -&gt; %U" referer&lt;br /&gt;LogFormat "%{User-agent}i" agent&lt;br /&gt;&lt;br /&gt;隨意的tail一個access_log文件,下面是一條經典的訪問記錄&lt;br /&gt;&lt;br /&gt;218.19.140.242 - - [10/Dec/2010:09:31:17 +0800] "GET /query/trendxml/district/todayreturn/month/2009-12-14/2010-12-09/haizhu_tianhe.xml HTTP/ 1.1" 200 1933 "-" "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8 (.NET CLR 3.5.30729)"&lt;br /&gt;&lt;br /&gt;一共是有9項,將他們一一拆開&lt;br /&gt;&lt;br /&gt;218.19.140.242&lt;br /&gt;-&lt;br /&gt;-&lt;br /&gt;[10/Dec/2010:09:31:17 +0800]&lt;br /&gt;"GET /query/trendxml/district/todayreturn/month/2009-12-14/2010-12-09/haizhu_tianhe.xml HTTP/1.1"&lt;br /&gt;200&lt;br /&gt;1933&lt;br /&gt;"-"&lt;br /&gt;"Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8 (.NET CLR 3.5.30729)"&lt;br /&gt;&lt;br /&gt;1) 218.19.140.242 這是一個請求到apache服務器的客戶端ip,默認的情況下,第一項信息只是遠程主機的ip地址,但我們如果需要apache查出主機的名字,可以將HostnameLookups設置為on ,但這種做法是不推薦使用,因為它大大的減緩了服務器.另外這裡的ip地址不一定就是客戶主機的ip地址,如果客戶端使用了代理服務器,那麼這裡的ip就是代理服務器的地址,而不是原機.&lt;br /&gt;&lt;br /&gt;2) - 這一項是空白,使用"-"來代替,這個位置是用於標註訪問者的標示,這個信息是由identd的客戶端存在,除非IdentityCheck為on,非則apache是不會去獲取該部分的信息(ps:不太理解,基本上這一項都是為空,奉上原文)&lt;br /&gt;The "hyphen" in the output indicates that the requested piece of information is not available. In this case, the information that is not available is the RFC 1413 identity of the client determined by identd on the clients machine. This information is highly unreliable and should almost never be used except on tightly controlled internal networks. Apache httpd will not even attempt to determine this information unless IdentityCheck is set to On.&lt;br /&gt;&lt;br /&gt;3) - 這一項又是為空白,不過這項是用戶記錄用戶HTTP的身份驗證,如果某些網站要求用戶進行身份雁陣,那麼這一項就是記錄用戶的身份信息&lt;br /&gt;&lt;br /&gt;4) [10/Dec/2010:09:31:17 +0800] 第四項是記錄請求的時間,格式為[day/month/year:hour:minute:second zone],最後的+0800表示服務器所處的時區為東八區&lt;br /&gt;&lt;br /&gt;5) "GET /..haizhu_tianhe.xml HTTP/1.1" 這一項整個記錄中最有用的信息,首先,它告訴我們的服務器收到的是一個GET請求,其次,是客戶端請求的資源路徑,第三,客戶端使用的協議時HTTP/1.1,整個格式為"%m %U%q %H",即"請求方法/訪問路徑/協議"&lt;br /&gt;&lt;br /&gt;6) 200 這是一個狀態碼,由服務器端發送回客戶端,它告訴我們客戶端的請求是否成功,或者是重定向,或者是碰到了什麼樣的錯誤,這項值為200，表示服務器已經成功的響應了客戶端的請求,一般來說,這項值以2開頭的表示請求成功,以3開頭的表示重定向,以4開頭的標示客戶端存在某些的錯誤,以5開頭的標示服務器端存在某些錯誤,詳細的可以參見HTTP specification (RFC2616 section 10).[http://www.w3.org/Protocols/rfc2616/rfc2616.txt]&lt;br /&gt;&lt;br /&gt;7) 1933 這項表示服務器向客戶端發送了多少的字節,在日誌分析統計的時侯,把這些字節加起來就可以得知服務器在某點時間內總的發送數據量是多少&lt;br /&gt;&lt;br /&gt;8) - 暫不知&lt;br /&gt;&lt;br /&gt;9) "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8 (.NET CLR 3.5.30729)" 這項主要記錄客戶端的瀏覽器信息&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;2.error_log&lt;br /&gt;error_log為錯誤日誌,記錄下任何錯誤的處理請求,它的位置和內容由ErrorLog指令控制,通常服務器出現什麼錯誤,首先對它進行查閱,是一個最重要的日誌文件&lt;br /&gt;&lt;br /&gt;tail error_log,隨意摘取一個記錄&lt;br /&gt;&lt;br /&gt;[Fri Dec 10 15:03:59 2010] [error] [client 218.19.140.242] File does not exist: /home/htmlfile/tradedata/favicon.ico&lt;br /&gt;&lt;br /&gt;同樣也是分為幾個項&lt;br /&gt;&lt;br /&gt;[Fri Dec 10 15:03:59 2010]&lt;br /&gt;[error]&lt;br /&gt;[client 218.19.140.242]&lt;br /&gt;File does not exist: /home/htmlfile/tradedata/favicon.ico&lt;br /&gt;&lt;br /&gt;1) [Fri Dec 10 15:03:59 2010] 記錄錯誤發生的時間,注意,它跟我們上面access_log記錄的時間格式是不同的&lt;br /&gt;&lt;br /&gt;2) [error] 這一項為錯誤的級別,根據LogLevel指令來控制錯誤的類別,上面的404是屬於error級別&lt;br /&gt;&lt;br /&gt;3) [client 218.19.140.242] 記錄客戶端的ip地址&lt;br /&gt;&lt;br /&gt;4) File does not exist: /home/htmlfile/tradedata/favicon.ico 這一項首先對錯誤進行了描述,例如客戶端訪問一個不存在或路徑錯誤的文件,就會給出404的提示錯誤&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;二.實用的日誌分析腳本&lt;br /&gt;了解日誌的各種定義後,這里分享一下從網上淘來的一些對日誌分析的腳本&lt;br /&gt;&lt;br /&gt;1.查看apache的進程數&lt;br /&gt;ps -aux | grep httpd | wc -l&lt;br /&gt;&lt;br /&gt;2.分析日誌查看當天的ip連接數&lt;br /&gt;cat default-access_log | grep "10/Dec/2010" | awk '{print $2}' | sort | uniq -c | sort -nr&lt;br /&gt;&lt;br /&gt;3.查看指定的ip在當天究竟訪問了什麼url&lt;br /&gt;cat default-access_log | grep "10/Dec/2010" | grep "218.19.140.242" | awk '{print $7}' | sort | uniq -c | sort -nr&lt;br /&gt;&lt;br /&gt;4.查看當天訪問排行前10的url&lt;br /&gt;cat default-access_log | grep "10/Dec/2010" | awk '{print $7}' | sort | uniq -c | sort -nr | head -n 10&lt;br /&gt;&lt;br /&gt;5.看到指定的ip究竟乾了什麼&lt;br /&gt;cat default-access_log | grep 218.19.140.242 | awk '{print $1"\t"$8}' | sort | uniq -c | sort -nr | less&lt;br /&gt;&lt;br /&gt;6.查看訪問次數最多的幾個分鐘(找到熱點)&lt;br /&gt;awk '{print $4}' default-access_log |cut -c 14-18|sort|uniq -c|sort -nr|head&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;三.使用awstats自動分析日誌&lt;br /&gt;當然啦,如果想最簡單和最直觀的分析日誌還是用工具,現在網上較流行的工具是awstats,一個基於perl的web日誌分析工具,功能很強大也支持IIS等服務器&lt;br /&gt;下載地址 http://awstats.sourceforge.net&lt;br /&gt;安裝配置見 &lt;安裝配置整理之 awstats&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/272429821527780388-525378201604911513?l=codestandup.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/i5OfzVKXO5gLHSlLWh01GboePqc/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/i5OfzVKXO5gLHSlLWh01GboePqc/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/i5OfzVKXO5gLHSlLWh01GboePqc/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/i5OfzVKXO5gLHSlLWh01GboePqc/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Code-standup/~4/DpYC7TpoliM" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://codestandup.blogspot.com/feeds/525378201604911513/comments/default" title="張貼意見" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=272429821527780388&amp;postID=525378201604911513" title="0 個意見" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/272429821527780388/posts/default/525378201604911513?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/272429821527780388/posts/default/525378201604911513?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Code-standup/~3/DpYC7TpoliM/apache.html" title="Apache日誌分析簡介" /><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14778696620700587607" /></author><thr:total>0</thr:total><feedburner:origLink>http://codestandup.blogspot.com/2010/12/apache.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUEHQHc6cCp7ImA9Wx9RE0w.&quot;"><id>tag:blogger.com,1999:blog-272429821527780388.post-3708904859173006700</id><published>2010-12-14T01:05:00.000-08:00</published><updated>2010-12-14T01:07:11.918-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-12-14T01:07:11.918-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Database" /><title>Killing Oracle Sessions</title><content type="html">detail &lt;a href="http://www.oracle-base.com/articles/misc/KillingOracleSessions.php"&gt;http://www.oracle-base.com/articles/misc/KillingOracleSessions.php&lt;/a&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial, serif; font-size: 13px; "&gt;Killing sessions can be very destructive if you kill the wrong session, so be very careful when identifying the session to be killed. If you kill a session belonging to a background process you will cause an instance crash.&lt;br /&gt;&lt;br /&gt;Identify the offending session using the &lt;code&gt;V$SESSION&lt;/code&gt; or &lt;code&gt;GV$SESSION&lt;/code&gt; view as follows.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: arial, serif; font-size: 13px; "&gt;Identify the offending session using the &lt;code&gt;V$SESSION&lt;/code&gt; or &lt;code&gt;GV$SESSION&lt;/code&gt; view as follows.&lt;br /&gt;&lt;blockquote&gt;&lt;pre style="color: rgb(0, 0, 0); background-color: rgb(240, 240, 240); border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(192, 192, 192); border-right-color: rgb(192, 192, 192); border-bottom-color: rgb(192, 192, 192); border-left-color: rgb(192, 192, 192); "&gt;SET LINESIZE 100 COLUMN spid FORMAT A10 COLUMN username FORMAT A10 COLUMN program FORMAT A45  SELECT s.inst_id,        s.sid,        s.serial#,        p.spid,        s.username,        s.program FROM   gv$session s        JOIN gv$process p ON p.addr = s.paddr AND p.inst_id = s.inst_id WHERE  s.type != 'BACKGROUND';     INST_ID        SID    SERIAL# SPID       USERNAME   PROGRAM ---------- ---------- ---------- ---------- ---------- ---------------------------------------------          1         30         15 3859       TEST       sqlplus@oel5-11gr2.localdomain (TNS V1-V3)          1         23        287 3834       SYS        sqlplus@oel5-11gr2.localdomain (TNS V1-V3)          1         40        387 4663                  oracle@oel5-11gr2.localdomain (J000)          1         38        125 4665                  oracle@oel5-11gr2.localdomain (J001)  SQL&gt;&lt;/pre&gt;&lt;/blockquote&gt;The &lt;code&gt;SID&lt;/code&gt; and &lt;code&gt;SERIAL#&lt;/code&gt; values of the relevant session can then be substituted into the commands in the following sections.&lt;br /&gt;&lt;a id="kill_session" style="color: rgb(102, 102, 153); "&gt;&lt;/a&gt;&lt;h2 style="font-size: 12pt; font-weight: bold; "&gt;ALTER SYSTEM KILL SESSION&lt;/h2&gt;The basic syntax for killing a session is shown below.&lt;br /&gt;&lt;blockquote&gt;&lt;pre style="color: rgb(0, 0, 0); background-color: rgb(240, 240, 240); border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: rgb(192, 192, 192); border-right-color: rgb(192, 192, 192); border-bottom-color: rgb(192, 192, 192); border-left-color: rgb(192, 192, 192); "&gt;SQL&gt; ALTER SYSTEM KILL SESSION 'sid,serial#';&lt;/pre&gt;&lt;/blockquote&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/272429821527780388-3708904859173006700?l=codestandup.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/yWqRciMPnflon5Z2W2d35jGs5nk/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/yWqRciMPnflon5Z2W2d35jGs5nk/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/yWqRciMPnflon5Z2W2d35jGs5nk/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/yWqRciMPnflon5Z2W2d35jGs5nk/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Code-standup/~4/Qo25wbaITbM" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://codestandup.blogspot.com/feeds/3708904859173006700/comments/default" title="張貼意見" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=272429821527780388&amp;postID=3708904859173006700" title="0 個意見" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/272429821527780388/posts/default/3708904859173006700?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/272429821527780388/posts/default/3708904859173006700?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Code-standup/~3/Qo25wbaITbM/killing-oracle-sessions.html" title="Killing Oracle Sessions" /><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14778696620700587607" /></author><thr:total>0</thr:total><feedburner:origLink>http://codestandup.blogspot.com/2010/12/killing-oracle-sessions.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkMHSH49fip7ImA9Wx9SF0w.&quot;"><id>tag:blogger.com,1999:blog-272429821527780388.post-521828285981073572</id><published>2010-12-07T02:35:00.000-08:00</published><updated>2010-12-07T02:40:39.066-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-12-07T02:40:39.066-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Database" /><title>Oracle (JOB) 更新next_date的探討</title><content type="html">Source: http://blog.csdn.net/kamus/archive/2004/12/02/201377.aspx&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New'; font-size: 27px; line-height: 30px; "&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;b&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;要&lt;/span&gt;&lt;/b&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;:&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;本文通过实验和事件跟踪来分析&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;Oracle Job&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;执行过程中修改下次执行时间的机制。&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;span style="font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;有些人问，&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;Oracle&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;的&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;在设定完&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;next_date&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;和&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;interval&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;之后，到底是什么时候决定下一次运行时间的。可以归纳成以下几个问题。&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 18pt; text-indent: -18pt; "&gt;&lt;span lang="EN-US" style="line-height: 40px; font-family: 'Courier New'; "&gt;&lt;span style="line-height: 40px; "&gt;&lt;span style="font-size:100%;"&gt;1．&lt;/span&gt;&lt;span style="line-height: normal; font: normal normal normal 7pt/normal 'Times New Roman'; "&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;假设我们的&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;设定第一次运行的时间是&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;12:00&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;，运行的间隔是&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;1&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;小时，&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;运行需要耗时&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;30&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;分钟，那么第二次运行是在&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;13:00&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;还是&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;13:30&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;？&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 18pt; text-indent: -18pt; "&gt;&lt;span lang="EN-US" style="line-height: 40px; font-family: 'Courier New'; "&gt;&lt;span style="line-height: 40px; "&gt;&lt;span style="font-size:100%;"&gt;2．&lt;/span&gt;&lt;span style="line-height: normal; font: normal normal normal 7pt/normal 'Times New Roman'; "&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;如果是在&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;13:00&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;那是不是说明只要&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;一开始运行，&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;next_date&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;就被重新计算了？&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 18pt; text-indent: -18pt; "&gt;&lt;span lang="EN-US" style="line-height: 40px; font-family: 'Courier New'; "&gt;&lt;span style="line-height: 40px; "&gt;&lt;span style="font-size:100%;"&gt;3．&lt;/span&gt;&lt;span style="line-height: normal; font: normal normal normal 7pt/normal 'Times New Roman'; "&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;的下一次运行会受到上一次运行时间的影响吗？如果受到影响，如何可以避免这个影响而让&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;在每天的指定时刻运行？&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 18pt; text-indent: -18pt; "&gt;&lt;span lang="EN-US" style="line-height: 40px; font-family: 'Courier New'; "&gt;&lt;span style="line-height: 40px; "&gt;&lt;span style="font-size:100%;"&gt;4．&lt;/span&gt;&lt;span style="line-height: normal; font: normal normal normal 7pt/normal 'Times New Roman'; "&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;假设我们的&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;设定第一次运行的时间是&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;12:00&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;，运行的间隔是&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;30&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;分钟，&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;运行需要耗时&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;1&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;小时，那么第二次运行是在&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;12:30&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;还是&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;13:00&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;还是根本就会报错？&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;span style="font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;本文通过一些实验和跟踪来解释上面的所有问题。&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;span style="font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;首先我们选择一个测试用户，假设该用户名为&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;kamus&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;。&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;由于我们在实验用的存储过程中会用到&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;dbms_lock&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;包，所以需要由&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;sys&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;用户先授予&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;kamus&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;用户使用&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;dbms_lock&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;包的权限。&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;span style="font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;d:\Temp&gt;sqlplus "/ as sysdba"&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;o:p&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(255, 255, 255); "&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt;SQL*Plus: Release &lt;st1:chsdate st="on" year="1899" month="12" day="30" islunardate="False" isrocdate="False"&gt;9.2.0&lt;/st1:chsdate&gt;.5.0 - Production on &lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;星期三&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt; 12&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;月&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt; 1 23:56:32 2004&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;o:p&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;Copyright (c) 1982, 2002, Oracle Corporation.&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;All rights reserved.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;o:p&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;o:p&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(255, 255, 255); "&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;连接到&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt;:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;Oracle9i &lt;st1:city st="on"&gt;&lt;st1:place st="on"&gt;Enterprise&lt;/st1:place&gt;&lt;/st1:city&gt; Edition Release &lt;st1:chsdate st="on" year="1899" month="12" day="30" islunardate="False" isrocdate="False"&gt;9.2.0&lt;/st1:chsdate&gt;.5.0 - Production&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;With the Partitioning, OLAP and Oracle Data Mining options&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;JServer Release &lt;st1:chsdate st="on" year="1899" month="12" day="30" islunardate="False" isrocdate="False"&gt;9.2.0&lt;/st1:chsdate&gt;.5.0 - Production&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;o:p&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;SQL&gt; grant execute on dbms_lock to kamus;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;o:p&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="line-height: 40px; font-family: 宋体; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;授权成功。&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;span style="font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;然后用&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;kamus&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;用户登录数据库，创建我们测试使用的存储过程&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;sp_test_next_date&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;。&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;span style="font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(217, 217, 217); "&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt;create or replace procedure sp_test_next_date as&lt;br /&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;p_jobno&lt;span style="line-height: 34px; "&gt;    &lt;/span&gt;number;&lt;br /&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;P_nextdate date;&lt;br /&gt;begin&lt;br /&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;&lt;/span&gt;&lt;i&gt;&lt;span lang="EN-US" style="line-height: 34px; color: red; "&gt;--&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style="line-height: 34px; color: red; font-family: 宋体; "&gt;将调用此存储过程的&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span lang="EN-US" style="line-height: 34px; color: red; "&gt;job&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style="line-height: 34px; color: red; font-family: 宋体; "&gt;的&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span lang="EN-US" style="line-height: 34px; color: red; "&gt;next_date&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style="line-height: 34px; color: red; font-family: 宋体; "&gt;设置为&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span lang="EN-US" style="line-height: 34px; color: red; "&gt;30&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style="line-height: 34px; color: red; font-family: 宋体; "&gt;分钟以后&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(217, 217, 217); "&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;select job into p_jobno from user_jobs where what = &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 40px; color: rgb(0, 0, 240); "&gt;&lt;span style="background-color: rgb(217, 217, 217); font-size:100%;"&gt;'sp_test_next_date;'&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(217, 217, 217); "&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt;;&lt;br /&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;execute immediate &lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; color: rgb(0, 0, 240); "&gt;'begin dbms_job.next_date('&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt; || to_char(p_jobno) || &lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; color: rgb(0, 0, 240); "&gt;',sysdate+1/48);commit;end;'&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(217, 217, 217); "&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt;;&lt;br /&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;&lt;/span&gt;&lt;i&gt;&lt;span lang="EN-US" style="line-height: 34px; color: red; "&gt;--&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style="line-height: 34px; color: red; font-family: 宋体; "&gt;修改完毕以后检查&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span lang="EN-US" style="line-height: 34px; color: red; "&gt;user_jobs&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style="line-height: 34px; color: red; font-family: 宋体; "&gt;视图，输出&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span lang="EN-US" style="line-height: 34px; color: red; "&gt;job&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style="line-height: 34px; color: red; font-family: 宋体; "&gt;目前的&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span lang="EN-US" style="line-height: 34px; color: red; "&gt;next_date&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(217, 217, 217); "&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;select next_date&lt;br /&gt;&lt;span style="line-height: 34px; "&gt;    &lt;/span&gt;into P_nextdate&lt;br /&gt;&lt;span style="line-height: 34px; "&gt;    &lt;/span&gt;from user_jobs&lt;br /&gt;&lt;span style="line-height: 34px; "&gt;   &lt;/span&gt;where what = &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 40px; color: rgb(0, 0, 240); "&gt;&lt;span style="background-color: rgb(217, 217, 217); font-size:100%;"&gt;'sp_test_next_date;'&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(217, 217, 217); "&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt;;&lt;br /&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;dbms_output.put_line(&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; color: rgb(0, 0, 240); "&gt;'JOB&lt;/span&gt;&lt;span style="line-height: 34px; color: rgb(0, 0, 240); font-family: 宋体; "&gt;执行中的&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; color: rgb(0, 0, 240); "&gt;next_date: '&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(217, 217, 217); "&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt; ||&lt;br /&gt;&lt;span style="line-height: 34px; "&gt;                       &lt;/span&gt;to_char(p_nextdate,&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; color: rgb(0, 0, 240); "&gt;'YYYY-MM-DD HH24:MI:SS'&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(217, 217, 217); "&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt;));&lt;br /&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;&lt;/span&gt;&lt;i&gt;&lt;span lang="EN-US" style="line-height: 34px; color: red; "&gt;--&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style="line-height: 34px; color: red; font-family: 宋体; "&gt;等待&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span lang="EN-US" style="line-height: 34px; color: red; "&gt;10&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style="line-height: 34px; color: red; font-family: 宋体; "&gt;秒再退出执行&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(217, 217, 217); "&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;dbms_lock.sleep(seconds =&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 40px; color: rgb(0, 0, 240); "&gt;&lt;span style="background-color: rgb(217, 217, 217); font-size:100%;"&gt;10&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(217, 217, 217); font-size:100%;"&gt;);&lt;br /&gt;end sp_test_next_date;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 31px; font-size: 11pt; color: black; font-family: 'Courier New'; "&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="line-height: 31px; font-size: 11pt; color: black; font-family: 宋体; "&gt;创建调用该存储过程的&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 31px; font-size: 11pt; color: black; font-family: 'Courier New'; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 31px; font-size: 11pt; color: black; font-family: 宋体; "&gt;，定义&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 31px; font-size: 11pt; color: black; font-family: 'Courier New'; "&gt;interval&lt;/span&gt;&lt;span style="line-height: 31px; font-size: 11pt; color: black; font-family: 宋体; "&gt;为每天一次，也就是这次执行以后，下次执行时间应该在&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 31px; font-size: 11pt; color: black; font-family: 'Courier New'; "&gt;1&lt;/span&gt;&lt;span style="line-height: 31px; font-size: 11pt; color: black; font-family: 宋体; "&gt;天以后。&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 31px; font-size: 11pt; color: black; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 31px; font-size: 11pt; color: black; font-family: 'Courier New'; "&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;SQL&gt; variable jobno number;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;SQL&gt; BEGIN&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(255, 255, 255); "&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;2&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;DBMS_JOB.SUBMIT(job =&gt; :jobno,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(255, 255, 255); "&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;3&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;what =&gt; 'sp_test_next_date;',&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(255, 255, 255); "&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;4&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;next_date =&gt; SYSDATE,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(255, 255, 255); "&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;5&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;interval =&gt; 'SYSDATE+1');&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(255, 255, 255); "&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;6&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;COMMIT;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(255, 255, 255); "&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;7&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;END;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(255, 255, 255); "&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;8&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;/&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;o:p&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(255, 255, 255); "&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt;PL/SQL &lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;过程已成功完成。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;o:p&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;jobno&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;---------&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;1&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 31px; font-size: 11pt; color: black; font-family: 'Courier New'; "&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="line-height: 31px; font-size: 11pt; color: black; font-family: 宋体; "&gt;然后我们手工执行存储过程，执行完毕以后再手工从&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 31px; font-size: 11pt; color: black; font-family: 'Courier New'; "&gt;user_jobs&lt;/span&gt;&lt;span style="line-height: 31px; font-size: 11pt; color: black; font-family: 宋体; "&gt;视图中获得&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 31px; font-size: 11pt; color: black; font-family: 'Courier New'; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 31px; font-size: 11pt; color: black; font-family: 宋体; "&gt;的下次执行时间，可以看到在存储过程中修改的&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 31px; font-size: 11pt; color: black; font-family: 'Courier New'; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 31px; font-size: 11pt; color: black; font-family: 宋体; "&gt;的下次执行时间已经生效，变成了当前时间的&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 31px; font-size: 11pt; color: black; font-family: 'Courier New'; "&gt;30&lt;/span&gt;&lt;span style="line-height: 31px; font-size: 11pt; color: black; font-family: 宋体; "&gt;分钟以后，而不是默认的&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 31px; font-size: 11pt; color: black; font-family: 'Courier New'; "&gt;1&lt;/span&gt;&lt;span style="line-height: 31px; font-size: 11pt; color: black; font-family: 宋体; "&gt;天以后。&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 31px; font-size: 11pt; color: black; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 31px; font-size: 11pt; color: black; font-family: 'Courier New'; "&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;SQL&gt; conn kamus&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(255, 255, 255); "&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;请输入口令&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt;:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="line-height: 40px; font-family: 宋体; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;已连接。&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;SQL&gt; set serverout on&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;SQL&gt; exec sp_test_next_date();&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(255, 255, 255); "&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;执行中的&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt;next_date: 2004-12-02 00:44:11&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;o:p&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(255, 255, 255); "&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt;PL/SQL &lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;过程已成功完成。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;o:p&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;SQL&gt; col next_date for a20&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;SQL&gt; select to_char(next_date,'YYYY-MM-DD HH24:MI:SS') next_date from user_jobs&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;where what = 'sp_test_next_date;';&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;o:p&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;NEXT_DATE&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;--------------------&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;2004-12-02 00:44:11&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;span style="font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;我们再手工运行&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;，看看这次的结果，可以发现&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;没有运行完毕以前被修改了的下次运行时间跟&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;运行完毕以后再次手工检索&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;user_jobs&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;视图获得的下次运行时间已经不相同了。由此我们可以得出一个结论，&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;next_date&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;是在&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;运行完毕以后被&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;Oracle&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;自动修改的，而不是在&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;刚开始运行的时候，因为我们在存储过程中修改的&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;next_date&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;在&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;运行结束之后又被修改为默认的&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;1&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;天以后了。&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;span style="font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;SQL&gt; exec dbms_job.run(1);&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(255, 255, 255); "&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;执行中的&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt;next_date: 2004-12-02 00:54:52&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;o:p&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(255, 255, 255); "&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt;PL/SQL &lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;过程已成功完成。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;o:p&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;SQL&gt; select to_char(next_date,'YYYY-MM-DD HH24:MI:SS') next_date from user_jobs&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;where what = 'sp_test_next_date;';&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;o:p&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;NEXT_DATE&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;--------------------&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;2004-12-03 00:24:52&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;span style="font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;现在我们再次修改存储过程，输出存储过程开始执行的时间，便于跟执行完毕以后的&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;下次执行时间进行比较。&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;span style="font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(217, 217, 217); "&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt;create or replace procedure sp_test_next_date as&lt;br /&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;p_jobno&lt;span style="line-height: 34px; "&gt;    &lt;/span&gt;number;&lt;br /&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;P_nextdate date;&lt;br /&gt;begin&lt;br /&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;&lt;/span&gt;&lt;i&gt;&lt;span lang="EN-US" style="line-height: 34px; color: red; "&gt;--&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style="line-height: 34px; color: red; font-family: 宋体; "&gt;输出&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span lang="EN-US" style="line-height: 34px; color: red; "&gt;JOB&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style="line-height: 34px; color: red; font-family: 宋体; "&gt;刚开始执行的时间&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(217, 217, 217); "&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;dbms_output.put_line(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(217, 217, 217); "&gt;&lt;span lang="EN-US" style="line-height: 34px; color: rgb(0, 0, 240); "&gt;'&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt; &lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; color: rgb(0, 0, 240); "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 34px; color: rgb(0, 0, 240); font-family: 宋体; "&gt;开始执行的时间&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; color: rgb(0, 0, 240); "&gt;: '&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(217, 217, 217); "&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt; ||&lt;br /&gt;&lt;span style="line-height: 34px; "&gt;                       &lt;/span&gt;to_char(sysdate, &lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; color: rgb(0, 0, 240); "&gt;'YYYY-MM-DD HH24:MI:SS'&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(217, 217, 217); "&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt;));&lt;br /&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;&lt;/span&gt;&lt;i&gt;&lt;span lang="EN-US" style="line-height: 34px; color: red; "&gt;--&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style="line-height: 34px; color: red; font-family: 宋体; "&gt;将调用此存储过程的&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span lang="EN-US" style="line-height: 34px; color: red; "&gt;job&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style="line-height: 34px; color: red; font-family: 宋体; "&gt;的&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span lang="EN-US" style="line-height: 34px; color: red; "&gt;next_date&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style="line-height: 34px; color: red; font-family: 宋体; "&gt;设置为&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span lang="EN-US" style="line-height: 34px; color: red; "&gt;30&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style="line-height: 34px; color: red; font-family: 宋体; "&gt;分钟以后&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(217, 217, 217); "&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;select job into p_jobno from user_jobs where what = &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 40px; color: rgb(0, 0, 240); "&gt;&lt;span style="background-color: rgb(217, 217, 217); font-size:100%;"&gt;'sp_test_next_date;'&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(217, 217, 217); "&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt;;&lt;br /&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;execute immediate &lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; color: rgb(0, 0, 240); "&gt;'begin dbms_job.next_date('&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt; || to_char(p_jobno) || &lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; color: rgb(0, 0, 240); "&gt;',sysdate+1/48);commit;end;'&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(217, 217, 217); "&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt;;&lt;br /&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;&lt;/span&gt;&lt;i&gt;&lt;span lang="EN-US" style="line-height: 34px; color: red; "&gt;--&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style="line-height: 34px; color: red; font-family: 宋体; "&gt;修改完毕以后检查&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span lang="EN-US" style="line-height: 34px; color: red; "&gt;user_jobs&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style="line-height: 34px; color: red; font-family: 宋体; "&gt;视图，输出&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span lang="EN-US" style="line-height: 34px; color: red; "&gt;job&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style="line-height: 34px; color: red; font-family: 宋体; "&gt;目前的&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span lang="EN-US" style="line-height: 34px; color: red; "&gt;next_date&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(217, 217, 217); "&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;select next_date&lt;br /&gt;&lt;span style="line-height: 34px; "&gt;    &lt;/span&gt;into P_nextdate&lt;br /&gt;&lt;span style="line-height: 34px; "&gt;    &lt;/span&gt;from user_jobs&lt;br /&gt;&lt;span style="line-height: 34px; "&gt;   &lt;/span&gt;where what = &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 40px; color: rgb(0, 0, 240); "&gt;&lt;span style="background-color: rgb(217, 217, 217); font-size:100%;"&gt;'sp_test_next_date;'&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(217, 217, 217); "&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt;;&lt;br /&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;dbms_output.put_line(&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; color: rgb(0, 0, 240); "&gt;'&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt; &lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; color: rgb(0, 0, 240); "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 34px; color: rgb(0, 0, 240); font-family: 宋体; "&gt;执行中的&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; color: rgb(0, 0, 240); "&gt;next_date: '&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(217, 217, 217); "&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt; ||&lt;br /&gt;&lt;span style="line-height: 34px; "&gt;                       &lt;/span&gt;to_char(p_nextdate,&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; color: rgb(0, 0, 240); "&gt;'YYYY-MM-DD HH24:MI:SS'&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(217, 217, 217); "&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt;));&lt;br /&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;&lt;/span&gt;&lt;i&gt;&lt;span lang="EN-US" style="line-height: 34px; color: red; "&gt;--&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style="line-height: 34px; color: red; font-family: 宋体; "&gt;等待&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span lang="EN-US" style="line-height: 34px; color: red; "&gt;10&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style="line-height: 34px; color: red; font-family: 宋体; "&gt;秒再退出执行&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(217, 217, 217); "&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;dbms_lock.sleep(seconds =&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 40px; color: rgb(0, 0, 240); "&gt;&lt;span style="background-color: rgb(217, 217, 217); font-size:100%;"&gt;10&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(217, 217, 217); font-size:100%;"&gt;);&lt;br /&gt;end sp_test_next_date;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 31px; font-size: 11pt; color: black; font-family: 'Courier New'; "&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="line-height: 31px; font-size: 11pt; color: black; font-family: 宋体; "&gt;重新进行测试，我们可以发现&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 31px; font-size: 11pt; color: black; font-family: 'Courier New'; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 31px; font-size: 11pt; color: black; font-family: 宋体; "&gt;的&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 31px; font-size: 11pt; color: black; font-family: 'Courier New'; "&gt;next_date&lt;/span&gt;&lt;span style="line-height: 31px; font-size: 11pt; color: black; font-family: 宋体; "&gt;是&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 31px; font-size: 11pt; color: black; font-family: 'Courier New'; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 31px; font-size: 11pt; color: black; font-family: 宋体; "&gt;开始执行时间的&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 31px; font-size: 11pt; color: black; font-family: 'Courier New'; "&gt;1&lt;/span&gt;&lt;span style="line-height: 31px; font-size: 11pt; color: black; font-family: 宋体; "&gt;天以后，而不是&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 31px; font-size: 11pt; color: black; font-family: 'Courier New'; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 31px; font-size: 11pt; color: black; font-family: 宋体; "&gt;结束时间的&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 31px; font-size: 11pt; color: black; font-family: 'Courier New'; "&gt;1&lt;/span&gt;&lt;span style="line-height: 31px; font-size: 11pt; color: black; font-family: 宋体; "&gt;天以后（因为&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 31px; font-size: 11pt; color: black; font-family: 'Courier New'; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 31px; font-size: 11pt; color: black; font-family: 宋体; "&gt;结束需要经过&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 31px; font-size: 11pt; color: black; font-family: 'Courier New'; "&gt;10&lt;/span&gt;&lt;span style="line-height: 31px; font-size: 11pt; color: black; font-family: 宋体; "&gt;秒钟）&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 31px; font-size: 11pt; color: black; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 31px; font-size: 11pt; color: black; font-family: 'Courier New'; "&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;SQL&gt; exec dbms_job.run(1);&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(255, 255, 255); "&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;开始执行的时间&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt;: 2004-12-02 00:38:24&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(255, 255, 255); "&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;执行中的&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt;next_date: 2004-12-02 01:08:24&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;o:p&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(255, 255, 255); "&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt;PL/SQL &lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;过程已成功完成。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;o:p&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;SQL&gt; select to_char(next_date,'YYYY-MM-DD HH24:MI:SS') next_date from user_jobs&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;where what = 'sp_test_next_date;';&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;o:p&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;NEXT_DATE&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;--------------------&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;2004-12-03 00:38:24&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;span style="font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;至此，我们已经说明了两个问题。就是：&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;在运行结束之后才会更新&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;next_date&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;，但是计算的方法是&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;刚开始的时间加上&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;interval&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;设定的间隔。&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;span style="font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;下面我们通过&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;trace&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;来再次求证这个结论。&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;SQL&gt; ALTER SESSION SET EVENTS '10046 trace name context forever, level 12';&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;o:p&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="line-height: 40px; font-family: 宋体; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;会话已更改。&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;o:p&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;SQL&gt; exec dbms_job.run(1);&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;o:p&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(255, 255, 255); "&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt;PL/SQL &lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;过程已成功完成。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;o:p&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;SQL&gt; ALTER SESSION SET EVENTS '10046 trace name context off';&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;o:p&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="line-height: 40px; font-family: 宋体; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;会话已更改。&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;span style="font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;执行完毕以后在&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;udump&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;目录中查看生成的&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;trace&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;文件。如果我们用&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;tkprof&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;来格式化这个&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;trace&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;文件然后再查看格式化后的结果，我们会感到很诧异。因为在格式化完毕的&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;SQL&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;执行顺序中，更新&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;job$&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;表的语句出现在&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;dbms_job.next_date&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;语句之前，也就是看上去是&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;Oracle&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;先按照&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;interval&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;自动更新了&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;的&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;next_date&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;，然后才继续往下执行存储过程中定义的&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;next_date&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;更新语句，而这样显然无法解释我们在上面的实验中看到的结果。&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;但是当我们跳过&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;tkprof&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;而直接去查看生成的&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;trace&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;文件，就会恍然大悟，同时也印证了&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;steve adams&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;在&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;ixora&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;上提到的观点：&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;tkprof&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;格式化完的结果会省略一些信息，甚至在有时候会给我们错误的信息。&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;直接查看&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;trace&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;文件，我们可以看到如下的执行顺序：&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 18pt; text-indent: -18pt; "&gt;&lt;span lang="EN-US" style="line-height: 40px; font-family: 'Courier New'; "&gt;&lt;span style="line-height: 40px; "&gt;&lt;span style="font-size:100%;"&gt;1．&lt;/span&gt;&lt;span style="line-height: normal; font: normal normal normal 7pt/normal 'Times New Roman'; "&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;parse cursor #10&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;（&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;oracle&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;根据&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;interval&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;和先前保存的&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;this_date&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;字段值更新&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;job$&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;表的语句，包括更新&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;failures, last_date, next_date, total&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;等）&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 18pt; text-indent: -18pt; "&gt;&lt;span lang="EN-US" style="line-height: 40px; font-family: 'Courier New'; "&gt;&lt;span style="line-height: 40px; "&gt;&lt;span style="font-size:100%;"&gt;2．&lt;/span&gt;&lt;span style="line-height: normal; font: normal normal normal 7pt/normal 'Times New Roman'; "&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;parse cursor #15&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;（存储过程中的&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;begin dbms_job.next_date&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;语句）&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 18pt; text-indent: -18pt; "&gt;&lt;span lang="EN-US" style="line-height: 40px; font-family: 'Courier New'; "&gt;&lt;span style="line-height: 40px; "&gt;&lt;span style="font-size:100%;"&gt;3．&lt;/span&gt;&lt;span style="line-height: normal; font: normal normal normal 7pt/normal 'Times New Roman'; "&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;binds cursor #15&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;（将加上了&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;30&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;分钟的时间绑定到&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;cursor #15&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;上）&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 18pt; text-indent: -18pt; "&gt;&lt;span lang="EN-US" style="line-height: 40px; font-family: 'Courier New'; "&gt;&lt;span style="line-height: 40px; "&gt;&lt;span style="font-size:100%;"&gt;4．&lt;/span&gt;&lt;span style="line-height: normal; font: normal normal normal 7pt/normal 'Times New Roman'; "&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;exec cursor #15&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;（执行&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;cursor #15&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;）&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 18pt; text-indent: -18pt; "&gt;&lt;span lang="EN-US" style="line-height: 40px; font-family: 'Courier New'; "&gt;&lt;span style="line-height: 40px; "&gt;&lt;span style="font-size:100%;"&gt;5．&lt;/span&gt;&lt;span style="line-height: normal; font: normal normal normal 7pt/normal 'Times New Roman'; "&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;wait cursor #11&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;（经历一个&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;PL/SQL lock timer&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;事件，也就是存储过程中执行的&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;dbms_lock.sleep&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;方法）&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 18pt; text-indent: -18pt; "&gt;&lt;span lang="EN-US" style="line-height: 40px; font-family: 'Courier New'; "&gt;&lt;span style="line-height: 40px; "&gt;&lt;span style="font-size:100%;"&gt;6．&lt;/span&gt;&lt;span style="line-height: normal; font: normal normal normal 7pt/normal 'Times New Roman'; "&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;binds cursor #10&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;（将&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;刚开始执行时候的时间绑定到&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;cursor #10&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;上）&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 18pt; text-indent: -18pt; "&gt;&lt;span lang="EN-US" style="line-height: 40px; font-family: 'Courier New'; "&gt;&lt;span style="line-height: 40px; "&gt;&lt;span style="font-size:100%;"&gt;7．&lt;/span&gt;&lt;span style="line-height: normal; font: normal normal normal 7pt/normal 'Times New Roman'; "&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;exec cursor #10&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;（执行&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;cursor #10&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;）&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;span style="font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;也就是说虽然更新&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;job$&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;的语句被很早地解析过了，但是直到&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;运行结束时这个被解析过的游标才开始作变量绑定进而开始执行。&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;正是因为解析&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;update sys.job$&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;语句的时间早于解析&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;begin dbms_job.next_date&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;语句的时间，所以&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;tkprof&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;的结果将前者放在了前面。&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;span style="font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;接下来我们进入另外一个问题的探讨，本文最开始提到的第四个问题：&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;假设我们的&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;设定第一次运行的时间是&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;12:00&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;，运行的间隔是&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;30&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;分钟，&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;运行需要耗时&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;1&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;小时，那么第二次运行是在&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;12:30&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;还是&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;13:00&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;还是根本就会报错？&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;span style="font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;通过分析&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;trace&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;文件我们可以找到更新&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;next_date&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;的&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;SQL&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;语句是：&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; font-family: 'Courier New'; "&gt;&lt;span style="font-size:100%;"&gt;update sys.job$ set failures=0, this_date=null, flag=:1, last_date=:2, next_date=greatest(:3,sysdate),total=total+(sysdate - nvl(this_date, sysdate)) where job=:4&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;span style="font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;注意到更新&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;next_date&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;字段的公式是&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;greatest(:3, sysdate)&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;，此处的&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;:3&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;绑定的是&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;job&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;的&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;this_date+interval&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;。所以我们猜测实际上应该是有一个跟当前时间的比较机制，如果在执行完&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;之后的时间比按照&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;this_date+interval&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;计算出的时间更晚一些，那么&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;next_date&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;就更新为当前时间，也就是几乎会立刻再重新执行&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;。&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;span style="font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;同样这样的猜测我们也需要通过实验来验证一下。&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;创建一个新的存储过程&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;sp_test_next_date1&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;，简单地等待&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;2&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;分钟，但是我们将调用这个存储过程的&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;的&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;interval&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;设置为&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;1&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;分钟，看看会有什么情况。&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;为了更方便得比较，我们创建一个表用来记录每次&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;执行的开始时间。&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;SQL&gt; create table t (cdate date);&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;o:p&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="1" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;Table created&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;span style="font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;创建存储过程的脚本&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;span style="font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(217, 217, 217); "&gt;&lt;b&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt;create&lt;/span&gt;&lt;/b&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt; &lt;/span&gt;&lt;b&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt;or&lt;/span&gt;&lt;/b&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt; &lt;/span&gt;&lt;b&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt;replace&lt;/span&gt;&lt;/b&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt; &lt;/span&gt;&lt;b&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt;procedure&lt;/span&gt;&lt;/b&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt; sp_test_next_date1 &lt;/span&gt;&lt;b&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt;as&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;br /&gt;&lt;/span&gt;&lt;b&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(217, 217, 217); font-size:100%;"&gt;begin&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;br /&gt;&lt;span style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(217, 217, 217); font-size:100%;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(217, 217, 217); "&gt;&lt;i&gt;&lt;span lang="EN-US" style="line-height: 34px; color: red; "&gt;--&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style="line-height: 34px; color: red; font-family: 宋体; "&gt;输出&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span lang="EN-US" style="line-height: 34px; color: red; "&gt;JOB&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style="line-height: 34px; color: red; font-family: 宋体; "&gt;开始执行的时间&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;br /&gt;&lt;span style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(217, 217, 217); font-size:100%;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(217, 217, 217); "&gt;&lt;b&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt;insert&lt;/span&gt;&lt;/b&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt; &lt;/span&gt;&lt;b&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt;into&lt;/span&gt;&lt;/b&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt; t(cdate) &lt;/span&gt;&lt;b&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt;values&lt;/span&gt;&lt;/b&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt;(&lt;/span&gt;&lt;b&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt;sysdate&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(217, 217, 217); "&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt;);&lt;br /&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;&lt;/span&gt;&lt;b&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt;commit&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(217, 217, 217); "&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt;;&lt;br /&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;&lt;/span&gt;&lt;i&gt;&lt;span lang="EN-US" style="line-height: 34px; color: red; "&gt;--&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style="line-height: 34px; color: red; font-family: 宋体; "&gt;等待&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span lang="EN-US" style="line-height: 34px; color: red; "&gt;120&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span style="line-height: 34px; color: red; font-family: 宋体; "&gt;秒退出&lt;/span&gt;&lt;/i&gt;&lt;i&gt;&lt;span lang="EN-US" style="line-height: 34px; color: red; "&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;br /&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(217, 217, 217); "&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;dbms_lock.sleep(seconds =&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 40px; color: rgb(0, 0, 240); "&gt;&lt;span style="background-color: rgb(217, 217, 217); font-size:100%;"&gt;120&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(217, 217, 217); "&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt;);&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;b&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt;end&lt;/span&gt;&lt;/b&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt; sp_test_next_date1;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;span style="font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;创建调用此存储过程的&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;JOB&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;span style="font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;SQL&gt; variable jobno number;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;SQL&gt; BEGIN&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(255, 255, 255); "&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;2&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;DBMS_JOB.SUBMIT(job =&gt; :jobno,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(255, 255, 255); "&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;3&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;what =&gt; 'sp_test_next_date1;',&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(255, 255, 255); "&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;4&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;next_date =&gt; SYSDATE,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(255, 255, 255); "&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;5&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;interval =&gt; 'SYSDATE+1/1440');&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(255, 255, 255); "&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;6&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;COMMIT;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(255, 255, 255); "&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;7&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;END;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(255, 255, 255); "&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;8&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;/&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;o:p&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(255, 255, 255); "&gt;&lt;span lang="EN-US" style="line-height: 34px; "&gt;PL/SQL &lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;过程已成功完成。&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;o:p&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;jobno&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;---------&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;7&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;span style="font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;执行此&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;，然后过一段时间开始检查表&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;t&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;中的输出。&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;span style="font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;SQL&gt; select * from t order by cdate;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;o:p&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;CDATE&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;--------------------&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;2004-12-3 14:10:43&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;2004-12-3 14:12:47&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;2004-12-3 14:14:55&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;2004-12-3 14:16:59&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;2004-12-3 14:19:07&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;2004-12-3 14:21:11&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;o:p&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;6 rows selected&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;span style="font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;首先我们确认&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;每次都是成功执行了，并没有任何报错，然后检查&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;cdate&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;字段，发现时间间隔都是&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;2&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;分钟左右，也就是说因为&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;本身的&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;interval&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;设定比&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;本身的执行时间要长，所以&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;Oracle&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;将&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;next_date&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;设置为每次&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;结束的时间。&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;同时我们也注意到，每次开始的时间都有&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;4&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;秒到&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;8&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;秒的延迟，没有继续深究，不确认这是因为&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;oracle&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;本身计算的误差，还是内部比如启动&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;Job Process&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;需要的时长。&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;不论如何，到此我们也已经回答了第四个问题，即使&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;interval&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;的时长短于&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;执行的时间，整个作业仍然会继续进行，只是执行间隔变为了&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;真实运行的时长。&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;span style="font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;由于&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;trace&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;文件过长，所以不在本文中贴出了，如果有兴趣可以发邮件给我。我的邮件地址是：&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;a href="http://blog.csdn.net/kamus/archive/2004/12/02/201377.aspx" rel="noreferrer" style="text-decoration: none; color: rgb(51, 102, 153); "&gt;kamus@itpub.net&lt;/a&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;span style="font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;本文的最后一部分，解答本文开头提出的第三个问题，也就是：&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;的下一次运行会受到上一次运行时间的影响吗？如果受到影响，如何可以避免这个影响而让&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;在每天的指定时刻运行？&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;的下一次运行时间是会受上一次影响的，如果我们的&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;interval&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;仅仅是&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;sysdate+1/24&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;这样的形式的话，无疑，上次执行的时间再加上&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;1&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;小时就是下次执行的时间。那么如果&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;因为某些原因延迟执行了一次，这样就会导致下一次的执行时间也同样顺延了，这通常不是我们希望出现的现象。&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;解决方法很简单，只需要设定正确的&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;interval&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;就可以了。&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;比如，我们要&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;JOB&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;在每天的凌晨&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;3:30&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;执行而不管上次执行到底是几点，只需要设置&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;interval&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;为&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;trunc(SYSDATE)+3.5/24+1&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;即可。完整的&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;SQL&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;如下：&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;SQL&gt; variable jobno number;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="background-color: rgb(255, 255, 255); font-size:100%;"&gt;SQL&gt; BEGIN&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(255, 255, 255); "&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;2&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;DBMS_JOB.SUBMIT(job =&gt; :jobno,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(255, 255, 255); "&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;3&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;what =&gt; 'sp_test_next_date;',&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(255, 255, 255); "&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;4&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;next_date =&gt; SYSDATE,&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(255, 255, 255); "&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;5&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;interval =&gt; 'trunc(SYSDATE)+3.5/24+1');&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(255, 255, 255); "&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;6&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;COMMIT;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(255, 255, 255); "&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;7&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;END;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="a0" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="background-color: rgb(255, 255, 255); "&gt;&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;8&lt;span style="line-height: 34px; "&gt;  &lt;/span&gt;/&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;span style="font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;BTW&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;：在&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;trace&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;文件中发现虽然通过&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;select rowid from table&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;返回的结果已经是扩展&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;ROWID&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;格式（&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;Data Object number + File + Block + ROW&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;）了，但是&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;oracle&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;内部检索数据仍然在使用限制&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;ROWID&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;格式（&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;Block number.Row number.File number&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;）。&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span lang="EN-US" style="line-height: 40px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;span style="font-size:100%;"&gt; &lt;/span&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; "&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;本文涉及到的额外知识可以参看我的其它技术文章：&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 18pt; text-indent: -18pt; "&gt;&lt;span lang="EN-US" style="line-height: 40px; font-family: 'Courier New'; "&gt;&lt;span style="line-height: 40px; "&gt;&lt;span style="font-size:100%;"&gt;1．&lt;/span&gt;&lt;span style="line-height: normal; font: normal normal normal 7pt/normal 'Times New Roman'; "&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;通过事件跟踪&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;SQL&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;执行的后台步骤&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 18pt; text-indent: -18pt; "&gt;&lt;span lang="EN-US" style="line-height: 40px; font-family: 'Courier New'; "&gt;&lt;span style="line-height: 40px; "&gt;&lt;span style="font-size:100%;"&gt;2．&lt;/span&gt;&lt;span style="line-height: normal; font: normal normal normal 7pt/normal 'Times New Roman'; "&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;Oracle&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;等待事件，比如本文提到的&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;PL/SQL lock timer&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 18pt; text-indent: -18pt; "&gt;&lt;span lang="EN-US" style="line-height: 40px; font-family: 'Courier New'; "&gt;&lt;span style="line-height: 40px; "&gt;&lt;span style="font-size:100%;"&gt;3．&lt;/span&gt;&lt;span style="line-height: normal; font: normal normal normal 7pt/normal 'Times New Roman'; "&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size:100%;"&gt;&lt;span lang="EN-US" style="line-height: 34px; font-family: 'Courier New'; "&gt;ROWID&lt;/span&gt;&lt;span style="line-height: 34px; font-family: 宋体; "&gt;格式&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 40px; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" align="justify" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; text-align: center; "&gt; &lt;/p&gt;&lt;p class="MsoNormal" align="center" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; text-align: center; "&gt;&lt;span lang="EN-US" style="line-height: 34px; font-size: 12pt; font-family: 'Courier New'; "&gt;&lt;o:p&gt; &lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" align="left" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; text-align: left; "&gt;&lt;b&gt;&lt;span style="line-height: 34px; font-size: 12pt; font-family: 宋体; "&gt;作者简介：&lt;/span&gt;&lt;/b&gt;&lt;b&gt;&lt;span lang="EN-US" style="line-height: 34px; font-size: 12pt; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;&lt;p class="MsoNormal" align="left" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; text-align: left; "&gt;&lt;span style="line-height: 34px; font-size: 12pt; font-family: 宋体; "&gt;张乐奕，网名&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-size: 12pt; font-family: 'Courier New'; "&gt;kamus&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" align="left" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; text-align: left; "&gt;&lt;span style="line-height: 34px; font-size: 12pt; font-family: 宋体; "&gt;曾任&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-size: 12pt; font-family: 'Courier New'; "&gt;ITPUB Oracle&lt;/span&gt;&lt;span style="line-height: 34px; font-size: 12pt; font-family: 宋体; "&gt;认证版版主&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-size: 12pt; font-family: 'Courier New'; "&gt;,&lt;/span&gt;&lt;span style="line-height: 34px; font-size: 12pt; font-family: 宋体; "&gt;现任&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-size: 12pt; font-family: 'Courier New'; "&gt;itpub Oracle&lt;/span&gt;&lt;span style="line-height: 34px; font-size: 12pt; font-family: 宋体; "&gt;管理版版主&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-size: 12pt; font-family: 'Courier New'; "&gt;. &lt;span style="line-height: 34px; "&gt; &lt;/span&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" align="left" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; text-align: left; "&gt;&lt;span style="line-height: 34px; font-size: 12pt; font-family: 宋体; "&gt;现任职于北京某大型软件公司，首席&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-size: 12pt; font-family: 'Courier New'; "&gt;DBA&lt;/span&gt;&lt;span style="line-height: 34px; font-size: 12pt; font-family: 宋体; "&gt;，主要负责证券行业的全国十数处核心交易系统数据库管理及维护工作。&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-size: 12pt; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" align="left" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; text-align: left; "&gt;&lt;span style="line-height: 34px; font-size: 12pt; font-family: 宋体; "&gt;热切关注&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-size: 12pt; font-family: 'Courier New'; "&gt;Oracle&lt;/span&gt;&lt;span style="line-height: 34px; font-size: 12pt; font-family: 宋体; "&gt;技术和其它相关技术，出没于各大数据库技术论坛，目前是中国最大的&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-size: 12pt; font-family: 'Courier New'; "&gt;Oracle&lt;/span&gt;&lt;span style="line-height: 34px; font-size: 12pt; font-family: 宋体; "&gt;技术论坛&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-size: 12pt; font-family: 'Courier New'; "&gt;www.itpub.net&lt;/span&gt;&lt;span style="line-height: 34px; font-size: 12pt; font-family: 宋体; "&gt;的数据库管理版版主，&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-size: 12pt; font-family: 'Courier New'; "&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/span&gt;&lt;/p&gt;&lt;p class="MsoNormal" align="left" style="padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; margin-top: 0cm; margin-right: 0cm; margin-bottom: 0pt; margin-left: 0cm; text-align: left; "&gt;&lt;span style="line-height: 34px; font-size: 12pt; font-family: 宋体; "&gt;阅读更多技术文章和随笔可以登录我的个人&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-size: 12pt; font-family: 'Courier New'; "&gt;blog&lt;/span&gt;&lt;span style="line-height: 34px; font-size: 12pt; font-family: 宋体; "&gt;。&lt;br /&gt;&lt;/span&gt;&lt;span lang="EN-US" style="line-height: 34px; font-size: 12pt; font-family: 'Courier New'; "&gt;&lt;a href="http://blog.cdsn.net/kamus" style="text-decoration: none; color: rgb(51, 102, 153); "&gt;http://blog.cdsn.net/kamus&lt;/a&gt;&lt;/span&gt;&lt;span style="line-height: 34px; font-size: 12pt; font-family: 宋体; "&gt;。&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/272429821527780388-521828285981073572?l=codestandup.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/OTgDBOrsKYRcB2Uzsa8OTh6hYkw/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/OTgDBOrsKYRcB2Uzsa8OTh6hYkw/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/OTgDBOrsKYRcB2Uzsa8OTh6hYkw/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/OTgDBOrsKYRcB2Uzsa8OTh6hYkw/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Code-standup/~4/Voj1K3kx6EQ" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://codestandup.blogspot.com/feeds/521828285981073572/comments/default" title="張貼意見" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=272429821527780388&amp;postID=521828285981073572" title="0 個意見" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/272429821527780388/posts/default/521828285981073572?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/272429821527780388/posts/default/521828285981073572?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Code-standup/~3/Voj1K3kx6EQ/oracle-job-nextdate.html" title="Oracle (JOB) 更新next_date的探討" /><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14778696620700587607" /></author><thr:total>0</thr:total><feedburner:origLink>http://codestandup.blogspot.com/2010/12/oracle-job-nextdate.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUUBSH85eyp7ImA9Wx9SE0k.&quot;"><id>tag:blogger.com,1999:blog-272429821527780388.post-2902651225305801131</id><published>2010-12-02T19:30:00.000-08:00</published><updated>2010-12-02T19:34:19.123-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-12-02T19:34:19.123-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Database" /><title>Oracle PL/SQL 利用 Merge 進行兩個 Table 之間的資料比對與備份</title><content type="html">在 Oracle PL/SQL 中, 可以利用 &lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;&lt;b&gt;Merge &lt;/b&gt;&lt;/span&gt;進行新增 OR 修改資料的處理,&lt;br /&gt;若資料&lt;span class="Apple-style-span"  style="color:#FF0000;"&gt;&lt;b&gt;存在&lt;/b&gt;&lt;/span&gt;於來源 Table, 則要作何處理 (如修改資料),&lt;br /&gt;若資料&lt;b&gt;&lt;span class="Apple-style-span"  style="color:#FF0000;"&gt;不存在&lt;/span&gt;&lt;/b&gt;來源 Table, 則要作何處理 (如新增資料),&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;-- 建立來源 Temp Table&lt;/span&gt;&lt;br /&gt;create table tomSour (&lt;br /&gt;aa number&lt;br /&gt;, bb varchar2(100)&lt;br /&gt;);&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;-- 建立要比對的目的 Temp Table&lt;/span&gt;&lt;br /&gt;create table tomDest (&lt;br /&gt;aa number&lt;br /&gt;, bb varchar2(100)&lt;br /&gt;);&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;-- 新增來源資料&lt;/span&gt;&lt;br /&gt;insert into tomSour values( 1, '100' );&lt;br /&gt;insert into tomSour values( 2, '200' );&lt;br /&gt;insert into tomSour values( 3, '300' );&lt;br /&gt;insert into tomSour values( 4, '400' );&lt;br /&gt;insert into tomSour values( 5, '500' );&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;-- 新增目的資料&lt;/span&gt;&lt;br /&gt;insert into tomDest values( 1, 'abc' );&lt;br /&gt;insert into tomDest values( 3, 'xyz' );&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;-- 開始比對&lt;br /&gt;-- 若存在於來源, 則更改目的 Table 的 bb 欄位&lt;br /&gt;-- 若不存在於來源, 則新增到目地 Table&lt;/span&gt;&lt;br /&gt;begin&lt;br /&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;merge into&lt;/span&gt; tomDest d&lt;br /&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;    using &lt;/span&gt;tomSour s&lt;br /&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;       on &lt;/span&gt;(d.aa = s.aa)&lt;br /&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;     when MATCHED then&lt;/span&gt;&lt;br /&gt;       update set d.bb = d.bb || ' to ' || s.bb&lt;br /&gt;&lt;span class="Apple-style-span"  style="color:#3333FF;"&gt;     when NOT MATCHED then&lt;/span&gt;&lt;br /&gt;       insert (aa, bb ) values( s.aa, 'New: '||s.bb );&lt;br /&gt;end;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;-- 查看目的資料&lt;/span&gt;&lt;br /&gt;select * from tomDest;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span"  style="color:#009900;"&gt;-- 查詢結果 :&lt;/span&gt;&lt;br /&gt;1   abc to 100&lt;br /&gt;2   New: 200&lt;br /&gt;3   xyz to 300&lt;br /&gt;4   New: 400&lt;br /&gt;5   New: 500&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;source: tomkuo139.blogspot.com&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/272429821527780388-2902651225305801131?l=codestandup.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/4_6UljVKwn3g_YfiWj2qUFasE9s/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/4_6UljVKwn3g_YfiWj2qUFasE9s/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/4_6UljVKwn3g_YfiWj2qUFasE9s/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/4_6UljVKwn3g_YfiWj2qUFasE9s/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Code-standup/~4/vmgs0vpQ6sk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://codestandup.blogspot.com/feeds/2902651225305801131/comments/default" title="張貼意見" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=272429821527780388&amp;postID=2902651225305801131" title="0 個意見" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/272429821527780388/posts/default/2902651225305801131?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/272429821527780388/posts/default/2902651225305801131?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Code-standup/~3/vmgs0vpQ6sk/oracle-plsql-merge-table.html" title="Oracle PL/SQL 利用 Merge 進行兩個 Table 之間的資料比對與備份" /><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14778696620700587607" /></author><thr:total>0</thr:total><feedburner:origLink>http://codestandup.blogspot.com/2010/12/oracle-plsql-merge-table.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUANRngzcCp7ImA9WhZRF0s.&quot;"><id>tag:blogger.com,1999:blog-272429821527780388.post-2220473906862934505</id><published>2010-12-01T23:20:00.000-08:00</published><updated>2011-04-13T23:49:57.688-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-04-13T23:49:57.688-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Database" /><title>分隔數值變為 IN的 可用列表</title><content type="html">&lt;span class="Apple-style-span" &gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family:'courier new';"&gt;select to_number(&lt;br /&gt;&lt;span class="Apple-style-span"&gt;rtrim&lt;/span&gt;(&lt;br /&gt;substr&lt;span class="Apple-style-span" style="color:#006600;"&gt;(&lt;/span&gt;activityno,&lt;br /&gt;instr(activityno,',', 1, b.row_num)+1,&lt;br /&gt;instr(activityno,',',1,b.row_num+1) - instr(activityno,',',1,b.row_num)&lt;span class="Apple-style-span" style="color:#006600;"&gt;)&lt;/span&gt;&lt;br /&gt;,',') ) activity_no&lt;br /&gt;from ( select ','||'50009,60042'||',' activityno from dual) a,&lt;br /&gt;(select rownum row_num  from &lt;/span&gt;&lt;span class="Apple-style-span" style="color:#FF0000;"&gt;&lt;span class="Apple-style-span" style="font-family:'courier new';"&gt;mkt_record&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family:'courier new';"&gt;) b&lt;br /&gt;WHERE b.row_num &amp;lt;=((length(a.activityno)- length(replace(a.activityno,',')))/length(','))-1;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;div&gt;&lt;span class="Apple-style-span" &gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" &gt;&lt;b&gt;========================&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;b&gt;&lt;u&gt;&lt;span class="Apple-style-span" &gt;Result:&lt;/span&gt;&lt;/u&gt;&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" &gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" &gt;ACTIVITY_NO&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" &gt;------------------&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" &gt;50009&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" &gt;60042&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/272429821527780388-2220473906862934505?l=codestandup.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/JUZcLKzTrnXhgQDVkiRtLKQ8IDY/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/JUZcLKzTrnXhgQDVkiRtLKQ8IDY/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/JUZcLKzTrnXhgQDVkiRtLKQ8IDY/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/JUZcLKzTrnXhgQDVkiRtLKQ8IDY/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/Code-standup/~4/7EXSR9G-t5s" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://codestandup.blogspot.com/feeds/2220473906862934505/comments/default" title="張貼意見" /><link rel="replies" type="text/html" href="https://www.blogger.com/comment.g?blogID=272429821527780388&amp;postID=2220473906862934505" title="0 個意見" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/272429821527780388/posts/default/2220473906862934505?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/272429821527780388/posts/default/2220473906862934505?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/Code-standup/~3/7EXSR9G-t5s/in.html" title="分隔數值變為 IN的 可用列表" /><author><name>StandUp</name><uri>http://www.blogger.com/profile/09308017848947794586</uri><email>noreply@blogger.com</email><gd:extendedProperty name="OpenSocialUserId" value="14778696620700587607" /></author><thr:total>0</thr:total><feedburner:origLink>http://codestandup.blogspot.com/2010/12/in.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ck4EQng_cSp7ImA9Wx5TEk0.&quot;"><id>tag:blogger.com,1999:blog-272429821527780388.post-4309850808820531554</id><published>2010-07-26T20:20:00.000-07:00</published><updated>2010-07-26T20:21:43.649-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-07-26T20:21:43.649-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="System Design" /><title>构建的股指期货交易系统概述</title><content type="html">&lt;span class="Apple-style-span" style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; "&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 14px; margin-left: 0px; "&gt;&lt;strong&gt;概要&lt;/strong&gt;&lt;/p&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 14px; margin-left: 0px; "&gt;本 文主要介绍怎样使用 Java 相关技术构建一个股指期货交易系统（金融期货）。主要内容包括股指期货交易系统简介，系统业务架构，系统规划要求和采用的技术架构及使用 Java 技术的优点。其中重点介绍使用 Java 相关技术实现的系统架构，关键技术包括 – JMS, SOA/Web Service, Appliction Server Cluster 等。本文为系统的概要描述，不会过多阐述具体设计。&lt;/p&gt;&lt;strong&gt;1 股指期货交易系统简介&lt;/strong&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 14px; margin-left: 0px; "&gt;在本文中所提到的股指期货、期权交易系统，均指券商端的期货、期权交易系统。期货客户通过该交易系统连接到交易所撮合成交平台。系统提供客户下单，行情信息，资金结算和风险控制等功能。&lt;/p&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 14px; margin-left: 0px; "&gt;和股票交易系统类似，股指期货交易系统提供在线下单，行情查询等功能。和股票交易系统相比，期货、期权交易在业务上要求更复杂的风险控制和资金结算等功能。 在技术架构上，由于交易的标的物是指数或期权、贵金属、全球市场等，市场行情数据变化更频繁、相比于股票市场，风险更大。对系统的实时性、稳定性要求更高。&lt;/p&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 14px; margin-left: 0px; "&gt;在现代期货、期权交易中，有相当多的投资者进行快速、频繁的交易，追求短期交易机会。对券商的交易系统要求能提供一定程度的程序化交易功能和灵活的交易方式。面对激烈的商业竞争，券商应该能够提供多样化的交易方式、快速推出新的交易模式以吸引更多的投资者。&lt;/p&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 14px; margin-left: 0px; "&gt;在整个金融期货交易系统的规划中，应当考虑到以下几点 –&lt;/p&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 14px; margin-left: 0px; "&gt;1） 交易系统应该提供一个统一的交易平台，以支持多种产品交易，包括金融期货、期权、本地和全球市场&lt;/p&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 14px; margin-left: 0px; "&gt;2） 系统应该支持多种交易渠道，包括可下载的交易客户端， WEB 交易、电话委托和客户代理委托等&lt;/p&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 14px; margin-left: 0px; "&gt;3） 系统规划应分开企业核心信息服务和外围应用系统，以支持持续丰富的外围应用系统&lt;/p&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 14px; margin-left: 0px; "&gt;4） 面对激烈的商业竞争和业务变革，要求系统支持快速开发、部署和持续的新功能发布。&lt;/p&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 14px; margin-left: 0px; "&gt;&lt;br /&gt;&lt;/p&gt;&lt;strong&gt;2 系统业务框架&lt;/strong&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 14px; margin-left: 0px; "&gt;本章节主要介绍股指期货交易的业务框架，从高层次简介期货交易系统的功能。&lt;/p&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 14px; margin-left: 0px; "&gt;整个股指期货交易系统包括下面几个大的部分 –&lt;/p&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 14px; margin-left: 0px; "&gt;核心服务系统、券商内部运行维护系统、交易和行情借口、客户端交易终端系统等。&lt;/p&gt;&lt;strong&gt;核心服务系统&lt;/strong&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 14px; margin-left: 0px; "&gt;提供&lt;a href="http://www.rnjyz.com/daytrade-1999345-1-1/" style="color: black; text-decoration: none; "&gt;股指期货&lt;/a&gt;系统的核心功能，包括订单处理，交易管理、行情服务、风险管理、基础数据服务、 Back Office 服务（ Position 结算等）、数据中心（资金结算等）服务。这些功能以组件或服务的方式提供外部应用系统使用。&lt;/p&gt;&lt;strong&gt;运行维护系统&lt;/strong&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 14px; margin-left: 0px; "&gt;运 行服务系统为交易系统运行提供所有必要的操作支持，包括 Back Office 操作终端，风险管理 / 监控终端、 Data Center 操作终端、 Dealer/ 客户 Agent 交易终端等。 这些系统运行在券商的 LAN 之内，提供给券商的各类用户使用。&lt;/p&gt;&lt;strong&gt;统一交易、行情服务接口&lt;/strong&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 14px; margin-left: 0px; "&gt;期货交易系统的核心业务服务提供给 WLAN 或其他渠道的用户使用，要通过一个统一的交易和行情服务接口，以面向服务（ SOA ）的方式和其他外部交易终端集成。&lt;/p&gt;&lt;strong&gt;交易终端&lt;/strong&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 14px; margin-left: 0px; "&gt;交易终端通过统一交易、行情服务接口和核心系统交互。这些交易终端包括可下载的独立客户端、 WEB 页面客户端、电话客户端（通过语言模块转化）等。在技术架构章节，涉及的客户端为独立客户端。&lt;/p&gt;&lt;strong&gt;统一网关（交易、行情）&lt;/strong&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 14px; margin-left: 0px; "&gt;核心服务通过统一的交易和行情网关连接到本地交易所和全球市场。&lt;br /&gt;&lt;/p&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 14px; margin-left: 0px; "&gt;&lt;br /&gt;&lt;/p&gt;&lt;strong&gt;3 技术方案规划&lt;/strong&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 14px; margin-left: 0px; "&gt;基于核心交易系统的性质，在技术方案的规划时，需考虑以下因素 –&lt;/p&gt;&lt;strong&gt;高性能要求 （ Performance ）&lt;/strong&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 14px; margin-left: 0px; "&gt;相比于其他管理信息系统，期货交易系统要求更高的性能，包括行情数据的实时刷新,&lt;a href="http://www.rnjyz.com/daytrader-232-1/" style="color: black; text-decoration: none; "&gt;股票论坛&lt;/a&gt;，交易订单处理等。&lt;/p&gt;&lt;strong&gt;可扩充性要求 （ Scalability ）&lt;/strong&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 14px; margin-left: 0px; "&gt;股指期货交易系统通常支持较多的并发用户，且随着业务的发展，交易客户持续或快速增长，这要求系统有能力易于扩充以应付系统负载的增长。&lt;/p&gt;&lt;strong&gt;高稳定性要求 (Availability)&lt;/strong&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 14px; margin-left: 0px; "&gt;系统稳定性对于交易系统的重要性不言而喻。系统有能力在整体架构上防止单点失败，能有一定程度上的故障恢复（ Fail-over ）的能力。&lt;/p&gt;&lt;strong&gt;与其他系统集成&lt;/strong&gt;&lt;p style="margin-top: 0px; margin-right: 0px; margin-bottom: 14px; margin-left: 0px; "&gt;随着现在金融行业的快速发展和业务创新，交易系统也要求能和多个外部的系统包括第三方系统集成的能力，包括企业内部的客户管理系统（ CRM ），交易所、银行等。&lt;/p&gt;&lt;strong&gt;支持快速开发和业务创新&lt;
