Web Development 的學習之旅

2008/08/10

MySQL command-line[basic]

[mysqld]


mysqld --console

=>將錯訊息在螢幕上輸出. 省略此參數, 則會在 datadir 指定的資料夾內產生 .err 的文字檔.



mysqld --verbose --help

=>顯示所有的參數



mysqld --install

=>設定 mysql server 成為 Windows Service(預設 Service Name 為 MySQL)



mysqld --install MySQL50 --defaults-file=c:\my-opts.cnf

=>設定 mysql server 成為 Windows Service(Service Name 為 MySQL50), 並讀取 c:\my-opts.cnf 內設置的參數



mysqld --install-manual

=>設定 mysql server 成為 Windows Service(手動), 系統啟動時不會自動啟動 MySQL

mysqld --remove

=>移除 mysql server 為 Windows Service 的設定

net start [ServiceName] 啟動 Windows Service
net stop [ServiceName] 停止 Windows Service

[mysqladmin]


mysqladmin -u root shutdown

=>關閉 mysql server, 若 root 有設定密碼, 請使用 -p 指定密碼


mysqladmin version status proc

=>顯示 mysql server 狀態

[mysqlshow]


mysqlshow -u root

=>mysql 顯示資料庫[mysql]的內容

mysqlshow test

=>顯示資料庫[test]的內容

2008/06/04

Load resource file test / 讀取資源檔案測試

測試 function:
object.getClass().getResourceAsStream(filename);

Project 的資料夾結構:



結論:
* 只寫檔名只能找到與該 class 相同的 namespace 下的檔案.
* 若以相對路徑的寫法, 則 jar 檔內的檔案一律找不到. 即使在相同目錄也找不到.
* 以絕對路徑的寫法, 可以完全找到.


Project: ResTest1


package tw.purple.test;

import java.io.*;

public class ResTest1 {
public static void main(String[] args) {
ResTest1 test = new ResTest1();
test.runTest();
}

public void runTest() {
String[] pathList = {
""
,"./"
,"/"
,"../"
,"../../"
,"../../../"
,"/tw/"
,"/tw/purple/"
,"/tw/purple/test/"
,"/tw/yahoo/"
};
String[] nameList = {
"log4j_1.properties"
,"log4j_2.properties"
,"log4j_3.properties"
,"log4j_4.properties"
,"log4j_5.properties"
,"log4j_6.properties"
,"log4j_7.properties"
,"log4j_8.properties"
};

for (int i=0; i<pathList.length; i++) {
for (int j=0; j<nameList.length; j++) {
String filename = pathList[i] + nameList[j];
InputStream stream = this.getClass().getResourceAsStream(filename);
if (stream==null) System.out.print(" not found: ");
else System.out.print(" found: ");
System.out.println(filename);
}
}
}

}



Project: ResTest2

package tw.purple.test;

public class ResTest2 {
public static void main(String[] args) {
// TODO Auto-generated method stub
ResTest1 test1 = new ResTest1();
test1.runTest();
}
}

2008/05/23

Eclipse 一些開發環境設定

[關掉 Spelling]
在編輯文字檔案時, Spelling 會進行檢查, 不合格的英文字下方就會有 underline 出現, 看起來挺礙事的, 自己是完全不會用上併字檢查的功能, 就關了它吧.
Windows->Perferences:
General->Editors->Text Editors->Spelling

[調整常用 Editor 字體大小]
Windows->Perferences:
General->Appearance->Colors and Fonts

Basic->Text Font: 調整一般文字檔的字體設定
Java->Java Editor Text Font: 調整 .java 檔案的字體設定
Java->Properties File Editor Text Font: 調整 .properties 檔案的字體設定
Debug->Console font: 調整 Console View 裡的文字大小

[Validation]
Eclipse 在很多時候會執行 Validation 的動作, 若機器等級不夠, 可是會讓人等翻天.
Windows->Perferences:
General->Validation 內有各種的 Validation, 可視需要把不需要的關掉, 或乾脆全關掉.
當然, 也可以至某 Project 內的 Properties 單獨設定 Validation 的開關.