Answer the question
In order to leave comments, you need to log in
How to prevent the server from closing the connection to the database?
Good day. There is a server in Java, running under Ubuntu. I encountered a fairly common problem - after a certain time, the connection to the Mysql database is closed and does not allow anything to be put / taken away. Advises to set autoReconnect=true in JDBC properties, which doesn't help.
Further actions: I try to run a python program as a background process that pings the server every 10 minutes. Also doesn't help.
from commands import getoutput
from time import sleep
import re
import os
host='мой сервер'
interval1=600
interval2=600
p = re.compile('ttl=')
while True:
ping=getoutput('ping -c 2 %s' % host)
if not p.findall(ping):
print "Attempt to connect failed"
sleep(interval2)
sleep(interval1)
response = urllib.urlopen(host)
Answer the question
In order to leave comments, you need to log in
Use pool connections. There are a million settings and you don't need to ping anything.
ping to the database in no way (well, except for checking the availability of the piece of iron)
pick the Java connector, it's very strange that it closes itself
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question