Friday, March 26, 2010

Backup/Restore db using MySQL

Type on your command prompt (windows) or terminal (linux)

To Backup : mysqldump -v -uroot -ppassword -hlocalhost db_user > "db_user.sql"

To Restore : mysql -v -uroot -ppassword -Ddb_user < "db_user.sql"

How to Install MySQL on Linux?

After spending much time searching on google, blogs, and many others resource I finally found simple way to configure MySQL, here the steps :

1. Login as root and Open terminal then type :

shell> groupadd mysql // to add mysql as a group
shell> useradd -g mysql mysql // add user as mysql
shell> cd /usr/local

// unzip your MySQL source
shell> gunzip < /path/to/mysql-VERSION-OS.tar.gz | tar xvf -

// make a symbolic link called "mysql"
shell> ln -s full-path-to-mysql-VERSION-OS mysql

shell> cd mysql

// change owner as mysql
shell> chown -R mysql .

// change group as mysql
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql

// change the owner as root
shell> chown -R root .
shell> chown -R mysql data
shell> bin/mysqld_safe --user=mysql &

// this is for configure mysql as autorun services
shell> cp mysql.server /etc/init.d/mysql

// this is for changing access type of mysql
shell> chmod +x /etc/init.d/mysql

shell> cd /etc
shell> ln -s rc.d/init.d .

shell> chkconfig --add mysql

shell> chkconfig --level 345 mysql on

2. Setting PATH for MySQL

- open directory /etc/profile and find a file named "profile"

- Edit the file, add this path:

// you can load mysql in any directory
export PATH="$PATH:/usr/local/mysql/bin"

- do a test on terminal as you type mysql -version

3. Set MySQL password:

shell> mysql --user=root mysql
mysql> update user set password=PASSWORD("NEWPASSWORD") where User='agusjuliardi';
mysql> flush privileges; // Untuk reload privileges
mysql> quit

4. Add user MySQL :

// this is for creating a user
mysql> CREATE USER 'agus'@'localhost' IDENTIFIED BY 'some_pass';

// grant all privileges on to user "agus"
mysql> GRANT ALL PRIVILEGES ON *.* TO 'agus'@'localhost' WITH GRANT OPTION;

// create user "agus@%" -> this can be opened on client
mysql> CREATE USER 'agus'@'%' IDENTIFIED BY 'some_pass';

// create user "admin"
mysql> CREATE USER 'admin'@'localhost';

// reload your changes
mysql> GRANT RELOAD,PROCESS ON *.* TO 'admin'@'localhost';

// create user "dummy"
mysql> CREATE USER 'dummy'@'localhost';

Hopefully Helpful...

Configuring Seam On Eclipse

SEAM - Next generation enterprise java development

Seam is a powerful open source development platform for building rich Internet applications in Java. Seam integrates technologies such as Asynchronous JavaScript and XML (AJAX), JavaServer Faces (JSF), Java Persistence (JPA), Enterprise Java Beans (EJB 3.0) and Business Process Management (BPM) into a unified full-stack solution, complete with sophisticated tooling.

Seam has been designed from the ground up to eliminate complexity at both architecture and API levels. It enables developers to assemble complex web applications using simple annotated Java classes, a rich set of UI components, and very little XML. Seam's unique support for conversations and declarative state management can introduce a more sophisticated user experience while at the same time eliminating common bugs found in traditional web applications.

To begin development we need to configure seam on an opensource IDEs, one of them is Eclipse.

Here is the configuration :

1. Extract jboss-seam (here I use jboss-seam-2.1.1.GA.tar.gz) on your destination folder (I use D:\java-app\jboss-seam-2.1.1.GA.tar.gz)

2. Extract on D:\java-app folder.

3. Run eclipse.exe on your destination folder above.

4. On your first window choose workbench.

5. jboss tools installation

- extract on D:\java-app
- run eclipse.exe
- choose Help menu -> Software Updates...
- find out jboss tools on your exclipse software updates to ensure jboss is available and works well.

6. Begin project deployment on Seam

seam setup:

- Create a new folder for project on D:\proyek.
Copy mysql-connector-java-5.1.0-bin.jar to D:\proyek
Open command prompt, type D:

type cd java-app\jboss-seam-2.1.1.GA

type seam setup

[input] Enter your Java project workspace (the directory that contains your Seam projects) [C:/Projects] [C:/Projects]

[input] Enter your JBoss AS home directory [C:/Program Files/jboss-4.2.3.GA] [C:/Program Files/jboss-4.2.3.GA]

[input] Enter the project name [myproject] [myproject]

[input] Do you want to use ICEfaces instead of RichFaces [n] (y, [n])

[input] Select a RichFaces skin [classic] (blueSky, [classic], deepMarine, DEFAULT, emeraldTown, japanCherry, ruby, wine)

[input] Is this project deployed as an EAR (with EJB components) or a WAR (with no EJB support) [ear] ([ear], war)

[input] Enter the Java package name for your session beans [com.mydomain.myproject] [com.mydomain.myproject]

[input] Enter the Java package name for your entity beans [com.artmkn.myproject] [com.artmkn.myproject]

[input] Enter the Java package name for your test cases [com.artmkn.myproject.test] [com.artmkn.myproject.test]

[input] What kind of database are you using? [hsql] ([hsql], mysql, oracle, postgres, mssql, db2, sybase, enterprisedb, h2)

[input] Enter the Hibernate dialect for your database [org.hibernate.dialect .MySQLDialect] [org.hibernate.dialect.MySQLDialect]

[input] Enter the filesystem path to the JDBC driver jar [D:\java-app\jboss-seam-2.1.1.GA/lib/hsqldb.jar] [D:\java-app\jboss-seam-2.1.1.GA/lib/hsqldb.jar]

[input] Enter JDBC driver class for your database [com.mysql.jdbc.Driver] [com.mysql.jdbc.Driver]

[input] Enter the JDBC URL for your database [jdbc:mysql:///test] [jdbc:mysql:///test]

[input] Enter database username [sa] [sa]

[input] Enter database password [] []

[input] Enter the database catalog name (it is OK to leave this blank) [] []

[input] Are you working with tables that already exist in the database? [n](y, [n])

[input] Do you want to drop and recreate the database tables and data in import.sql each time you deploy? [n] (y, [n])

[propertyfile] Creating new property file: D:\java-app\jboss-seam-2.1.1.GA\seam-gen\
[echo] Installing JDBC driver jar to JBoss AS
[copy] Copying 1 file to D:\projek\server\default\lib
[echo] Type 'seam create-project' to create the new project


seam create-project

type seam create-project on command prompt
if success the output must be:


type seam generate on command prompt
if success the output must be


seam restart

type seam restart on command prompt and type http://localhost:8080/myproject on your browser as shown below :

Thursday, January 21, 2010

rich column vs jsf columns

Rich column : We could use attributes such as "SortBy" and "FilterBy".

Jsf column : Only some attributes is available.

Do you find another?comment please...

JSF : Simple Date Format

Sometimes we need to display Date Outputs.
There is customs format always used :

format : dd/MMM/yyyy kk:mm
Result : 26/Jan/2010 10:52

format : dd MMM yyyy kk:mm
Result : 26 March 2010 10:52

JSF : Using Currency Symbol

This is the Code :

This the Output :

Wednesday, September 9, 2009

J2EE application using JBOSS SEAM

This Output looks like desktop application