Saturday, January 31, 2009

Essential Java Resources(必備 Java 資源)

最近看到一篇文章,裡面提到重要的 Java 必備資源,所以就把這些資源 blog 下來,日後在做 research 時可以參考

Web sites and developer Web portals
Weblogs
Packages and/or libraries
Books

  • Effective Java (2nd Ed) by Joshua Bloch

  • Java Concurrency in Practice by Brian Goetz

  • Better, Faster, Lighter Java by Justin Gehtland and Bruce Tate

  • Effective Enterprise Java by Ted Neward (me)

  • Release It! by Michael Nygard

  • Either Inside the Java 2 Virtual Machine by Bill Venners or Component Development for the Java Platform by Stuart Halloway

  • Patterns of Enterprise Application Architecture by Martin Fowler and Enterprise Integration Patterns by Gregor Hohpe and Bobby Woolf

  • Java Power Tools by John Smart

  • The Pragmatic Programmer by Andy Hunt and Dave Thomas

  • The Productive Programmer by Neal Ford

  • The Pragmatic Starter Kit

  • Ant in Action (2nd Ed) by Erik Hatcher and Steve Loughran
Tools
  • The IDE
    Of course, the tools discussion begins with the IDE. In an effort to steer clear of commercial endorsements, both Eclipse and NetBeans are open source and free and thus offer an attractive "first steps" option.

  • Unit testing
    The perennial favorite here is the original that started the unit testing revolution, JUnit, but a few others have crept into popular usage, including TestNG, and not surprisingly JUnitPerf, among others.

  • Continuous Integration
    A Continuous Integration server constantly checks the code out of source control, builds it, runs the unit tests against it, and reports any build failures to the developers, usually via e-mail. Several open-source versions are available, but one that has gathered a lot of attention is Hudson, a Continuous Integration server with a lot of plug-ins and high extensibility. The original is CruiseControl and for that reason alone commands respect.

  • Static analysis
    FindBugs is an open-source static analysis tool that runs over Java code, performs deep n-way analysis to figure out all the possible code paths, and reports all sorts of errors and warnings it finds, based on a set of extensible rules. Developed by William Pugh (the same William Pugh who discovered a bug in the Java memory model), FindBugs' biggest claim to fame is its ability to analyze Java code for concurrency bugs, something that every programmer can appreciate.

  • Network packet tracing
    WireShark (which formerly used to be called Ethereal) gives programmers a view of what's traveling across the network, giving them an opportunity to verify that what's moving across the wire is what's supposed to be moving across the wire, and that what's not supposed to be there (such as sensitive information or passwords in clear text), isn't.

  • Virtualization
    A virtualization tool (or perhaps it is more accurate to call it a platform) like VMWare, Xen, VirtualBox, or VirtualPC offers programmers the ability to create an environment identical to the one the production machine will be running without losing the productivity of the environment of the host PC. It also provides a convenient way to have a home for trying "experimental" software without risking the machine that has to stay productive. Most of these have some kind of free option if they're not outright open-source projects.

以上都是在使用 Java 寫系統時最好先須具備的 Resource ,這樣才能隨時參考到資料並做最有效的運用

Thursday, January 29, 2009

如何清除 Microsoft SQL2000, SQL2005 的 log 檔

使用 MSSQL Server 的人一定會發現,雖然資料很少,但由於 MSSQL 機制的關係,會將 transaction log 保留作為後面 recovery 用,導致 transaction 的 log file 變成非常的大,尤其是很多人用的時候,transaction log 更是大的誇張

若平常有做備份,其實這些 transaction log 是可以不要的。要去除這些 log ,可以利用 MSSQL 內建的指令去除,可以參考以下步驟

1. 找出 log file 目錄
要縮小這些 log ,必須先找出 log 到底有多大。這個 log file 普通都會跟資料檔放在同一個目錄,在 MSSQL 2005 的系統裡面,預設放資料檔的目錄為
C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\










副檔名為 mdf 的為資料檔, 副檔名為 ldf 的為 transaction log 檔

2. 縮小 log file
打開 SQL2005 的 Server Management Studio 或 SQL2000 的 Analyzer,然後執行以下指令

=======================================
USE [master]
ALTER DATABASE [master]
SET RECOVERY SIMPLE;
GO
-- Shrink the truncated log file to 1 MB.
DBCC SHRINKFILE (mastlog, 1);
GO
-- Reset the database recovery model.
ALTER DATABASE [master]
SET RECOVERY FULL;
GO
=========================================

這邊需注意的是,[master] 與 [mastlog] 是邏輯名稱 (logical name),不是資料檔名稱







注意事項
1. 一但將這些 log file 清除,就無法做 transaction 的 recovery。
何謂 transaction 的 recovery ,就是可以利用之前的備份,將資料 recover 到特定日期。如今天是 2009/1/30,若要將資料庫還原到 1/27 的狀態,則需有 2009/1/25 的 full backup,便可以配合 1/26, 1/27 的 transaction backup ,將資料庫 recover 到 1/27 的狀態。

2. 做清除 transaction log 前最好先做 full backup ,以防萬一。

Thursday, January 8, 2009

如何用 appfuse 2.0.2 透過 gmail 發信

若需要發信但又沒有 SMTP servr 時,可以利用 gmail 的帳號發信
因為 gmail 用的 SMTP 走的是 SSL 機制,所以設定上比較麻煩一點

以下是用 gmail 發信的 mail.properties 範例

mail.default.from=Name <xyz@gmail.com>
mail.debug=true
mail.transport.protocol=smtp
mail.smtp.starttls.enable=true
mail.host=smtp.gmail.com
mail.username=xyz@gmail.com
mail.password=secret
mail.port=587

mail.mime.address.strict=false
mail.mime.charset=UTF-8

雖然有點 tricky, but it works