2011年12月5日 星期一

[MySQL]乾淨移除MySQL的步驟

1. ‘Uninstall’ mysql from the Control panel.
2. remove the “C:\Program Files\MySQL” folder.
3. Delete the mysql service my using command in command prompt “Sc delete mysql”
4. remove the “C:\Users\pc\AppData\RoaminMySql” folder.
5. Again Reinstall a fresh copy

2011年10月11日 星期二

[DOS] netstat指令

Displays protocol statistics and current TCP/IP network connections.

NETSTAT [-a] [-b] [-e] [-n] [-o] [-p proto] [-r] [-s] [-v] [interval]

  -a            Displays all connections and listening ports.
  -b            Displays the executable involved in creating each connection or
                listening port. In some cases well-known executables host
                multiple independent components, and in these cases the
                sequence of components involved in creating the connection
                or listening port is displayed. In this case the executable
                name is in [] at the bottom, on top is the component it called,
                and so forth until TCP/IP was reached. Note that this option
                can be time-consuming and will fail unless you have sufficient
                permissions.
  -e            Displays Ethernet statistics. This may be combined with the -s
                option.
  -n            Displays addresses and port numbers in numerical form.
  -o            Displays the owning process ID associated with each connection.
  -p proto      Shows connections for the protocol specified by proto; proto
                may be any of: TCP, UDP, TCPv6, or UDPv6.  If used with the -s
                option to display per-protocol statistics, proto may be any of:
                IP, IPv6, ICMP, ICMPv6, TCP, TCPv6, UDP, or UDPv6.
  -r            Displays the routing table.
  -s            Displays per-protocol statistics.  By default, statistics are
                shown for IP, IPv6, ICMP, ICMPv6, TCP, TCPv6, UDP, and UDPv6;
                the -p option may be used to specify a subset of the default.
  -v            When used in conjunction with -b, will display sequence of
                components involved in creating the connection or listening
                port for all executables.
  interval      Redisplays selected statistics, pausing interval seconds
                between each display.  Press CTRL+C to stop redisplaying
                statistics.  If omitted, netstat will print the current
                configuration information once.

2011年10月4日 星期二

[Maven]missing artifact com.sun:tools:jar:1.5.0

解決方式: 在pom.xml增加dependency
在local repository依照錯誤建立資料夾, 並將tools.jar置於其中
        <dependency>
            <groupId>com.sun</groupId>
            <artifactId>tools</artifactId>
            <version>1.5.0</version>
        </dependency>

        <dependency>
            <groupId>com.sun</groupId>
            <artifactId>tools</artifactId>
            <version>1.5.0</version>
            <scope>system</scope>
            <systemPath>%jdk path%/lib/tools.jar</systemPath>
        </dependency>

2011年9月5日 星期一

2011年8月30日 星期二

2011年8月10日 星期三

[java]log4j設定

#定義logger "test.board", 這可以以namespace層級方式設定, 如傳入class屬於test.board.aaa, 則會取到此logger
log4j.logger.test.board=debug, A1
#避免讓rootLogger也有重複的輸出, 要加入這一行
log4j.additivity.test.board=false
#設定logger "test.board"顯示在哪種裝置上
log4j.appender.A1=org.apache.log4j.ConsoleAppender
#設定logger "test.board"顯示訊息的格式
log4j.appender.A1.layout.ConversionPattern=%d{ABSOLUTE} %5p [%t] (%F:%L) - %m%n
log4j.appender.A1.layout=org.apache.log4j.PatternLayout


"Log4j的關鍵之處在于它的繼承思想。也就是一個Log可以繼承另外一個Log的屬性(輸出到哪里,日誌等級,日誌格式等等)。怎麼繼承?
Log4j是根據Log的名字來判斷繼承關係的,比如:
名字為“com.zhlmmc.lib”的Log就是“com.zhlmmc.lib.log”的parent,明白了吧!Log4j還有一個rootLogger,相當於JavaObject回過頭來看“LogFactory.getLog(Test.class)”這裏的“Test.class”事實上傳進去的是Test這個類的完整路徑(包名+類名),“test.Test”。這樣如果存在“test”這個Log那麼Test這個Log就繼承它,否則就繼承rootLogger。"




2011年8月8日 星期一

[Visual Studio] *.vshost.exe的用處

轉自http://chuiwenchiu.wordpress.com/2006/04/21/c%E4%B8%80%E5%A0%86-vshost-exe-%E6%98%AF%E5%81%9A%E4%BB%80%E9%BA%BC%E7%94%A8%E5%95%8A/
不知道有沒有人發現 bin/Debug 或 bin/Release 下會出現 [Application Name].vshost.exe,這個檔案是做什麼用的呢?依據官方[1]說法,這個是 Visual Studio 2005 為了以下三個目的所加上去的:
1. 改善除錯效能
2. Partial Trust Debugging:這個沒有用過不太清楚,不過依據文件[1]的描述,好像是為了測試應用程式的安全性必須透過 vshost 來進行初始化…
3. 設計階段可以使用 Immediate Window 進行除錯
簡言之,這個檔案就是為了除錯用。
接下來的問題是,如果程式要出貨想關閉這個功能要怎麼做呢?
只要選取 Project | Properties | Debug,將 Enable the Visual Studio hosting process 選項前的鉤鉤取消即可[3]。

參考資料:
[1] http://msdn2.microsoft.com/en-us/library/ms185331.aspx
[2] http://msdn2.microsoft.com/en-us/library/ms242202.aspx
[3] http://msdn2.microsoft.com/en-us/library/ms185330.aspx
[4] http://blogs.msdn.com/dtemp/archive/2004/08/17/215764.aspx

2011年7月21日 星期四

[JMS] MessageListener.onMessage

A client can register an object that implements the JMS MessageListener interface with a MessageConsumer. As messages arrive for the consumer, the provider delivers them by calling the listener’s onMessage method.

It is possible for a listener to throw a RuntimeException; however, this is considered a client programming error. Well-behaved listeners should catch such exceptions and attempt to divert messages causing them to some form of application-specific ‘unprocessable message’ destination.

The result of a listener throwing a RuntimeException depends on the session’s acknowledgment mode.

AUTO_ACKNOWLEDGE or DUPS_OK_ACKNOWLEDGE - the message will be immediately redelivered. The number of times a JMS provider will redeliver the same message before giving up is provider-dependent. The JMSRedelivered message header field will be set for a message redelivered under these circumstances.
CLIENT_ACKNOWLEDGE - the next message for the listener is delivered. If a client wishes to have the previous unacknowledged message redelivered, it must manually recover the session.
Transacted Session - the next message for the listener is delivered. The client can either commit or roll back the session (in other words, a RuntimeException does not automatically rollback the session).

JMS providers should flag clients with message listeners that are throwing RuntimeExceptions as possibly malfunctioning.

2011年7月5日 星期二

[MySQL] 手動安裝

1. 註冊為系統Service:
    mysqld --install MySQL3 --defaults-file="%CURRENT_DIR%\my-huge.ini"
2. 從系統Service中移除:
    mysqld --remove MySQL3
3. 啟動Service:
    net start MySQL3
4. 關閉Service:
    net stop MySQL3

2011年5月15日 星期日

[C#] byte[] to hex format string

            StringBuilder sb = new StringBuilder(byteData.Length * 2);
            foreach (byte b in byteData)
            {
                sb.AppendFormat("{0:x2}", b);
            }

2011年5月2日 星期一

[C#] log4net 設定檔變數

  %m(message):輸出的日志消息,如ILog.Debug(…)輸出的一條消息
  %n(new line):換行
  %d(datetime):輸出當前语句運行的時刻
  %r(run time):輸出程序從運行到執行到當前語句時消耗的毫秒數
  %t(thread id):當前語句所在的線程ID
  %p(priority): 日志的當前優先級别,即DEBUG、INFO、WARN…等
  %c(class):當前日志對象的名稱
  %L:輸出語句所在的行號
  %F:輸出語句所在的文件名
  %-數字:表示該項的最小長度,如果不夠,則用空格填充

2011年3月2日 星期三

[C#] Thread 執行的method接受參數

1. 要給thread執行的method要能傳入參數Object
public static void StartClient(object messageObj) 
2. 在呼叫Thread.Start()時, 傳入參數
Thread thread = new Thread(AsynchronousClient.StartClient);
thread.Start("456, 121.54068, 25.047867, 0");

2011年2月20日 星期日

[C#] using


using 關鍵字有兩個用途:
1. 作為指令,用於為命名空間創建別名或導入其他命名空間中定義的類型。
2. 作為語句,用於定義一個範圍,在此範圍的末尾將釋放物件。
與try/catch/finally共同點: 都可以釋放資源 
與try/catch/finally不同點:
try/catch/finally可以用來捕獲異常並處理, using不行 
using可以創建別名,導入命名空間 ,try catch finally不行 
using會在資源超出範圍後主動釋放物件,try catch finally要程式師自己寫 釋放物件 的代碼

2011年2月13日 星期日

[C#] 同階運算子結合性

左結合: 由左而右, 先結合左邊運算子再結合右邊
右結合: 由右而左, 先結合右邊運算子再結合左邊

2011年1月10日 星期一