SmileFace
          與java一起走過的日子
          posts - 41,  comments - 8,  trackbacks - 0
          I am trying to run wireshark in linux using sudo, but was told: i am not in the sudoer files. So I must edit this file to add my own user into this file. Steps as follows:

          1. su to root:  su-
           2. open sudoers:  visudo /etc/sudoers
          3. add my user name:  testuser ALL=(ALL) NOPASSWD:ALL
              This lines means that the user "testuser" can execute from ALL terminals, acting as ALL (any) users, and run ALL (any) command.

          The detail is in paper:  http://www.go2linux.org/sudoers-how-to






          posted @ 2009-08-28 04:28 SmileFace 閱讀(239) | 評論 (0)編輯 收藏
          In order to supports internationalization (I18N), on Tomcat some additional configuration is necessary. You must
          ensure that Tomcat's URI encoding is set to UTF-8. You can do this by editing the Tomcat configuration file
          conf/server.xml and adding URIEncoding=”UTF-8” to each connector element, as shown below:

          <Connector port="8080"
          maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
          enableLookups="false" redirectPort="8443" debug="0"
          acceptCount="100" connectionTimeout="20000"
          disableUploadTimeout="true"
          URIEncoding="UTF-8" />

          And make sure you do this for every connectort.
          posted @ 2009-08-20 13:45 SmileFace 閱讀(293) | 評論 (0)編輯 收藏
          I planned to install Roller in my centOS which need tomcat6. But centos5.3 has tomcat5 in it's yum. So I have to install tomcat6 using other way. I searched and found this good install guide in:
               http://cloudservers.mosso.com/index.php/CentOS_-_Tomcat_6 ( or http://de0ris.blogspot.com/2008/08/installing-tomcat-6x-on-centos-5.html )
          which give detail instructions. I choose some important part and paste here in case for late use.

          1.  install appache ant:  (note: download and put the tar file in /usr/share first )
             tar -xzf apache-ant-1.7.1-bin.tar.gz



          2. install tomcat:(note: download and put the tar file in /usr/share first )



          tar -xzf apache-tomcat-6.0.18.tar.gz

          3.  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.
          ln -s /usr/share/apache-ant-1.7.1/bin/ant /usr/bin

          4. 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_14

          Test:
          cd /usr/share/apache-tomcat-6.0.18/bin

          ./startup.sh

          5.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:
          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.

              



          posted @ 2009-08-20 13:12 SmileFace 閱讀(706) | 評論 (0)編輯 收藏
          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...
          posted @ 2009-08-20 01:43 SmileFace 閱讀(133) | 評論 (0)編輯 收藏
          一看書名就知道又是一本通俗易懂的書。果不其然,而且比想象的更有意思(我想是簡單的緣故吧)。

          書里只是很簡單的提及了一些網絡的基本概念和運作原理,似乎各個方面都有覆蓋,但是因為描述的很淺顯,所以建議給:
          1 想大致了解DNS,ARP,router等網絡知識的人;
          2 有閑但是對于網絡感興趣的人;

          其實不錯,無聊的時候翻翻,解悶!

          posted @ 2009-08-19 14:08 SmileFace 閱讀(163) | 評論 (0)編輯 收藏
          centos

          0. /sbin/ifconfig

          1. mysql :

             *remove: yum -y remove mysql mysql-server
             *insatll: yum -y install mysql mysql-server
           
             *check: chkconfig --list | grep mysql
            
             *Set to Start on Boot:
                 chkconfig mysqld on

             *start service:
                 service --status-all
                 service mysqld start
                 check:  mysqladmin version    
           
             *setup root password:
              mysqladmin -u root password ***(this is new password)

              *run:
              mysql -u root -p

              *exit:
              \q

              *commands:ep t
              show databases;

              drop database ***;

          2. Tomcat:

              *install:
                  yum -y install tomcat5 tomcat5-webapps tomcat5-admin-webapps

              *You can find these packages using
                  yum list available tomcat5*
                  or
                  yum search tomcat5

              *Start:
                  service tomcat5 start
                 
              view:   http://localhost:8080/.

              *location:r
                   /usr/share/tomcat5 .
                  *setting:
                      "$CATALINA_HOME".

          3. JDK:

               * Originally, centOS only install jre. so we need install jdk by ourselves.
               *To install from the command line:
          $yum install java-1.6.0-openjdk-devel

          You can also install all the OpenJDK 6 packages, including the API documentation, by using the wildcard java-1.6.0-openjdk*.

                *location:         /usr/lib/jvm...
                *check:  java -version
                  






          posted @ 2009-08-13 07:31 SmileFace 閱讀(178) | 評論 (0)編輯 收藏

          最近賦閑,借來這本書看。本來希望很大,期冀可以學到些東西。結果,事與愿違。

          總的感覺:這書一般,不推薦給大家,尤其是對于有項目開發經驗的人。在這個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"

          posted @ 2009-07-25 07:38 SmileFace 閱讀(215) | 評論 (0)編輯 收藏

          在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,否則會出錯的。

          posted @ 2007-05-25 22:42 SmileFace 閱讀(366) | 評論 (0)編輯 收藏
          前天開始在fedora 4 下安裝java的這一套開發環境,滿以為很簡單,后來發現里面還是有點小trick的,而且在網上并沒有找到類似的完整講解的文章,所以寫出來共享。希望對大家有所幫助。

          安裝的版本: jdk1.5.0_11+Tomcat5.0.28+Eclipse3.2.2+Sysdeo3.2.1

          說明:

          1、fc4第一次有了自帶的全套java開發環境,也就是說,如果你完全安裝,那么jdk,tomcat和eclipse都是直接裝好的。據說這是因為版權的原因不再使用sun的jdk,所以才會這樣。但是卻害苦了我。我遇到了一個接一個的問題。后來再網上搜了一遍,看了寫文章,結論是:fc4自帶的這套環境不能用,最好自己裝。于是就有了我的子裝過程和這片文章。注意:我遇到的問題主要來自sysdeo,如果你不使用這個插件,也許fc4的環境可以將就用。

          2、安裝jdk和tomcat需要是root用戶,安裝eclipse和sysdeo最好使用開發者自己的用戶。

          安裝過程:

          1 安裝jdk:   參考文檔:http://www.sitepoint.com/article/jakarta-tapestry

             su 到root用戶:

              1.1 下載jdk-1_5_0_11-linux-i586-rpm.bin;
             1.2 要執行文件,須先change文件的perrmissions: chmod +x jdk-1_5_0_11-linux-i586-rpm.bin
            
              1.3 執行文件:./jdk-1_5_0_11-linux-i586-rpm.bin
              1.4 在etc/profile.d新建java.sh,如下:
            
               if ! echo ${PATH} | grep -q /usr/java/jdk1.5.0_11/bin ; then
                export PATH=/usr/java/jdk1.5.0_11/bin:${PATH}
              fi
              if ! echo ${PATH} | grep -q /usr/java/jdk1.5.0_11/jre/bin ; then
                export PATH=/usr/java/jdk1.5.0_11/jre/bin:${PATH}
              fi
              export JAVA_HOME=/usr/java/jdk1.5.0_11
              export CLASSPATH=.:/usr/java/jdk1.5.0_11/lib/tools.jar:/usr/java/jdk1.5.0_11/jre/lib/rt.jar
              
          2.安裝tomcat:我完全參考文檔:http://linux-sxs.org/internet_serving/c140.html#INSTALL。這個文章很好,強烈推薦。

          3、安裝eclipse: 沒有trick。
                3.1 su到普通的開發用戶;
                 3.2 unzip即可。
                 3.3 ./eclipse即可啟動。
          4、安裝sysdeo:
                 因為在windows下這個插件用的很順手,所以在linux下我也希望能接著用它。
                 以普通用戶身份下載,unzip,然后mv到eclips的plugins下,即可。
           
                  重新啟動eclipse,小貓的圖標在。再在window/perferences下配置一下。運行,就出問題了。原因是:tomcat的啟動只有root有權限,現在是普通用戶的模式下,權限受限。solution:  讓普通用戶接管tomcat的權限。

                 做法是:chown -R test:test  /opt/tomcat
             這里的 test:test是我自己的用戶名和用戶組,opt/tomcat是catalina_home。
             注意:如果這里的/opt/tomcat是sambolic link的話,真正的目錄也需要chown。即,如果是opt/jarcartar_tomcat_1.5.0指向opt/tomcat,那么opt/jarcartar_tomcat_1.5.0也要chown。



          這下應該就ok了。
          posted @ 2007-05-25 11:32 SmileFace 閱讀(427) | 評論 (0)編輯 收藏

          出處:hihi的網站

          http://home.fego.cn/loading.html?aspxerrorpath=/members/hihi/m_Article/Detail.aspx


          Java數據庫接口JDBC入門基礎講座-第六講?PreparedStatement接口

          ?

          ?
            概述

            該 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:

          pstmt.setLong(1, 123456789);
          pstmt.setLong(2, 100000000);

            一旦設置了給定語句的參數值,就可用它多次執行該語句,直到調用clearParameters 方法清除它為止。在連接的缺省模式下(啟用自動提交),當語句完成時將自動提交或還原該語句。

            如果基本數據庫和驅動程序在語句提交之后仍保持這些語句的打開狀態,則同一個 PreparedStatement 可執行多次。如果這一點不成立,那么試圖通過使用PreparedStatement 對象代替 Statement 對象來提高性能是沒有意義的。

            利用 pstmt(前面創建的 PreparedStatement 對象),以下代碼例示了如何設置兩個參數占位符的值并執行 pstmt 10 次。如上所述,為做到這一點,數據庫不能關閉 pstmt。在該示例中,第一個參數被設置為 "Hi"并保持為常數。在 for 循環中,每次都將第二個參數設置為不同的值:從 0 開始,到 9 結束。

          pstmt.setString(1, "Hi");
          for (int i = 0; i < 10; i++) {
           pstmt.setInt(2, i);
           int rowCount = pstmt.executeUpdate();
          }

            3、IN 參數中數據類型的一致性

            setXXX 方法中的 XXX 是 Java 類型。它是一種隱含的 JDBC 類型(一般 SQL 類型),因為驅動程序將把 Java 類型映射為相應的 JDBC 類型(遵循該 JDBCGuide中§8.6.2 “映射 Java 和 JDBC 類型”表中所指定的映射),并將該 JDBC 類型發送給數據庫。例如,以下代碼段將 PreparedStatement 對象 pstmt 的第二個參數設置為 44,Java 類型為 short:

          pstmt.setShort(2, 44);

            驅動程序將 44 作為 JDBC SMALLINT 發送給數據庫,它是 Java short 類型的標準映射。

            程序員的責任是確保將每個 IN 參數的 Java 類型映射為與數據庫所需的 JDBC 數據類型兼容的 JDBC 類型。不妨考慮數據庫需要 JDBC SMALLINT 的情況。如果使用方法 setByte ,則驅動程序將 JDBC TINYINT 發送給數據庫。這是可行的,因為許多數據庫可從一種相關的類型轉換為另一種類型,并且通常 TINYINT 可用于SMALLINT 適用的任何地方
          posted @ 2006-12-23 01:47 SmileFace 閱讀(294) | 評論 (0)編輯 收藏
          僅列出標題  下一頁

          <2025年6月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          常用鏈接

          留言簿(2)

          隨筆分類

          隨筆檔案

          文章檔案

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 车致| 龙陵县| 彝良县| 盐津县| 贡山| 墨竹工卡县| 黑河市| 平安县| 娱乐| 祁阳县| 商南县| 黎平县| 平罗县| 吴江市| 电白县| 洛川县| 哈密市| 乌海市| 顺昌县| 普陀区| 吴桥县| 河曲县| 柳河县| 房产| 织金县| 永丰县| 玉屏| 台湾省| 博客| 南丹县| 晋江市| 镇原县| 揭西县| 平泉县| 丹凤县| 瑞金市| 永昌县| 和林格尔县| 施甸县| 山阴县| 亳州市|