Hello,
I am programming a WebService in Java that create and call this class :
public class Manager{
private Connection aConnection;
public CacheManager(){
//We get a connection
aConnection = java.sql.DriverManager.getConnection("jdbc:mysql://localhost/mydb?user=root&password=";
}
// Insert a datalist into a table
public void insertIntoDB(List listData, String tableName, StringData previousData)
{
// Some code using database
}
The main problem is that the connection is not closed right after the call of the webservice. It means that 100 calls to the webservice create 100 connections to the database.It create the MySQL error "too many users connected" If I wait 2 minutes, objects are destroyed by the garbage collector and the webservice can work again.
Does somebody has an idea about how to bypass this problem ?
Thanks!!