Thursday, March 28, 2013

MySQL - Cannot truncate a table referenced in a foreign key constraint

If you encounter the error "Cannot truncate a table referenced in a foreign key constraint", temporality turn off the foreign keys check like the following:

SET FOREIGN_KEY_CHECKS=0;
TRUNCATE table;
SET FOREIGN_KEY_CHECKS=1;

Wednesday, March 6, 2013

MySQL - how to see the bit(1) value

Say you have a column active bit(1).

In MySQL cmd, type
select active+0 from table
You should be able to see it.

Tuesday, March 5, 2013

SpringMVC - SEVERE: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener

Make sure you have added the following if you are using Maven


dependency>
      groupId>org.springframework< /groupId>
      artifactId>spring-web< /artifactId>
      version>3.2.1.RELEASE< /version>
< /dependency>

If not, make sure the spring-web jar is in your lib folder and also in the build path (Right click on your project -> properties -> Java Build Path -> Add JARs)

Monday, March 4, 2013

Nginx client intended to send too large body

If you see the message "client intended to send too large body" in the nginx log file (/var/log/nginx/error.log), you need to set the size of client_max_body_size.

You can set client_max_body_size in the context of http, server, location.

For example, in your .conf file:


server {
        listen 80;
        server_name domain.com;
        access_log /vol/logs/nginx/web_portal.access.log;

        location / {

                if ($http_x_forwarded_proto != 'https') {
                        rewrite ^ https://$host$request_uri? permanent;
                }

                proxy_pass      http://domain.com
                proxy_next_upstream error timeout invalid_header http_500;
                proxy_connect_timeout 1;
                proxy_set_header        Host            $host;
                proxy_set_header        X-Real-IP       $remote_addr;

                proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_intercept_errors on;
                error_page 502 503 504 =200 http://domain.com;
                client_max_body_size 650M;
        }
}