發表文章

詳盡的Nginx效能測試

最近開始想要研究Nginx...找到一個很詳盡的壓測結果 給大家參考: http://www.cnblogs.com/killkill/archive/2010/04/14/1711810.html

Hibernate c3p0 pool

在Hibernate中使用Connection Pool來增強與資料庫連線的穩定度... <!-- configuration pool via c3p0 --> < property name = "connection.provider_class" > org.hibernate.connection.C3P0ConnectionProvider </ property > < property name = "c3p0.min_size" > 0 </ property > < property name = "c3p0.max_size" > 30 </ property > < property name = "c3p0.timeout" > 600 </ property > < property name = "c3p0.max_statements" > 0 </ property > < property name = "c3p0.acquire_increment" > 1 </ property > < property name = "c3p0.idle_test_period" > 60 </ property >

MS SQL import SQL file

兩種從MSSQL執行外部檔案的方式: 1. Execute file from SQL Tool -- To allow advanced options to be changed. EXEC sp_configure 'show advanced options', 1 GO -- To update the currently configured value for advanced options. RECONFIGURE GO -- To enable the feature. EXEC sp_configure 'xp_cmdshell', 1 GO -- To update the currently configured value for this feature. RECONFIGURE GO EXEC master..xp_cmdshell   ' c:\Scripts\create_db.sql' 2. Execute file from CMD Tool SQLCMD -E -d master -i c:\Scripts\create_db.sql

MySQL select to file

兩種儲存MySQL資料到檔案的方法 Piping the SQL into the database echo "SELECT * FROM TABLE_NAME" | mysql -uUSERNAME -pPASSWORD DATABASENAME > /tmp/outfile.txt;    Using an external SQL file. mysql -uUSERNAME -pPASSWORD DATABASENAME < /tmp/sql.sql > /tmp/outfile.txt;

Executing exe on Mac

Enjoy a bottle of Wine... http://winebottler.kronenberg.org/

Android doPost request encoding problem

日前在開發一個Android上的doPost需求時候 發現在呼叫伺服端主機時候,均會有中文亂碼問題 後來文獻中找到應該是輸入參數時候需要在轉碼一次(或者說指定用UTF-8) 下面是各通用的doPost方法 供有需要的人參考:   public String getDataFromUrl(String url, Map<String, String> params) { HttpClient httpclient = new DefaultHttpClient(); HttpPost httppost = new HttpPost(url); String result = null; Log.d(TAG, "Params: " + params); try { List<NameValuePair> pairs = null; if(params != null){ pairs = new ArrayList<NameValuePair>(params.size()); for(String k : params.keySet()){ String v = params.get(k); pairs.add(new BasicNameValuePair(k,v)); } } httppost.setEntity(new UrlEncodedFormEntity(pairs, HTTP.UTF_8 )); // Finally, execute the request HttpResponse webServerAnswer = httpclient.execute(httppost); Log.d(TAG, ">>>" + httppost.getURI()); Log.d(TAG, ">>>" + httppost.getParams()); HttpEntity httpEntity = web...

Python + MySQL 效能增進

下面是一篇Python使用SSCursor做MySQL資料查詢的文章 其中使用SSCursor做大量資料查詢時,可以更有效能 有興趣的人,可以參考一下: http://fcamel-life.blogspot.com/2010/08/python-mysql.html 下面是可用的Code,可以參考: import MySQLdb from MySQLdb.cursors import SSCursor db = MySQLdb.connect(host="db_ip_address", user="db_user", passwd="db_password", db="db_name") sql = "SELECT * FROM some_table" cursor = db.cursor(cursorclass=SSCursor) #cursor = db.cursor() cursor.execute(sql) result = cursor.fetchall() try:   for record in result:     print record[0] finally:   cursor.close()   db.close()