The Answer to Life, the Universe, and Everything

Tuesday, December 23, 2008

SQL Error: 0, SQLState: 08S01

If you see the such a error by using hibernate3, you need the following to avoid it.
JDBCExceptionReporter SQL Error: 0, SQLState: 08S01


In hibernate.cfg.xml, write

<property name="c3p0.min_size">5</property>
<property name="c3p0.max_size">20</property>
<property name="c3p0.timeout">1800</property>
<property name="c3p0.max_statements">50</property>


Then create "c3p0.properties" in your root classpath folder and write
c3p0.testConnectionOnCheckout=true
c3p0.acquireRetryDelay=1000
c3p0.acquireRetryAttempts=1

Wednesday, December 10, 2008

Illegal mix of collations in MySQL

In case for having such a error in mysql using Hibernate or so.

java.sql.SQLException: General error message
from server: "Illegal mix of collations
(utf8_general_ci,COERCIBLE) and
(latin1_swedish_ci,IMPLICIT) for operation '='"


Add the following in my.cnf
[client]
default-character-set = utf8

[mysqld]
skip-character-set-client-handshake
default-character-set=utf8
character-set-server=utf8
init-connect=SET NAMES utf8

Monday, November 17, 2008

Apache2.2 : AuthUserFile Error

<Location /svn>
DAV svn
SVNParentPath "/var/svn"
AuthzSVNaccessFile /var/svn/.htpasswd
AuthType Basic
AUthName "Dev Project"
AuthUserFile /var/svn/.htpasswd
</Location>

I set the basic authentication such as above which ended up the below error.
# /etc/init.d/apache2 reload
Syntax error on line 64 of /etc/apache2/mods-enabled/dav_svn.conf:
Invalid command 'AuthUserFile', perhaps misspelled or defined by a module not included in the server configuration

Since below,
$ for i in /usr/lib/apache2/modules/*; do strings $i | grep -q -i AuthUser && echo $i; done
/usr/lib/apache2/modules/mod_authn_file.so
$ ls /etc/apache2/mods-available/authn_file.load
/etc/apache2/mods-available/authn_file.load

You need to do as follow,
$ sudo /usr/sbin/a2enmod authn_file
Module authn_file installed; run /etc/init.d/apache2 force-reload to enable.
$ /usr/sbin/apache2ctl configtest
Syntax OK

Friday, November 14, 2008

JBoss Setting

After the installation of JBoss, here is the know-how of its setting.

1) Heap size
$ sudo vim $JBOSS/bin/run.conf

JAVA_OPTS="-Xms128m -Xmx512m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000"
=>
JAVA_OPTS="-Xms512m -Xmx768m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000"

2) Port check
vim $JBOSS/server/default/deploy/jboss-web.deployer/server.xml


3) Transaction time out
vim $JBOSS/server/default/conf/jboss-service.xml

300
=>
150

4) Thread number
vim server/default/deploy/jboss-web.deployer/server.xml

maxThreads="250"
=>
maxThreads="200"

5) Log Output level by log4j
vim /opt/jboss-4.2.3.GA/server/default/conf/jboss-log4j.xml 
<root>
<priority value="WARN" />
<appender-ref ref="CONSOLE"/>
<appender-ref ref="FILE"/>
</root>

Thursday, November 13, 2008

Struts2 and Hibernate v3 Min. Lib.

Those are the minimum required libraries for Struts2 and Hibernate v3.

Struts2

-commons-logging
-freemaker
-ognl
-struts2-core
-xwork


JBoss
-hibernate3
-antlr
-comons-collection
-dom4j
-javassist
-jta
-slf4j-api

Monday, August 18, 2008

Log4J Log rotate

It's better to log rotate by Java side than using Linux/Unix logrotate.
This is the example for log4J v1.2x (The v1.3 development is stopped by the way.) series , "log4j.xml" file.

By using DailyRollingFileAppender, you can log rotate as the date base.


<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<!--Definition of the File Appender -->
<appender name="file" class="org.apache.log4j.DailyRollingFileAppender">
<!-- Date pattern policy -->
<param name="DatePattern" value=".yyyy-ww" />

<param name="File" value="logs/hibernate.log"/>
<!-- Log append -->
<param name="Append" value="true" />

<!-- Log layout -->
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %5p %c{1} - %m%n" />
</layout>

<!-- Default log level -->
<param name="threshold" value="info"/>

</appender>

<!--Console log appender -->
<appender name="stdout" class="org.apache.log4j.ConsoleAppender">
<!-- Default log level -->
<param name="threshold" value="info"/>
<!-- log layout -->
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %5p %c{1} - %m%n"/>
</layout>
</appender>

<root>
<appender-ref ref="stdout"/>
<appender-ref ref="file"/>
</root>
</log4j:configuration>

Saturday, June 07, 2008

File code converting

After moving from Windows dev. environment to Linux, source file needs to be converted to UTF8 from Shift_JIS. It's done easily.
 find ./* -type f -name '*.java' -exec nkf -Luw --overwrite {} \;

Tuesday, May 27, 2008

Flv file convert

Flv file convert to music format

.flv to mp3
$ ffmpeg -i xxx.flv -vn -acodec aac -ab 128k -ac 2 -ar 44100 -y test.mp3


.flv to aac
$ ffmpeg -i xxx.flv -vn -acodec mp3 -ab 128k -ac 2 -ar 44100 -y test.mp3


.flv to mp4
$ ffmpeg -bitexact -y -i OLD_TOWN.flv -vcodec mpeg4 -s 320x240 -r 25 -b 480k -acodec aac -ac 2 
-ar 22050 -ab 69k out.mp4


To cut mp3 then
$ sudo apt-get install poc-streamer
#mp3cut [ -o outputfile ] [ -T title ] [ -A artist ] [ -N album-name ]
[ -t [hh:]mm:ss[+ms]-[hh:]mm:ss[+ms] ] mp3file [[ -t … ] mp3file1 …]

$ mp3cut -o cut.mp3 -t 00:08-00:49 test.mp3

Wednesday, May 21, 2008

Awstats for Ubuntu

awstats is log analyzer I use it for tomcat log analysis.

<Host name="localhost" appBase="webapps" >
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs" prefix="ich_access_log."
suffix=".txt" pattern="combined" resolveHost="false" / >
</Host >


Setting for awstats

cp -r /usr/share/awstats/icon /var/www/awstats-icon
/usr/lib/cgi-bin/awstats.pl -config=hostname -update


Then access to :http://hostname/cgi-bin/awstats.pl?config=hostname

Edit cron

crontab -e
--
0 1 * * * /usr/lib/cgi-bin/awstats.pl -config=hostname -update

Wednesday, May 14, 2008

Firefox3 Plugins

I've been using Hardy 8.04 which implements Firefox3.0b5.
Still many of FF plug-ins are not supported for FF3. If you want to use it by any means.

1) about:config
2) Choose New>Boolean. Then "checkCompatibility" to "false".
3) Choose New>Boolean. "checkUpdateSecurity" to "false".
4) Restart Firefox and done ;-)

Thursday, March 06, 2008

Change the folder name in English

Change the default folder such as Music/Document etc. name in English.

LANG=C xdg-user-dirs-gtk-update

Monday, February 25, 2008

zshrc

mine

# Created by newuser for 4.3.4

export JAVA_HOME=/usr/lib/jvm/java-6-sun
export PATH=$PATH:/opt/apache-maven-2.0.8/bin

alias eclipse='/opt/eclipse/eclipse'
alias update='sudo apt-get update'
alias upgrade='sudo apt-get upgrade'
alias du="du -h"
alias df="df -h"
alias ps="ps -aux"

# For auto compinit
autoload -U compinit
compinit

# For prompt
PROMPT="%/%% "
PROMPT2="%_%% "
SPROMPT="%r is correct? [n,y,a,e]: "

# For title bar
case "${TERM}" in
kterm*|xterm)
precmd() {
echo -ne "\033]0;${USER}@${HOST%%.*}:${PWD}\007"
}
;;
esac

# For history function
HISTFILE=~/.zsh_history
HISTSIZE=10000
SAVEHIST=10000
setopt hist_ignore_dups # ignore duplication command history list
setopt share_history # share command history data

# For History search shortcut
autoload history-search-end
zle -N history-beginning-search-backward-end history-search-end
zle -N history-beginning-search-forward-end history-search-end
bindkey "^P" history-beginning-search-backward-end
bindkey "^N" history-beginning-search-forward-end

# Editor vi mode
bindkey -v

# For remembering the previous folder
setopt auto_pushd

# No beep
setopt nolistbeep

# For auto-prediction function
autoload predict-on
predict-on

Saturday, February 09, 2008

Ubuntu Gutsy Step1

I just bought Dell Inspiron 1720 for my private note PC.
I certainly decided to delete Vista and then install Ubuntu for the box.
This is step by step set up for my reminder.
I skip writing the way to add apt line or so as it is too easy procedure to forget.

*Sound - you need to install the following package to enable the sound

$ sudo apt-get install linux-backports-modules-generic


1) I suggest to visit here for your little preparation
http://easylinux.info/wiki/Ubuntu:Gutsy

2) Font installation

#Mplus
% sudo cp /usr/share/fonts/truetype/ipa/ipag.ttf .
% sudo fontforge -script m++ipa.pe
% sudo mkdir /usr/share/fonts/truetype/mplus
% sudo mv M*IPAG.ttf /usr/share/fonts/truetype/mplus/.
% sudo fc-cache -f -v /usr/share/fonts/truetype/mplus

#Mikacha for the same step


3) Then go to forum to see what you want to do.
http://ubuntuforums.org/

4) Adobe related s/w
Flash capability is important. Visit adobe page to download the flash player.

$ tar zvxf install_flash_player_9_linux.tar.gz
$ cd install_flash_player_9_linux/
$ sudo ./flashplayer-installer

--
Copyright(C) 2002-2006 Adobe Macromedia Software LLC. All rights reserved.
Adobe Flash Player 9 for Linux
Adobe Flash Player 9 will be installed on this machine.
You are running the Adobe Flash Player installer as the "root" user.
Adobe Flash Player 9 will be installed system-wide.
Support is available at http://www.adobe.com/support/flashplayer/
To install Adobe Flash Player 9 now, press ENTER.
To cancel the installation at any time, press Control-C.
NOTE: Please exit any browsers you may have running.
Press ENTER to continue...
Please enter the installation path of the Mozilla, Netscape,
or Opera browser (i.e., /usr/lib/mozilla): /usr/lib/firefox


----------- Install Action Summary -----------
Adobe Flash Player 9 will be installed in the following directory:
Browser installation directory = /usr/lib/firefox
Proceed with the installation? (y/n/q): y
Installation complete.
Perform another installation? (y/n): n
Please log out of this session and log in for the changes to take effect.
The Adobe Flash Player installation is complete.

#Then PDF
$sudo aptitude install acroread acroread-plugins acroread-escript
$sudo aptitude install mozilla-acroread

--set at the first launch :: Edit -> Prefences -> Interne
Browser Executable: /usr/bin/firefox
libgtkembedmoz Folder: /usr/lib/firefox/


5) java capability


$ sudo apt-get install sun-java6-jre sun-java6-plugin
$ sudo update-java-alternatives -s java-6-sun
$ sudo vim /etc/jvm
--
#Add the following line in the top of the file
/usr/lib/jvm/java-6-sun

Friday, January 11, 2008

MySQL5 character set

All you need to edit my.cnf in order not to write the command like "set name xxx" everytime you restart the service.


[client]
default-character-set = utf8

[mysqld]
skip-character-set-client-handshake
default-character-set = utf8
character-set-server = utf8
collation-server = utf8_general_ci
init-connect = SET NAMES utf8

[mysqldump]
default-character-set = utf8

[mysql]
default-character-set = utf8


In order to check the charset

mysql> shwo variables like 'char%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+

#Then set charset
mysql>set character_set_database=utf8
mysql> show variables like 'char%';
+--------------------------+----------------------------+
| Variable_name | Value |
+--------------------------+----------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+