tananaev/traccar — pull request #875 by vitalidze (2014-09-19 04:45:12+00:00)
Title: Connection pooling

I am using MySQL and from time-to-time I am facing problem when connection times out due to inactivity:

```
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

The last packet successfully received from the server was XXX.XXX milliseconds ago. The last packet sent successfully to the server was XX milliseconds ago.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
```

I know that this can be worked out by using `autoReconnect=true` parameter in JDBC url of MySQL. However, in such case it throws an error right before reconnecting. So the failure is still recorded.

My big question is why don't traccar use connection pooling? Instead of using it it just has single 'advanced' connection in `DatabaseDataManager` and a weird datasource in web server set up in JNDI context. I believe the much better approach is to use connection pool like c3p0 or dbcp or modern bonecp. There are many benefits of using connection pooling and I thinks this is a good choice for traccar.

I can implement it and submit a pool request. I just want it to be in upstream to avoid merging issues in future.