Sunday, December 20, 2009

Spring annotations static injection tutorial

I found this interesting code snippet to initialize static properties of a class using Spring IoC

public class UserUtils
  private static UserAccessor userAccessor;

   * Sets the rule DAO. This method should never be called except by Spring
   * @param userAccessor The user accessor to set
  @Autowired(required = true)
  public void setUserAccessor(userAccessor UserAccessor) {
    UserUtils.userAccessor = userAccessor;

Friday, December 4, 2009

MySQL: Export Table

C:\>mysqldump -hlocalhost -P3307 -uroot -ppass --tables gis places > c:/x.sql

This would export table structure and data for table named places from schema named gis
you can export multiple tables by providing list of table names instead of just one in this example
C:\>mysqldump -hlocalhost -P3307 -uroot -ppass gis  > c:/y.sql

This would export all tables in schema gis
C:\>mysql -hlocalhost -P3307 -uroot -ppass myschema < c:/x.sql

This would import the data into schema named myschema
Export schema objects without data
C:\>mysqldump -hlocalhost -P3307 -uroot -ppass --tables --no-data myschema > c:/myschema_script.sql

C:\>mysql -hlocalhost -P3307 -uroot -ppass myschema  < c:/myschema_script.sql