Total Pageviews

2011/03/25

Implementing a simple toString() with Apache Commons

我們在Web開發的時候,JSP頁面參數是透過form bean傳遞,有時候需要印出form bean裡頭的valuedebug,大家可以在form bean中,override toString(),如以下寫法

public String toString() {

return ToStringBuilder.reflectionToString(this);

}

實作如下

public static void main(String[] args) {

// set value to value object

Nigw002PK vo = new Nigw002PK();

vo.setCarryDate("1");

vo.setCarrySeqNo("2");

vo.setCaseStus("3");

vo.setMtgTp("4");

// print value object by toString()

System.out.println(vo.toString());

}

印出結果入下:gov.fdc.nig.domain.Nigw002PK@63396339[mtgTp=4,caseStus=3,taxCd=,carryDate=1,carrySeqNo=2,vioNo=>]

Reference: http://blogs.bytecode.com.au/glen/2007/10/05/implementing-a-simple-tostring---with-apache-commons.html

2011/03/16

WTRN0037W: The transaction service encountered an error on an xa_recover operation


As I start up WAS(WebSphere Application Server) V7, it show error messages as bellows:
[2011/3/16 17:30:48:784 CST] 0000000b XARminst E WTRN0037W: The transaction service encountered an error on an xa_recover operation. The resource was com.ibm.ws.rsadapter.spi.WSRdbXaResourceImpl@702d702d. The error code was XAER_RMERR. The exception stack trace follows: javax.transaction.xa.XAException
at oracle.jdbc.xa.OracleXAResource.recover(OracleXAResource.java:709)
at com.ibm.ws.rsadapter.spi.WSRdbXaResourceImpl.recover(WSRdbXaResourceImpl.java:1044)
at com.ibm.ws.Transaction.JTA.XARminst.recover(XARminst.java:140)
at com.ibm.ws.Transaction.JTA.XARecoveryData.recover(XARecoveryData.java:571)
at com.ibm.tx.jta.PartnerLogTable.recover(PartnerLogTable.java:389)
at com.ibm.tx.jta.RecoveryManager.resync(RecoveryManager.java:1523)
at com.ibm.ws.tx.jta.RecoveryManager.performResync(RecoveryManager.java:126)
at com.ibm.tx.jta.RecoveryManager.run(RecoveryManager.java:2200)
at java.lang.Thread.run(Thread.java:735)

Solution
1. Shut down WAS(WebSphere Application Server) V7

2. Change directory to transaction logs foldler: [WebSphere Application Server_install_root]\profiles\[PROFILE_NAME]\tranlog\[CELL_NAME]\[NODE_NAME]\[SERVER_NAME]\transaction


3. Delete all folder and files

4. Start up server again

5. Do not have error message any more

6. And log into admin console successfully.

2011/03/03

如何在Word中建立書籤及超連結

建立書籤與超連結

1. 將要做書籤的文字進行反白

2. 插入-->書籤

3. 輸入書籤名稱-->新增


4. 把要做超連結的文字進行反白

5. 按下書籤按鈕

6. 選擇剛剛建立的書籤 --> 確定



測試

1. 點選超連結


2. 正確連結到該頁面,大成功!

2011/01/31

RSA Error: 需要管理員權限,請嘗試『以系統管理員身分執行』。

Scenario
I got this error message "需要管理員權限,請嘗試『以系統管理員身分執行』。" when I launch IBM Installation Manager.


Solution

2011/01/28

Rational Software Architect (RSA) 7.5 for WebSphere Installation

Install IBM Installation Manager

Welcome Page, Click Next

Choose I accept agreement...., and Click Next

Click Next

Click Install

Downloading....

Finish


Install Rational Software Architect (RSA 7.5) and WebSphere Application Server 7.0

Enter welcome page, and click Next

Downloading jar files

Select I accept agreement, and Click Next

Click Next

Click Next

Click Next

Click Next

Select the plug-ins which you need to install

Click Next

Click Next

Click Install

downloading jar files

As it download all selected jar files, then the installation process was well done.

Before you startup RSA, remember to edit eclipse.ini to allocate more memory to RSA.


RSA Error: alt + / does not work

Scenario
In Rational Software Architect (RSA) 7.5, I create a web project. And I would like to use alt + / hot key.

Root Cause
I update eclipse.ini to change RSA's language from Traditional Chinese to English. And the hot key had been changed to ctrl + after I changed RSA's language. But the hot key has conflict with my 輸入法.

Solution
Remove -Duser.language=en

RSA Error:WebSphere Application Server 6.1版目前正在執行,請關閉它以繼續進行。


Scenario
As I installed RSA 7.5 for WebSphere, and selected RSA & WebSphere

It show this error message: WebSphere Application Server 6.1版目前正在執行,請關閉它以繼續進行。


Solution
As you install RSA, you have to CLOSE Microsoft Word.


2011/01/27

Eclipse Error – Failed to load the JNI shared library "C:\Program Files (x86)\Java\jre6\bin\client\jvm.dll"

Scenario
As I start up eclipse after I installed Windows 7 64-bit, it complained this error:
Failed to load the JNI shared library "C:\Program Files (x86)\Java\jre6\bin\client\jvm.dll"

Root Cause
I install JDK 32-bit version on Windows 7 64-bit.

Solution
Uninstall JDK 32-bit version, and install JDK 64-bit version.

2011/01/18

How to Query Columns' Comments from Database

Problem
I would like retrieve comments from each column. The database is Oracle.

Solution
select table_name, column_name, comments 
from user_col_comments 
where table_name like 'NIGT%';

2011/01/07

Utilize JDeveloper and SchemaSpy to maintain database schema & document

Scenario
1. I need to change database schema frequently, and add comments for each column (it does not have any comments originally).
2. I have to deliver the up-to-date schema document to customer.

Solution
1. Use JDeveloper to maintain database schema and add comments for each column.
2. Use SchemaSpy to generate the up-to-date database schema [Concerning SchemaSpy, please refer to http://albert-myptc.blogspot.com/2010/12/schemaspy-quick-start.html]


Prerequisite

1. Download JDeveloper from http://www.oracle.com/technetwork/developer-tools/jdev/downloads/soft11-098086.html

2. Launch JDeveloper after you installed it

3. JDeveloper workspace

4. Setup database connection

5. Check the connection in Database Navigator

5.Create a new Project

6. Choose "Generic Project", and click OK

7. Click Finish

8. Project had been created

9. Create Database Diagram from project




Before change
I would like to add three columns to NIGT036, and add comments for each column.

Use JDeveloper to change database schema
1. Select specific table --> Column --> Add

2. Assign "Column Name", "Data Type", "Precision", and then click Apply

3. Check the result

4. Add comments for each column

5. Assign Comment and then click Apply

Generate the latest schema document via SchemaSpy
1. execute the command:
java -jar "C:\schemaSpy_5.0.0.jar" -dp "C:\ojdbc6.jar" -t orathin -db dev02 -s ap_tax -host 192.168.30.102 -port 1521 -u ap_tax -p taxtest -schemas AP_TAX -connprops "C:\schemaSpyGUI\properties\orathin.properties" -i "NIG.*" -charset UTF-8 -o "C:\schemaSpyGUI\output" -norows -hq

You can get more information about this command from http://schemaspy.sourceforge.net/

2. check the result