SmileFace
與java一起走過的日子 |
tar -xzf apache-ant-1.7.1-bin.tar.gz3. create a symbolic link for Ant so other applications can easily find it. Be sure to select the correct version when you create your link.
2. install tomcat:(note: download and put the tar file in /usr/share first )
tar -xzf apache-tomcat-6.0.18.tar.gz
ln -s /usr/share/apache-ant-1.7.1/bin/ant /usr/bin4. set JAVA_HOME:
cd /usr/share/apache-tomcat-6.0.18/bin
vi catalina.sh
enter insert mode. Enter the following:
JAVA_HOME=/usr/java/jdk1.6.0_14Test:
cd /usr/share/apache-tomcat-6.0.18/bin5.Automating atartup: Right now Tomcat will not start up on it's own so we need to create a startup script for this. To do this:
./startup.sh
cd /etc/init.d
vi tomcat
Press i to enter insert mode and paste in the following:
#!/bin/bash
# chkconfig: 234 20 80
# description: Tomcat Server basic start/shutdown script
# processname: tomcat
JAVA_HOME=/usr/java/jdk1.6.0_14
export JAVA_HOME
TOMCAT_HOME=/usr/share/apache-tomcat-6.0.18/bin
START_TOMCAT=/usr/share/apache-tomcat-6.0.18/bin/startup.sh
STOP_TOMCAT=/usr/share/apache-tomcat-6.0.18/bin/shutdown.sh
start() {
echo -n "Starting tomcat: "
cd $TOMCAT_HOME
${START_TOMCAT}
echo "done."
}
stop() {
echo -n "Shutting down tomcat: "
cd $TOMCAT_HOME
${STOP_TOMCAT}
echo "done."
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 10
start
;;
*)
echo "Usage: $0 {start|stop|restart}"
esac
exit 0
Be sure to change the following items in the above file:
* JAVA_HOME path
* TOMCAT_HOME path
* START_TOMCAT path
* STOP_TOMCAT path
Once you have those changes made, save the file and quit.
Now we need to change the permissions on the file.
chmod 755 tomcat
We need to set the script to start with other system services and set the runlevels.
chkconfig --add tomcat
chkconfig --level 234 tomcat on
You can verify that it is listed by typing chkconfig --list tomcat.
tomcat 0:off 1:off 2:on 3:on 4:on 5:off 6:off
Test your shutdown and startup script.
sudo /sbin/service tomcat stop
sudo /sbin/service tomcat start
Tomcat 6 should now be installed under CentOS.
$yum install java-1.6.0-openjdk-devel*location: /usr/lib/jvm...
You can also install all the OpenJDK 6 packages, including the API documentation, by using the wildcard java-1.6.0-openjdk*.
最近賦閑,借來這本書看。本來希望很大,期冀可以學到些東西。結果,事與愿違。
總的感覺:這書一般,不推薦給大家,尤其是對于有項目開發經驗的人。在這個200多頁的書里,作者羅列了項目開發方法,開發工具,開發環境等等。因為涉及內容太多,所以每個知識點都是一帶而過,不過講講優點,缺點。所以感覺四不像。
如果你是個沒有項目開發經驗的人,想全面地了解目前web開發的基本過程,項目可能涉及的技術方面,可以看看。
下面是自己的一些讀書筆記,你們可以掠過:
1.Agile model driven development(AMDD): focus on model
2.Extreme programmning: focus on full development life cycle.
3.Jconsole: c:\program files\java\jdk1.6.0_14\bin\jconsole, which could dectect the memory issue, class loading,
garbage collection...
Java profilers: analyze the heap for memory usage and leaks, CPU utilization, trace object and methods,determine performance bottlenecks...
4.Ant new feature:
<exec command="date"/>
Get: fetch a file using HTTP GET.
<get src="http://visualpatterns.com/comics/funny.gif" dest="funny.gif" verbose="true"/>
Sleep: pause processing.
<sleep seconds="2"/>
FTP: use FTP directly. The example transfe the files to ftp server automatically using windows scheduled tasks
<ftp server="mirror.kernel.org"
action="get"
remotedir=...> </ftp>
MAIL: ...
5. JMX: my thought: I can use it to track how many user signed into, and so on.
6.unchecked exception: do not need to be caught by the code. Checked exception require the code to either cathch the exception or throw it up the call chain using throws. "If a client can reasonble to recover from an exception, make it a checked exception. If client cannot do anything to recover from the excepetion, make it unchecked"
在windows和fedora 4下都安裝了postgresql,有2點體會:
1。windows下安裝postgresql,最好在安裝前先建立“limit”權限的用戶postgres;當然,看見報錯的時候再加也來的及呀;
2。在fedora 4 下安裝,要么用rpm安裝低版本的postgresql,要么用source逐步安裝最新版本的。用rpm比較簡單,不說了;
如果安裝source,不要到網上到處找幫助,直接在postgresql的網站上找到權威文檔就行:http://www.postgresql.org/docs/8.2/static/installation.html。 我覺得很實用。按照它的步驟做下來,ok。 尤其是,注意看里面14.2中關于requirments的說明,在configure時記得使用--without-readline option,否則會出錯的。
|
||||
概述 該 PreparedStatement 接口繼承 Statement,并與之在兩方面有所不同: PreparedStatement 實例包含已編譯的 SQL 語句。這就是使語句“準備好”。包含于 PreparedStatement 對象中的 SQL 語句可具有一個或多個 IN 參數。IN參數的值在 SQL 語句創建時未被指定。相反的,該語句為每個 IN 參數保留一個問號(“?”)作為占位符。每個問號的值必須在該語句執行之前,通過適當的setXXX 方法來提供。 由于 PreparedStatement 對象已預編譯過,所以其執行速度要快于 Statement 對象。因此,多次執行的 SQL 語句經常創建為 PreparedStatement 對象,以提高效率。 作為 Statement 的子類,PreparedStatement 繼承了 Statement 的所有功能。另外它還添加了一整套方法,用于設置發送給數據庫以取代 IN 參數占位符的值。同時,三種方法 execute、 executeQuery 和 executeUpdate 已被更改以使之不再需要參數。這些方法的 Statement 形式(接受 SQL 語句參數的形式)不應該用于 PreparedStatement 對象。 1、創建 PreparedStatement 對象 以下的代碼段(其中 con 是 Connection 對象)創建包含帶兩個 IN 參數占位符的 SQL 語句的 PreparedStatement 對象: PreparedStatement pstmt = con.prepareStatement("UPDATE table4 SET m = ? WHERE x = ?"); pstmt 對象包含語句 "UPDATE table4 SET m = ? WHERE x = ?",它已發送給DBMS,并為執行作好了準備。 2、傳遞 IN 參數 在執行 PreparedStatement 對象之前,必須設置每個 ? 參數的值。這可通過調用 setXXX 方法來完成,其中 XXX 是與該參數相應的類型。例如,如果參數具有Java 類型 long,則使用的方法就是 setLong。setXXX 方法的第一個參數是要設置的參數的序數位置,第二個參數是設置給該參數的值。例如,以下代碼將第一個參數設為 123456789,第二個參數設為 100000000:
一旦設置了給定語句的參數值,就可用它多次執行該語句,直到調用clearParameters 方法清除它為止。在連接的缺省模式下(啟用自動提交),當語句完成時將自動提交或還原該語句。 如果基本數據庫和驅動程序在語句提交之后仍保持這些語句的打開狀態,則同一個 PreparedStatement 可執行多次。如果這一點不成立,那么試圖通過使用PreparedStatement 對象代替 Statement 對象來提高性能是沒有意義的。 利用 pstmt(前面創建的 PreparedStatement 對象),以下代碼例示了如何設置兩個參數占位符的值并執行 pstmt 10 次。如上所述,為做到這一點,數據庫不能關閉 pstmt。在該示例中,第一個參數被設置為 "Hi"并保持為常數。在 for 循環中,每次都將第二個參數設置為不同的值:從 0 開始,到 9 結束。
3、IN 參數中數據類型的一致性 setXXX 方法中的 XXX 是 Java 類型。它是一種隱含的 JDBC 類型(一般 SQL 類型),因為驅動程序將把 Java 類型映射為相應的 JDBC 類型(遵循該 JDBCGuide中§8.6.2 “映射 Java 和 JDBC 類型”表中所指定的映射),并將該 JDBC 類型發送給數據庫。例如,以下代碼段將 PreparedStatement 對象 pstmt 的第二個參數設置為 44,Java 類型為 short:
驅動程序將 44 作為 JDBC SMALLINT 發送給數據庫,它是 Java short 類型的標準映射。 程序員的責任是確保將每個 IN 參數的 Java 類型映射為與數據庫所需的 JDBC 數據類型兼容的 JDBC 類型。不妨考慮數據庫需要 JDBC SMALLINT 的情況。如果使用方法 setByte ,則驅動程序將 JDBC TINYINT 發送給數據庫。這是可行的,因為許多數據庫可從一種相關的類型轉換為另一種類型,并且通常 TINYINT 可用于SMALLINT 適用的任何地方 |
| |||||||||
日 | 一 | 二 | 三 | 四 | 五 | 六 | |||
---|---|---|---|---|---|---|---|---|---|
25 | 26 | 27 | 28 | 29 | 30 | 31 | |||
1 | 2 | 3 | 4 | 5 | 6 | 7 | |||
8 | 9 | 10 | 11 | 12 | 13 | 14 | |||
15 | 16 | 17 | 18 | 19 | 20 | 21 | |||
22 | 23 | 24 | 25 | 26 | 27 | 28 | |||
29 | 30 | 1 | 2 | 3 | 4 | 5 |