Saturday, October 21, 2006

readExif php script

It is very simple sample only a few lines of code.

- description
It read the JPEG file's EXIF information, and use the DateTime value to separate the image file to different folder.

-execution
1. Set php installed folder in envirnment variable.
2. then you can directly type "php" to execute php script on local computer.
3. enable the in php.ini (it may locate on Windows / WINNT folder):
extension=php_mbstring.dll
extension=php_exif.dll

4. put readExif.php into the image folder.
5. type "php readExif.php"
6. It will process.

Thursday, October 19, 2006

convert number to English words

I am finding the sample code to convert number to words.
I find one java sample:

reference: site
my own copy and modify code: my modify source file

It is quite simple to convert, just use a little bit time to understand

I think it can help to ppl no need to convert number when write cheque.

Wednesday, October 18, 2006

one-to-one bidirectional (in hibernate example) xDoclet

create xDoclet tag both one side
1. assume each user only have one car

user class reference car
car class reference user

2. identify From & To direction

assume that user (from) - car (to)
then user primary key store to car table (foreign key)

3. xDoclet tag

== code ==
car class:
/**
* @hibernate.many-to-one
* class = "local.sample.oo.User"
* column = "userId"
*/
public User getUser()
{
return _user;
}
== code ==

car is to --> so that is many-to-one relationship (from logic it is one-to-one but if both side one to one cannot be identify to & from)
column -> represent the user primary key store column on car table

== code ==
user class:
/**
* @hibernate.one-to-one
* cascade = "save-update"
*/
public Car getCar()
{
return _car;
}
== code ==

user is from -> so that is one-to-one relationship
cascade -> when update user, it also request car to update (if car is modified)

Monday, October 16, 2006

Simple Sample to use Spring, xDoclet and Hibernate

I just revision how to use Hibernate, you need to understand about the one-to-one, one-to-many, many-to-many before use the Hibernate. Hibernate is not very complicate but you don't use any tools to help develop the application with Hibernate, you will feel hard.
In my experience, I suggest to use Eclipse 3.1.x & JBoss IDE plugins to develop the Hibernate and Spring application.

I will provide the simple project. It demo how to create one-to-one, one-to-many, many-to-many.
You need to pay attention on :
  1. persistent classes xDoclect's Hibernate tag.
  2. Spring configuration xml file ( hibernate.xml) - datasource, hbm config, bean of spring
  3. xDoclet configuration. Project > right click > property > XDoclect configuration
Hope this example can give you idea to use Spring and Hibernate.
** Sample download**

Useful resource to futher study Hibernate.
- HibernateGossip

Any problem, please feel free to contact me:
mingkit@gmail.com

Mylar is eclipse plugin for project management

Interest! I will read about it and write some article.
http://www-128.ibm.com/developerworks/java/library/j-mylar1/?ca=dgr-jw01Mylar-1

http://www.hibernate.org/43.html

MySQL add new user account

It is a very simple procedure but i usually forget. We also can search ther result from MYSQL homepage. Please login by root account.
mysql -u root

1. create user account.
- CREATE USER mingkit IDENTIFIED BY 'password';

2. grant right for the accout.
- for localhost
GRANT ALL PRIVILEGES ON *.* TO 'mingkit'localhost'IDENTIFIED BY 'password' WITH GRANT OPTION;

- for worldwide or certain ip
GRANT ALL PRIVILEGES ON *.* TO 'mingkit'%'IDENTIFIED BY 'password' WITH GRANT OPTION;