MySQL Fix for Error Code: 1205. Lock wait timeout exceeded; try restarting transaction

This can mostly occur when you are trying to insert or update a table but there is a pending transaction thats locked some table. I run into these during my test units when inserting or updated test data and if there is a exception in between. Perils of good programming yeah! 😀

Anyways in order to diagnose this we need to connect to MySQL sever using the root access.

From your MySQL Workbench or mysql prompt run the below command.

SHOW ENGINE INNODB STATUS ;

Copy the contents of column status into a text editor and look for the lines.

mysql tables in use 1, locked 1

Under this you can see the MySQL thread id which shows the erring query that seems to have locked out the table. copy the id of this thread and proceed to kill the process.

MySQL thread id 60525, OS thread handle 0x7fd90c209700, query id 2102784 

Take caution before running the below command and ensure you know the consequences of killing a process, if in doubt refer to an experienced DBA.

Kill 60525;

Setup Tomcat7 as Server in Eclipse Luna under Ubuntu Linux

On your Ubuntu (12.04/14.04/14.10/15.04) , if you have installed tomcat7 from the repositories then adding them as a server in Eclipse would need some tweaks.

Getting the tomcat to be administrered from Eclipse makes it easy if you are developing enterprise applications on Java using Tomcat7 as your app server.

I have used Eclipse for Java EE version 4.4.2 Luna for the example below.

Make sure you have tomcat7 installed correctly. Do ensure you have the tomcat7-admin package installed as well. Run the command below to check the same.

whereis tomcat7

you should get

/etc/tomcat7 /usr/share/tomcat7

Before you add a server in Eclipse ensure to run the following commands, the tomcat server in eclipse expects to have these files and folders in their respective locations for working correctly.

cd /usr/share/tomcat7
sudo ln -s /var/lib/tomcat7/conf conf
sudo ln -s /etc/tomcat7/policy.d/03catalina.policy conf/catalina.policy
sudo ln -s /var/log/tomcat7 log
sudo chmod -R 777 /usr/share/tomcat7/conf
sudo ln -s /var/lib/tomcat7/common common
sudo ln -s /var/lib/tomcat7/server server
sudo ln -s /var/lib/tomcat7/shared shared

If you are going to solely use Eclipse to start and stop tomcat server then remove the tomcat7 from the startup script to disable it from starting automatically everytime the machine boots up.

sudo service tomcat7 stop
sudo update-rc.d tomcat7 disable

Now open the Java EE perspective in your Eclipse. Choose New server either from the File-> New menu or from New Server tab as shown below.

Screenshot from 2015-06-23 10:11:03

 

In the next screen choose Tomcat7 Server.

Screenshot from 2015-06-23 10:11:52

Enter the host name and server name as shown above. You will find the Server runtime environment to be empty. Click Add.. next to it to configure the tomcat7 server as shown below.

Screenshot from 2015-06-23 10:11:52-2

 

Use /usr/share/tomcat7 as the tomcat installation directory or browse if you want to chose another custom installtion directory of tomcat7 and click finish.

Now on the server tab you should see the administrative options for tomcat7 as shown below.

Screenshot from 2015-06-23 10:22:46

 

The reason we did soft linking of folders earlier in the post is because the server setup here expects all the files and folders required for setup in one directory of /usr/share/tomcat7. You will find typical errors as shown below.

‘Could not load the Tomcat server configuration at /usr/share/tomcat7/conf. The configuration may be corrupt or incomplete /usr/share/tomcat7/conf/catalina.policy (No such file or directory)’

The above solution is taken from this answer by Joe on this question thread in stackexchange.