I had read on the web that when updating with these instructions, there is no need to close the connection, but I got the "Pool Exhausted" error, I use this code:
Code: Select all
void Write_On_Database(String gifts)
{
IDBManager dbmanager = GameData.loginZone.getDBManager();
try
{
dbmanager.executeUpdate("UPDATE events_current SET gifts = ? WHERE id = ? ", new Object[] //This is CurrentEvents.java:305
{ gifts, id });
}
catch (SQLException e)
{
System.out.println("Error SQL: " + e);
e.printStackTrace();
}
catch (Exception e)
{
System.out.println("Error Generic: " + e);
e.printStackTrace();
}
}
Error:
Code: Select all
Error SQL: java.sql.SQLException: Cannot get a connection, pool error: Pool exhausted
java.sql.SQLException: Cannot get a connection, pool error: Pool exhausted
at org.apache.commons.dbcp.PoolingDriver.connect(PoolingDriver.java:188)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:270)
at com.smartfoxserver.v2.db.SFSDBManager.getConnection(SFSDBManager.java:113)
at com.smartfoxserver.v2.db.SFSDBManager.executeUpdate(SFSDBManager.java:194)
at gamedata.CurrentEvents.Write_GiftsString_On_Database(CurrentEvents.java:305)
at gamedata.CurrentEvents.<init>(CurrentEvents.java:156)
at gamedata.GameData.Control_If_Add_Event_To_CurrentEvents(GameData.java:330)
at registerserver.Developer.Set_New_Event(Developer.java:189)
at registerserver.Developer.handleClientRequest(Developer.java:76)
at com.smartfoxserver.v2.extensions.SFSExtension.handleClientRequest(SFSExtension.java:208)
at com.smartfoxserver.v2.controllers.v290.ExtensionReqController.processRequest(ExtensionReqController.java:174)
at com.smartfoxserver.v2.controllers.v290.ExtensionReqController$1.run(ExtensionReqController.java:68)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.util.NoSuchElementException: Pool exhausted
at org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObjectPool.java:1096)
at org.apache.commons.dbcp.PoolingDriver.connect(PoolingDriver.java:180)
... 15 more