среда, 9 ноября 2011 г.

PostgreSQL. How Disable All Constraints

Sometimes shit happens.
In my situation it was two plain-text SQL files. One of them contains DB schema and second with data.
I successfully create new DB and create DB schema using command:
psql -U my_user my_db < db_schema.sql
but the next steps gave many errors.
pg_restore didn’t want to read this format and psql didn’t want insert data because constraints were already turn on.
I did not find correct way for turn off all constraints in PosgressSQL. I found information about how disable triggers for specific table but not for all:
http://www.postgresql.org/docs/8.1/static/sql-altertable.html
After some experiments I found the next way which works for PostgreSQL v8.3.3:
Disable all triggers(run this sql command):
update pg_trigger set tgenabled='D' ;
Insert data:
psql -U my_user my_db < db_data.sql
Enable all triggers:
update pg_trigger set tgenabled='O' ;

четверг, 3 ноября 2011 г.

Using log4j into jboss

Good article about using log4j into jboss
http://www.mastertheboss.com/jboss-application-server/251-jboss-log4j-configuration.html?showall=1

пятница, 7 октября 2011 г.

среда, 13 октября 2010 г.

jMagick installation

First step - install ImageMagick :
For installation download file from for your OS and simple run it.
(for Unbuntu OS run command: apt-get install imagemagick --fix-missing)

Second step - install jMagick :
For installation download files from and follow by instructions
(for Unbuntu OS run command: sudo apt-get install jmagick --fix-missing)

Make sure that jmagick binary files (jmagick*.so or jmagick*.dll for windows os) are accessible for jvm. This files mast be present in /usr/lib for linux os or in java_home/bin folders. If this files are absent simple copy it from jmagick installation package.

четверг, 30 сентября 2010 г.

среда, 23 июня 2010 г.

Java Parameters

For debugging many project use next too helpful java parameters:
-verbose:class - Display information about each class loaded.
-Dproperty=value - Set a system property value.
  for example:   -Djava.endorsed.dirs=C:/jboss-5.1.0.GA/lib/endorsed/ sets endorsed libon JBoss startup

For more information see http://java.sun.com/javase/6/docs/technotes/tools/solaris/java.html

четверг, 24 декабря 2009 г.

Spring and file uploading

There are many guide how to upload file in spring framework. For example you can use ref .
But when you use it remember:
  • Add multipartResolver bean to spring.xml file!
  • Add fileupload.jar and commons-io.jar from http://commons.apache.org/downloads/download_fileupload.cgi
  • You can use Yahoo uploader or something that. If you do it add parameter name to request.
    For example in yahoo widget use:
    uploader.upload(fileID, url, "post", {}, "file");
  • Remember! SWF can not support cookies. That meens you droped current session. For resolve it simple add ;jsessionid=valuees to upload url.
    Example:
    var url="/reports/uploadFile;jsessionid=F34C5040A029C61658E8CC7A73841CCC"
  • Don't forget return response 200 from controller.
    Example:
    1 @RequestMapping(value = "/reports/uploadFile", method = RequestMethod.POST)
    2 public void uploadFile(@RequestParam("file") MultipartFile file, HttpServletResponse response) throws IOException {
    3
    4 reportStorageService.saveFile(file.getName(), file.getContentType(), file.getSize(), file.getBytes());
    5
    6 response.setStatus(HttpServletResponse.SC_OK);
    7
    8 }