輕便的客戶端oracle instant client安裝備忘:
假定instant client 解壓到E:\OracleInstantClient
1.SET PATH=E:\OracleInstantClient;
2.SET TNS_ADMIN=E:\OracleInstantClient
3.新建一個tnsnames.ora,然后填入
for example:
192.168.0.20 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.20)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = orcl)
)
)
4.SET LD_LIBRARY_PATH=E:\OracleInstantClient
5.如果要安裝SQL plus那么需要設置SET SQLPATH=E:\OracleInstantClient
6.如果查詢結果為亂碼,設置set NLS_LANG=XXXX(我自己是SIMPLIFIED CHINESE_CHINA.ZHS16CGB231280)
原地址:http://www.tkk7.com/rocky/archive/2007/09/13/oracle_instant_client.html
本文描述了一個用Java編寫的不使用專門SOAP庫的簡單通用SOAP客戶機。該客戶機可以讓您用任何 XML 編輯器(或文本編輯器)創建自己的請求, 而不是在暗中為您創建 SOAP 請求 XML 文檔。 該客戶機向您顯示實際的 SOAP 響應 XML 文檔,而不是僅僅提供遠程方法的返回值。 這個簡短的 Java 程序精確顯示了什么是 SOAP:打開 HTTP 連接、發送適當 XML 以調用遠程方法、接著讀取服務器返回的 XML 響應。 通用 Java SOAP 客戶機 SOAP(簡單對象訪問協議)是 IBM、Microsoft、DevelopMentor 和 UserLand Software 為在網絡上交換信息而開發的一種已在發展的 W3C 標準。 隨著Web上可以公開使用的SOAP服務器的不斷增加,SOAP幾乎對用任何語言編寫的程序——即使是用流行的簡單語言(如 Visual Basic、JavaScript 和 perl)編寫的非常短小的程序——執行著HTML對Web瀏覽器所做的事:它為這些程序提供一個簡單的方法來利用萬維網上不斷增加的可用信息源。 與 HTML 類似,SOAP 提供一套標記來表示在Web上使用HTTP傳輸協議(從 SOAP 1.1 以來,SMTP 也可以)發送的不同信息塊的作用。但是,SOAP向您提供的能力遠遠強于HTML。使用SOAP,您的程序向 SOAP服務器發送“SOAP請求”(一個簡短的XML文檔,描述在遠程機器上要調用的方法和所有要傳遞給它的參數)。SOAP服務器將嘗試用那些參數執行該方法,并將SOAP響應發回程序。響應可以是執行的結果,也可以是相應的錯誤消息??梢允褂霉睸OAP服務器為提出請求的客戶機提供股票價格、最新的貨幣兌換率、FedEx 包裹跟蹤信息、代數表達式的解決方案以及其它各類信息。 在SOAP存在之前,嘗試使用這種信息的程序必須先捕獲Web頁面,然后“刮下”HTML,以查找適當的文本。 對這些Web頁面進行可視的重新設計(例如,將當前股票價格放到表中第三列而不是第二列中)就可以使這些程序無用。SOAP規范以及它所攜帶的簡要的SOAP請求和響應模式為客戶機和服務器之間的聯絡提供了一個框架,該框架是那些強健得多的信息收集工具的基礎。 有許多SOAP客戶機可用于大多數的流行編程語言;有關詳盡列表,請參閱 SOAP::Lite for Perl 主頁上的 SOAP Toolkits 部分(請參閱參考資料)。大多數 SOAP 客戶機都提供類庫、COM 對象或從您自己程序調用的等同對象。通常,使用這些客戶機庫遵循以下模式: · 程序傳遞要調用的遠程方法的名稱和所有必需參數。 · 庫組裝 SOAP 請求的適當 XML 文檔以將這一信息打包。 · 庫將這一 XML 文檔傳遞給 SOAP 端點 URL 標識的 SOAP 服務器,這與通過指定服務器的 URL 將瀏覽器指向 Web 服務器地址很類似。 · SOAP 服務器嘗試執行方法后,它組裝包含執行結果的 SOAP 響應 XML 文檔,并將它發回 SOAP 客戶機。 · 接收SOAP響應時,客戶機庫對XML進行語法分析以獲得方法調用的結果,并將結果傳遞給使用庫的程序。 SOAPClient4XG SOAP 的介紹(請參閱 developerWorks 上 Graham Glass 編寫得極佳的“ Web 服務革命”專欄)總是討論用于 SOAP 請求和響應的 XML 的結構,但是我接觸到的 SOAP 客戶機總是會暗中進行 XML 組裝和語法分析,所以我從來不用知道。 作為使用 XML 的人員,我曾想自己執行 XML 部分;我認為如果 SOAP 這樣簡單,那么我應該能夠編寫一個簡單的 SOAP 客戶機來讀取 SOAP 請求的 XML 文檔、將它發送到命令行上指定的 SOAP 端點 URL、讀回響應文檔并輸出該響應。這將使它成為一個真正的通用 SOAP 客戶機,因為它調用任何 SOAP 服務器上的任何方法。 清單1中顯示的 SoapClient4XG(“SOAP Client for XML Geeks”)Java類執行該任務,而不使用早先提到的 SOAP Toolkits 頁面上列出的任何專用 Java SOAP 類(請參閱參考資料)。 檢查了必需的 SOAP 端點 URL 和 SOAP XML 文檔文件名參數及可選的 SOAP 操作參數后,讀入文件,將它發送到 SOAP 服務器,讀回響應,然后將其輸出到標準出口。 清單1 Listing 1. The complete SOAP client /** * SOAPClient4XG. Read the SOAP envelope file passed as the second * parameter, pass it to the SOAP endpoint passed as the first parameter, and * print out the SOAP envelope passed as a response. with help from Michael * Brennan 03/09/01 * * * @author Bob DuCharme * @version 1.1 * @param SOAPUrl URL of SOAP Endpoint to send request. * @param xmlFile2Send A file with an XML document of the request. * * 5/23/01 revision: SOAPAction added */ import java.io.*; import java.net.*; public class SOAPClient4XG { public static void main(String[] args) throws Exception { if (args.length < 2) { System.err.println("Usage: java SOAPClient4XG " + "http://soapURL soapEnvelopefile.xml" + " [SOAPAction]"); System.err.println("SOAPAction is optional."); System.exit(1); } String SOAPUrl = args[0]; String xmlFile2Send = args[1]; String SOAPAction = ""; if (args.length > 2) SOAPAction = args[2]; // Create the connection where we're going to send the file. URL url = new URL(SOAPUrl); URLConnection connection = url.openConnection(); HttpURLConnection httpConn = (HttpURLConnection) connection; // Open the input file. After we copy it to a byte array, we can see // how big it is so that we can set the HTTP Cotent-Length // property. (See complete e-mail below for more on this.) FileInputStream fin = new FileInputStream(xmlFile2Send); ByteArrayOutputStream bout = new ByteArrayOutputStream(); // Copy the SOAP file to the open connection. copy(fin,bout); fin.close(); byte[] b = bout.toByteArray(); // Set the appropriate HTTP parameters. httpConn.setRequestProperty( "Content-Length", String.valueOf( b.length ) ); httpConn.setRequestProperty("Content-Type","text/xml; charset=utf-8"); httpConn.setRequestProperty("SOAPAction",SOAPAction); httpConn.setRequestMethod( "POST" ); httpConn.setDoOutput(true); httpConn.setDoInput(true); // Everything's set up; send the XML that was read in to b. OutputStream out = httpConn.getOutputStream(); out.write( b ); out.close(); // Read the response and write it to standard out. InputStreamReader isr = new InputStreamReader(httpConn.getInputStream()); BufferedReader in = new BufferedReader(isr); String inputLine; while ((inputLine = in.readLine()) != null) System.out.println(inputLine); in.close(); } // copy method from From E.R. Harold's book "Java I/O" public static void copy(InputStream in, OutputStream out) throws IOException { // do not allow other threads to read from the // input or write to the output while copying is // taking place synchronized (in) { synchronized (out) { byte[] buffer = new byte[256]; while (true) { int bytesRead = in.read(buffer); if (bytesRead == -1) break; out.write(buffer, 0, bytesRead); } } } } } |