2009/06/03

Dvorak, New World Symphony No.9

分為四個樂章,各章說明可以參考此網頁
開啟網頁

Dublin Philharmonic, Dvorak, New World Symphony - 1st Mvt
前往Youtube

Dvorak, New World Symphony - 2nd Mvt Part 1
前往Youtube
Dvorak, New World Symphony - 2nd Mvt Part 2
前往Youtube

Dvorak - New World Symphony - 3rd Mvt
前往Youtube

Dublin Philharmonic, Dvorak, New World Symphony - 4th Mvt
前往Youtube

2009/06/02

[JDBC]顯示Open Cursor使用量

Oracle若statement和result沒有適時的關閉,則所佔用的open cursor的量會愈來愈多。oracle對於會分配設定值量的open cursor給每個使用者,一但使用者把open cursor用盡,則會出現ORA-01000: maximum open cursors exceeded的錯誤訊息。要檢視程式片段的statment或result沒有釋放掉,可以使用下列程式碼來確定忘記釋放open cursor資源的地方:

public static void getOpenCursors (Connection conn, String place) throws SQLException {
        System.out.print(place + "===> ");
        System.out.println("Open Cusrors are : ");
        Statement stmt = conn.createStatement();
        ResultSet rs = stmt.executeQuery ("select count(*) from V$OPEN_CURSOR");
        
        while (rs.next()){
            System.out.println(rs.getString(1));
        }
        rs.close();
        rs = null;
        stmt.close();
        stmt = null;
    }

2009/05/18

讀取Properties檔

java.util.Properties的功能很好用,不用特別花心思在文字檔的處理就可以把文字檔的設定給讀進來,
做為讀取或寫入系統的設定都非常方便,設定檔的格式只要滿足<propery name>=<property value>或
<propery name>:<property value>,Properties就可以幫我們讀出所需要的值。



//Read properties file
public void readProperties(){
InputStream propStream = null;
File file = new File(".");

try{
String path = file.getCanonicalPath();
String fileSeparator = System.getProperty("file.separator");
String name = path + fileSeparator + "fex.properties";
propStream = new FileInputStream(name);
fexProps.load(propStream);
propStream.close();
}catch(IOException ioe){
System.err.println("Can't open the file fex.properties");
}
}

//Show properties content in screen
Properties fexProps = new Properties(); //properties load from somewhere
fexProps.list(System.out);


2009/04/24

取得目前日期與時間

DateFormat有三種取得實體的方法,分別為getDateInstance、getTimeInstance和getDateTimeInstance,輸出結果會因為取得實體方式而不同。


DateFormat dFormat = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);

Calendar cal = Calendar.getInstance();
Date curDate = cal.getTime();
String dateStr = dFormat.format(curDate);


2009/04/22

[SQL Server]Rename a Column Name or Table Name

Introduction

Renaming any column
SP_RENAME ‘TableName.[OldColumnName]‘ , ‘[NewColumnName]‘, ‘COLUMN’


Renaming any object (table, sp etc)
SP_RENAME ‘[OldTableName]‘ , ‘[NewTableName]‘


Application
1.Renaming database table column to new name.

   sp_RENAME ‘Table_First.Name’, ‘NameChange’ , ‘COLUMN’

2.Renaming database table to new name.

   SP_RENAME ‘Table_First’, ‘Table_Last’





2009/03/27

印出目前的靜態系統參數

印出目前的靜態系統參數



import java.util.Properties;
import java.util.Enumeration;

public class testSystemProp{

    public static void main(String args[]){
    
    Properties props = System.getProperties();
   
   
    Enumeration enum = props.propertyNames();
    for (; enum.hasMoreElements(); ) {
      
        String propName = (String)enum.nextElement();
        String propValue = (String)props.get(propName);
        System.out.println(propName + ":\t" + propValue);
    }
   
  }



}


2009/03/20

Java GUI問題

ToolTip換行

setToolTip要達到換行功能,傳入的字串內容可以使用以下格式達到換行功能

<html>line1<br>line2</html>

但要注意一點是有些LookAndFeel不支援html