con=L2DatabaseFactory.getInstance().getConnection()
			rem=con.prepareStatement("DELETE FROM buffer_scheme_contents WHERE scheme_id=? AND skill_id=? AND skill_level=? LIMIT 1")
			rem.setString(1, scheme)
			rem.setString(2, skill)
			rem.setString(3, level)
			try :
				rem.executeUpdate()
			except :
				pass
			if getBuffCount(scheme) == 0 :
				HTML = getOptionList(scheme)
			else :
				HTML = viewAllSchemeBuffs(scheme,eventParam2,"remove")
			return HTML
			
		if event == "add_buff" :
			event = eventParam1.split("_")
			scheme = event[0]
			skill = event[1]
			level = event[2]
			idbuffclass = getclassbuff(skill)
			con=L2DatabaseFactory.getInstance().getConnection()
			ins = con.prepareStatement("INSERT INTO buffer_scheme_contents (scheme_id,skill_id,skill_level,buff_class) VALUES (?,?,?,?)")
			ins.setString(1, str(scheme))
			ins.setString(2, str(skill))
			ins.setString(3, str(level))
			ins.setString(4, str(idbuffclass))
			try :
				ins.executeUpdate()
				ins.close()
				con.close()
			except :
				pass		
			if getBuffCount(scheme) == MAX_BUFFS_PER_SCHEME :
				HTML = getOptionList(scheme)
			else :
				HTML = viewAllSchemeBuffs(scheme,eventParam2,"add")
			return HTML

I am using this script in Java aplication(gaming)and i keep getting error with unclosed connection!
I found there is on line :con=L2DatabaseFactory.getInstance().getConnection()
without ending with con.close()!
I am not sure where should i put con.close() after first on=L2DatabaseFactory.getInstance().getConnection()!

I would guess that you should comment line #22 as it is a duplicate of line #1, and so tries to open the same connection. For further help, please post the entire error message, as guessing is not a good thing.

Unclosed connection! Trace: sun.reflect.GeneratedMethodAccessor14.invoke(Unknown Source)
java.lang.RuntimeException
        at l2.java.L2DatabaseFactory.getConnection(L2DatabaseFactory.java:227)
        at sun.reflect.GeneratedMethodAccessor14.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.python.core.PyReflectedFunction.__call__(Unknown Source)
        at org.python.core.PyMethod.__call__(Unknown Source)
        at org.python.core.PyObject.__call__(Unknown Source)
        at org.python.core.PyInstance.invoke(Unknown Source)
        at org.python.pycode.serializable._pyx1312226277351.onAdvEvent$14(__init__.py:1207)
        at org.python.pycode.serializable._pyx1312226277351.call_function(__init__.py)
        at org.python.core.PyTableCode.call(Unknown Source)
        at org.python.core.PyTableCode.call(Unknown Source)
        at org.python.core.PyTableCode.call(Unknown Source)
        at org.python.core.PyFunction.__call__(Unknown Source)
        at org.python.core.PyMethod.__call__(Unknown Source)
        at org.python.core.PyObject.__call__(Unknown Source)
        at org.python.core.PyObject._jcallexc(Unknown Source)
        at org.python.core.PyObject._jcall(Unknown Source)
        at org.python.proxies.main$Quest$3.onAdvEvent(Unknown Source)
        at l2.brick.gameserver.model.quest.Quest.notifyEvent(Quest.java:448)
        at l2.brick.gameserver.model.actor.instance.L2PcInstance.processQuestEvent(L2PcInstance.java:1795)
        at l2.brick.gameserver.network.clientpackets.RequestBypassToServer.runImpl(RequestBypassToServer.java:210)
        at l2.brick.gameserver.network.clientpackets.L2GameClientPacket.run(L2GameClientPacket.java:62)
        at l2.brick.gameserver.network.L2GameClient.run(L2GameClient.java:1023)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

Here is full error code

This article has been dead for over six months. Start a new discussion instead.