相忘于江湖

泉涸,鱼相与处于陆,相呴以湿,相濡以沫,不如相忘于江湖。《庄子.大宗师篇》

Install MySQL + Tomcat on Solaris

Tuesday Jul 10, 2007

The default MySQL (4.0.24) shipped in Solaris Nevada (build 59) doesn't support UTF-8 encoding. Following are the steps to install a new MySQL on Solaris environment.

  1. download latest pkgs from www.sunfreeware.com
    mysql-5.0.41-sol10-sparc-local.gz
    openssl-0.9.8e-sol10-sparc-local.gz
    libgcc-3.4.6-sol10-sparc-local.gz

  2. with root privilege, pkgadd all pkgs

  3. setup environment for mysql
    # groupadd mysql
    # useradd -g mysql mysql
    # cd /usr/local/mysql
    # chown -R mysql .
    # chgrp -R mysql .
    # bin/mysql_install_db --user=mysql
    # bin/mysqld_safe --user=mysql &

  4. create root passwd (optional), add new account 'mysql'
    # bin/mysql mysql
    > UPDATE user SET password=password("newpasswd") WHERE user="root";
    > GRANT ALL PRIVILEGES ON *.* TO 'mysql'@'localhost'
        > IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
    > GRANT ALL PRIVILEGES ON *.* TO 'mysql'@'%'
        > IDENTIFIED BY 'some_pass' WITH GRANT OPTION;
    > exit
    # pkill -9 mysql
    # bin/mysqld_safe --user=mysql &

  5. Import database from backup
    create backup in source mysql env
    # mysqldump -u mysql -p --opt lunch > lunch.sql

    import backup into new mysql env
    # mysql -u mysql -p
    > create database lunch;
    > exit

    # mysql -u mysql -p < lunch.sql


Here are the steps to install and deploy Tomcat.
 

  1. download latest version of tomcat binaries from tomcat.apache.org
    http://archive.apache.org/dist/tomcat/tomcat-5/v5.5.23/bin/apache-tomcat-5.5.23.tar.gz

  2. install
    # cd /usr/local
    # gunzip < [path]/apache-tomcat-5.5.23.tar.gz | tar xvf -
    # ln -s apache-tomcat-5.5.23 tomcat

  3. install jdbc mysql connector
    # cp [path]/mysql-connector-java-5.0.3-bin.jar /usr/local/tomcat/common/lib

  4. start
    # export JAVA_HOME=/usr/java
    # /usr/local/tomcat/bin/startup.sh

 


 

Add MySQL and Tomcat in the startup scripts of apache2:

 

  1. append following lines in /usr/apache2/bin/envvars

    MYSQL=/usr/local/mysql/bin/mysqld_safe
    [ -x $MYSQL ] && $MYSQL --user=mysql &

    TOMCAT=/usr/local/tomcat/bin/startup.sh
    [ -x $TOMCAT ] && $TOMCAT

[1] Comments
Like this post? del.icio.us | furl | slashdot | technorati | digg

Support Chinese in JSF, NetBeans

Tuesday Jul 03, 2007

I'm developing a small project based on the JSF (Visual Web Pack) on NetBeans 5.5.1. It works pretty well at the beginning. But when I tried to input some Chinese characters in the form, and save it into MySQL database through menuDataProvider.commitChanges(), it didn't work. The Chinese chars will become '?' next time it's retrieved and displayed.

Solution: JSF is based on UTF-8 already. But by default, the connection to mysql db is using ISO8859_1 encoding. Adding encoding info in the connecting url string in context.xml file should fix this issue.

url="jdbc:mysql://127.0.0.1:3306/lunch?useUnicode=true&amp;characterEncoding=UTF-8"

 

[0] Comments
Like this post? del.icio.us | furl | slashdot | technorati | digg