




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、開源從代碼分享開始 分享代碼所有標(biāo)簽»熱門標(biāo)簽jQuery(1163) PHP(473) Python(470) Android SDK(372) Spring(295) MySQL(236) AAuto Quicker(217) Ru(206) Android(205) Hibernate(124) Java(112) JFinal(92) Qt(87) Struts(85) Perl(84) Oracle(79) jsoup(79) ExtJS(75) 排序(74) Windows(74) HttpClient(72) 精華(69) jQuery XML(68) OSCHINA(
2、65) Nginx(64) JDK(59) ThinkPHP(54) 正則表達(dá)式(53) Swing(52) JavaScript(52) HTTP(52) Scala(50) JSON(49) MyBatis(48) Excel(48) Bootstrap(47) Apache(45) 字符串(45) 算法(45) Boost(44)TOP40活躍貢獻(xiàn)者代碼片段文件 Form1.cs 77KB 文件 Form1.Designer.cs 79KB 文件 Program.cs 495B using System;using System.Collections.Generic;using Sys
3、tem.Linq;using System.Windows.Forms;將excel表格中具有相同sheet頁的模板進(jìn)行對(duì)比計(jì)數(shù)OSCHINA代碼分享代碼語言代碼分類JavaCC+C#JavaScriptPHPPerlPythonRuRailsHTMLXMLCSSASPBasicDelphiPascalScalaGroovyLuaSQLGoogle GoFlashActionScriptFlexWPFSliverLightShell批處理其他Objective-C排序?yàn)g覽評(píng)論代碼 配置文件 pertitsconnection.driverclass=com.mysql.jdbc
4、.Driver#connection.=jdbc:mysql:/08:3306/InvFinAdmin?useUnicode=true&characterEncoding=UTF-8connection.=jdbc:mysql:/:3306/Mybatis?useUnicode=true&characterEncoding=UTF-8connection.username=root#connection.password=2a4c094bbb588e8169connection.password=123456connection.init
5、ialPoolSize=10connection.minPoolSize=20connection.maxPoolSize=50connection.maxIdleTime=1800connection.preferredTestQuery=SELECT 1 connection.idleConnectionTestPeriod=18000connection.testConnectionOnCheckout=true pertieslog4j.rootLogger=DEBUG, A1, D namespace ExcelToDB_Form static class Prog
6、ram <summary>應(yīng)用程序的主入口點(diǎn)。<summary> STAThread static void Main() Application.EnableVisualStyles();Application.SetCompatibleTextRenderingDefault(false);Application.Run(new Form1(); #.apache=INFO,apache 文件 AssemblyInfo.cs 1KB using System.Reflection;using System.Runtime.Comp
7、ilerServices;using System.Runtime.InteropServices;.springframework.jdbc=DEBUG,spring #.mchange=INFO,mchangelog4j.appender.A1=org.apache.log4j.ConsoleAppender log4j.appender.A1.layout=org.apache.log4j.PatternLayout log4j.appender.A1.layout.ConversionPattern=%-4r %-5p %t %37c %3x - %
8、m%n log4j.appender.D = org.apache.log4j.DailyRollingFileAppender log4j.appender.D.File = logs/error.log log4j.appender.D.Append = true log4j.appender.D.Threshold = ERROR log4j.appender.D.layout = org.apache.log4j.PatternLayout log4j.appender.D.layout.ConversionPattern = %-dyyyy-MM-dd HH:mm:ss %t:%r
9、- %p %m%n 代碼 Google Go代碼 package mainimport ( "io/ioutil" "net/http" "net/" "fmt" "encoding/json") /-/ 黃金數(shù)據(jù)調(diào)用示例代碼 聚合數(shù)據(jù)/ 在線接口文檔:www/docs/29/- const APPKEY = "*" /您申請(qǐng)的APPKEY func main() /1.上海黃金交易所 Request1() /2.上海期貨交易所 Request2() /3.銀行賬戶黃金 Re
10、quest3() 有關(guān)程序集的常規(guī)信息通過以下 特性集控制。更改這些特性值可修改 與程序集關(guān)聯(lián)的信息。/1.上海黃金交易所func Request1() /請(qǐng)求地址 juhe :="web:8080/finance/gold/shgold" /初始化參數(shù) param:=.Values /配置請(qǐng)求參數(shù),方法內(nèi)部已處理encode問題,中文參數(shù)可以直接傳參 param.Set("key",APPKEY) /APP Key param.Set("v","") /JSON格式版本(0或1)默認(rèn)為0 /發(fā)送請(qǐng)求 data,e
11、rr:=Get(juhe,param) if err!=nil fmt.Errorf("請(qǐng)求失敗,錯(cuò)誤信息:rn%v",err) else var netReturn mapstringinterface json.Unmarshal(data,&netReturn) if netReturn"error_code".(float64)=0 fmt.Printf("接口返回result字段是:rn%v",netReturn"result") assembly: AssemblyTitle("Exc
12、elToDB-Form")assembly: AssemblyDescription("")assembly: AssemblyConfiguration("")assembly: AssemblyCompany("微軟中國")assembly: AssemblyProduct("ExcelToDB-Form")/2.上海期貨交易所func Request2() /請(qǐng)求地址 juhe :="web:8080/finance/gold/shfuture" /初始化參數(shù) param:=.V
13、alues /配置請(qǐng)求參數(shù),方法內(nèi)部已處理encode問題,中文參數(shù)可以直接傳參 param.Set("key",APPKEY) /APP Key param.Set("v","") /JSON格式版本(0或1)默認(rèn)為0 assembly: AssemblyCopyright("Copyright © 微軟中國 2013")assembly: AssemblyTrademark("")assembly: AssemblyCulture("") /發(fā)送請(qǐng)求 data,
14、err:=Get(juhe,param) if err!=nil fmt.Errorf("請(qǐng)求失敗,錯(cuò)誤信息:rn%v",err) else var netReturn mapstringinterface json.Unmarshal(data,&netReturn) if netReturn"error_code".(float64)=0 fmt.Printf("接口返回result字段是:rn%v",netReturn"result") /3.銀行賬戶黃金func Request3() /請(qǐng)求地址 j
15、uhe :="web:8080/finance/gold/bankgold" /初始化參數(shù) param:=.Values /配置請(qǐng)求參數(shù),方法內(nèi)部已處理encode問題,中文參數(shù)可以直接傳參 param.Set("key",APPKEY) /APP Key /發(fā)送請(qǐng)求 data,err:=Get(juhe,param) if err!=nil fmt.Errorf("請(qǐng)求失敗,錯(cuò)誤信息:rn%v",err) else var netReturn mapstringinterface json.Unmarshal(data,&n
16、etReturn) if netReturn"error_code".(float64)=0 fmt.Printf("接口返回result字段是:rn%v",netReturn"result") / get 網(wǎng)絡(luò)請(qǐng)求func Get(api string,params .Values)(rsbyte ,err error) var *. ,err=.Parse(api) if err!=nil fmt.Printf("解析錯(cuò)誤:rn%v",err) return nil,err /如果參數(shù)中有中文參數(shù),這個(gè)方法會(huì)進(jìn)
17、行Encode .RawQuery=params.Encode() resp,err:=http.Get(.String() if err!=nil fmt.Println("err:",err) return nil,err defer resp.Body.Close() return ioutil.ReadAll(resp.Body) / post 網(wǎng)絡(luò)請(qǐng)求 ,params 是.Values類型func Post(api string, params .Values)(rsbyte,err error) resp,err:=http.PostForm(api, para
18、ms) if err!=nil return nil ,err defer resp.Body.Close() return ioutil.ReadAll(resp.Body)代碼描述:基于GO的黃金數(shù)據(jù)接口調(diào)用代碼實(shí)例關(guān)聯(lián)數(shù)據(jù):黃金數(shù)據(jù)代碼 C#代碼 using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Net;using System.IO;using Xfrog.Net;using System.Diagnostics;using System.Web;
19、 /-/ 黃金數(shù)據(jù)調(diào)用示例代碼 聚合數(shù)據(jù)/ 在線接口文檔:www/docs/29/ 代碼中JsonObject類下載地址:/download/gcm3206021155665/7458439/- namespace ConsoleAPI class Program static void Main(string args) string appkey = "*" /配置您申請(qǐng)的appkey /1.上海黃金交易所 string 1 = "web:8080/finance/gold/shgold" var parameters1 = new Dictiona
20、ry<string, string>(); parameters1.Add("key", appkey);/你申請(qǐng)的key parameters1.Add("v" , ""); /JSON格式版本(0或1)默認(rèn)為0 string result1 = sendPost(1, parameters1, "get"); JsonObject newObj1 = new JsonObject(result1); String errorCode1 = newObj1"error_code".
21、Value; if (errorCode1 = "0") Debug.WriteLine("成功"); Debug.WriteLine(newObj1); else /Debug.WriteLine("失敗"); Debug.WriteLine(newObj1"error_code".Value+":"+newObj1"reason".Value); /2.上海期貨交易所 string 2 = "web:8080/finance/gold/shfuture"
22、; var parameters2 = new Dictionary<string, string>(); 將 ComVisible 設(shè)置為 false 使此程序集中的類型 對(duì) COM 組件不可見。如果需要從 COM 訪問此程序集中的類型, 則將該類型上的 ComVisible 特性設(shè)置為 true。assembly: ComVisible(false) parameters2.Add("key", appkey);/你申請(qǐng)的key parameters2.Add("v" , ""); /JSON格式版本(0或1)默認(rèn)為0
23、 string result2 = sendPost(2, parameters2, "get"); JsonObject newObj2 = new JsonObject(result2); String errorCode2 = newObj2"error_code".Value; if (errorCode2 = "0") Debug.WriteLine("成功"); Debug.WriteLine(newObj2); else /Debug.WriteLine("失敗"); Debug.
24、WriteLine(newObj2"error_code".Value+":"+newObj2"reason".Value); /3.銀行賬戶黃金 string 3 = "web:8080/finance/gold/bankgold" var parameters3 = new Dictionary<string, string>(); parameters3.Add("key", appkey);/你申請(qǐng)的key string result3 = sendPost(3, param
25、eters3, "get"); JsonObject newObj3 = new JsonObject(result3); String errorCode3 = newObj3"error_code".Value; if (errorCode3 = "0") Debug.WriteLine("成功"); Debug.WriteLine(newObj3); else /Debug.WriteLine("失敗"); Debug.WriteLine(newObj3"error_code&q
26、uot;.Value+":"+newObj3"reason".Value); / <summary> / Http (GET/POST) / </summary> / <param name="">請(qǐng)求</param> / <param name="parameters">請(qǐng)求參數(shù)</param> / <param name="method">請(qǐng)求方法</param> / <returns>
27、;響應(yīng)內(nèi)容</returns> static string sendPost(string , IDictionary<string, string> parameters, string method) if (method.ToLower() = "post") HttpWebRequest req = null; HttpWebResponse rsp = null; System.IO.Stream reqStream = null; try req = (HttpWebRequest)WebRequest.Create(); req.Met
28、hod = method; req.KeepAlive = false; req.ProtocolVersion = HttpVersion.Version10; req.Timeout = 5000; req.ContentType = "application/x-www-form-encoded;charset=utf-8" byte postData = Encoding.UTF8.GetBytes(BuildQuery(parameters, "utf8"); reqStream = req.GetRequestStream(); reqStr
29、eam.Write(postData, 0, postData.Length); rsp = (HttpWebResponse)req.GetResponse(); Encoding encoding = Encoding.GetEncoding(rsp.CharacterSet); return GetResponseAsString(rsp, encoding); catch (Exception ex) return ex.Message; finally if (reqStream != null) reqStream.Close(); if (rsp != null) rsp.Clo
30、se(); else /創(chuàng)建請(qǐng)求 HttpWebRequest request = (HttpWebRequest)WebRequest.Create( + "?" + BuildQuery(parameters, "utf8"); /GET請(qǐng)求 request.Method = "GET" request.ReadWriteTimeout = 5000; request.ContentType = "text/html;charset=UTF-8" HttpWebResponse response = (Http
31、WebResponse)request.GetResponse(); Stream myResponseStream = response.GetResponseStream(); StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8"); /返回內(nèi)容 string retString = myStreamReader.ReadToEnd(); return retString; / <summary> / 組裝普通文本請(qǐng)求參數(shù)。
32、/ </summary> / <param name="parameters">Key-Value形式請(qǐng)求參數(shù)字典</param> / <returns>編碼后的請(qǐng)求數(shù)據(jù)</returns> static string BuildQuery(IDictionary<string, string> parameters, string encode) StringBuilder postData = new StringBuilder(); bool hasParam = false; IEnumerat
33、or<KeyValuePair<string, string>> dem = parameters.GetEnumerator(); while (dem.MoveNext() string name = dem.Current.Key; string value = dem.Current.Value; / 忽略參數(shù)名或參數(shù)值為空的參數(shù) if (!string.IsNullOrEmpty(name)/&& !string.IsNullOrEmpty(value) if (hasParam) postData.Append("&&quo
34、t;); postData.Append(name); postData.Append("="); if (encode = "gb2312") postData.Append(HttpUtility.Encode(value, Encoding.GetEncoding("gb2312"); else if (encode = "utf8") postData.Append(HttpUtility.Encode(value, Encoding.UTF8); else postData.Append(value);
35、hasParam = true; return postData.ToString(); / <summary> / 把響應(yīng)流轉(zhuǎn)換為文本。 / </summary> / <param name="rsp">響應(yīng)流對(duì)象</param> / <param name="encoding">編碼方式</param> / <returns>響應(yīng)文本</returns> static string GetResponseAsString(HttpWebResponse r
36、sp, Encoding encoding) System.IO.Stream stream = null; StreamReader reader = null; try / 以字符流的方式讀取HTTP響應(yīng) stream = rsp.GetResponseStream(); reader = new StreamReader(stream, encoding); return reader.ReadToEnd(); finally / 釋放資源 if (reader != null) reader.Close(); if (stream != null) stream.Close(); if
37、 (rsp != null) rsp.Close(); 代碼 PHP代碼 /* * c遠(yuǎn)程傳輸工具 */public function post_c($,$body,$header,$type='POST') $ch = c_init(); c_setopt($ch,COPT_,$); c_setopt($ch,COPT_HEADER,0);/0只要正文 c_setopt($ch,COPT_TIMEOUT,5);/設(shè)置超時(shí)時(shí)間 c_setopt($ch,COPT_CONNECTTIMEOUT,5); /將c_exec()獲取的信息以文件流的形式返回,而不是直接輸出。 c_set
38、opt($ch,COPT_RETURNTRANSFER,1); /增加header頭信息 / array_push($header,'Accept:application/json'); / array_push($header,'Content-Type:application/json'); / array_push($header,'http:multipart/form-data'); if(count($body)>0) c_setopt($ch,COPT_POSTFIELDS,$body); if(count($header)&
39、gt;0) c_setopt($ch,COPT_HTTPHEADER,$header); /設(shè)置上傳文件相關(guān) c_setopt($ch,COPT_FOLLOWLOCATION,true); c_setopt($ch,COPT_MAXREDIRS,3);/遞歸 c_setopt($ch,COPT_SSL_VERIFYPEER,false);/ 對(duì)認(rèn)證證書來源的檢查 c_setopt($ch,COPT_SSL_VERIFYHOST,0);/ 從證書中檢查SSL加密算法 switch ($type) case 'GET': c_setopt($ch,COPT_HTTPGET,1);
40、break; case 'POST': c_setopt($ch,COPT_POST,1); break; case 'PUT': c_setopt($ch,COPT_CUSTOMREQUEST,'PUT'); break; case 'DELETE': c_setopt($ch,COPT_CUSTOMREQUEST,'DELETE'); break; /上傳文件相關(guān)設(shè)置 c_setopt($ch,COPT_ENCODING,'gzip'); c_setopt($ch,COPT_USERAGENT,
41、'SSTS Browser/1.0'); c_setopt($ch,COPT_USERAGENT,'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0)');/ 模擬用戶使用的瀏覽器 if(c_errno($ch) return c_error($ch); $content = c_exec($ch); c_close($ch);/關(guān)閉c資源,并且釋放系統(tǒng)資源 $result = json_decode($content,true); if(!empty($result) return $
42、result; else return $content; 代碼 C/C+代碼 /*編譯指令$ /opt/sybase/OCS-16_0/bin/cpre64 -m teststu.cp$ cc -m64 -g -DSYB_LP64 -I. -I/opt/sybase/OCS-16_0/include teststu.c /opt/sybase/OCS-16_0/include/sybesql.c -L/opt/sybase/OCS-16_0/lib -lsybct64 -lsybtcl64 -lsybcs64 -lsybcomn64 -lsybintl64 -lsybunic64 -rdyn
43、amic -ldl -lnsl -lm -o teststu*/#include <stdio.h> /*建立通訊區(qū)域*/EXEC SQL INCLUDE SQLCA;/* * These tokens must be declared in a declare section* because they are used in declare sections below.*/EXEC SQL BEGIN DECLARE SECTION;#define TYPESIZE 13#define TIDSIZE 6EXEC SQL END DECLARE SECTION; #defin
44、e EOLN '0'/* * Forward declarations of the error and message handlers and* other subroutines called from main().*/void error_handler();void warning_handler(); intmain(int argc, char *argv)/*聲明宿主變量*/ EXEC SQL BEGIN DECLARE SECTION; /* storage for login name and password. */ char username30; c
45、har sname30; char password30; char server30; EXEC SQL END DECLARE SECTION;/*錯(cuò)誤處理*/ EXEC SQL WHENEVER SQLERROR CALL error_handler(); EXEC SQL WHENEVER SQLWARNING CALL warning_handler(); EXEC SQL WHENEVER NOT FOUND CONTINUE;/*連接到 SQL SERVER 服務(wù)器*/ /* * Copy the user name and password defined in sybsqle
46、x.h to * the variables declared for them in the declare section. */ strcpy(username, "mymotif"); strcpy(password, "wxwpxh"); strcpy(server, "MYMOTIFVOSTRO145480"); EXEC SQL CONNECT :username IDENTIFIED BY :password using :server; EXEC SQL USE testdb; EXEC SQL DECLARE c1
47、 CURSOR FOR SELECT SNAME FROM STUDENT; EXEC SQL OPEN c1; printf("name in table studentn"); do EXEC SQL FETCH c1 INTO :sname; if (sqlca.sqlcode != 0) break; printf( "student name = %sn", sname ); while ( 1 ); EXEC SQL CLOSE c1; return(0); /*錯(cuò)誤處理程序*/* void error_handler()* * Displa
48、ys error codes and numbers from the SQLCA and exits with* an ERREXIT status. */voiderror_handler(void) fprintf(stderr, "n* SQLCODE=(%ld)", sqlca.sqlcode); if (sqlca.sqlerrm.sqlerrml) fprintf(stderr, "n* ASE Error "); fprintf(stderr, "n* %s", sqlca.sqlerrm.sqlerrmc); fprintf(stderr, "nn"); exit(-1); /* void warning_ha
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年的設(shè)備租賃合同范本
- 2025年勞動(dòng)合同制度的革新及其影響
- 《時(shí)尚潮流女鞋深度解析》課件
- 2025水電裝潢合同(李)
- 《社團(tuán)組織創(chuàng)建流程》課件
- 中小學(xué)校長在教師會(huì)議上講話:教育者要“作為、善為、樂為”-
- 供應(yīng)鏈優(yōu)化與整合實(shí)施方案
- 2025如何制定合同:合同草案審查指南制定說明
- 2025標(biāo)準(zhǔn)版商品房買賣合同
- 2025年南寧貨運(yùn)駕駛從業(yè)資格考試題庫模擬考試
- (讀書筆記)禮物的流動(dòng):一個(gè)中國村莊中的互惠原則和社會(huì)網(wǎng)絡(luò)
- 《醫(yī)療垃圾的分類》課件
- 江蘇師范大學(xué)成人繼續(xù)教育網(wǎng)絡(luò)課程《英語》單元測試及參考答案
- 雙堿法脫硫操作規(guī)程
- 全國中學(xué)生物理競賽及實(shí)驗(yàn)課件
- 病案信息技術(shù)基礎(chǔ)知識(shí)考試重點(diǎn)梳理(最新最全)
- 安全施工作業(yè)票(模版)
- 環(huán)保管理制度(適用于軟件企業(yè))
- DB 33-T 1015-2021居住建筑節(jié)能設(shè)計(jì)標(biāo)準(zhǔn)(高清正版)
- 鋼結(jié)構(gòu)門式剛架廠房設(shè)計(jì)土木工程畢業(yè)設(shè)計(jì)
- 中國供銷合作社標(biāo)識(shí)使用手冊(cè)課件
評(píng)論
0/150
提交評(píng)論