Page 1 of 1

Unclosed connection

Posted: Sat Oct 01, 2011 10:33 am
by angkor_tm
If you want to receive support we need this info to help you properly.
» Find Revision
L2J Revision Freya last rev:
L2JDP Revision Freya last rev:

Hi!
Where can problemma? Where to dig?

Code: Select all

Unclosed connection! Trace: sun.reflect.GeneratedMethodAccessor15.invoke(Unknown Source)java.lang.RuntimeException        at com.l2jserver.L2DatabaseFactory.getConnection(L2DatabaseFactory.java:227)        at sun.reflect.GeneratedMethodAccessor15.invoke(Unknown Source)        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)        at java.lang.reflect.Method.invoke(Method.java:601)        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._pyx1317470639610.onAdvEvent$14(__init__.py:715)        at org.python.pycode.serializable._pyx1317470639610.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$421.onAdvEvent(Unknown Source)        at com.l2jserver.gameserver.model.quest.Quest.notifyEvent(Quest.java:448)        at com.l2jserver.gameserver.model.actor.instance.L2PcInstance.processQuestEvent(L2PcInstance.java:1746)        at com.l2jserver.gameserver.network.clientpackets.RequestBypassToServer.runImpl(RequestBypassToServer.java:212)        at com.l2jserver.gameserver.network.clientpackets.L2GameClientPacket.run(L2GameClientPacket.java:62)        at com.l2jserver.gameserver.network.L2GameClient.run(L2GameClient.java:1000)        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)        at java.lang.Thread.run(Thread.java:722) 

Re: Unclosed connection

Posted: Sat Oct 01, 2011 11:09 am
by angkor_tm
Where I have not closed the connection?
buffer.zip

Re: Unclosed connection

Posted: Sat Oct 01, 2011 12:13 pm
by nonom
Check the line 715

Code: Select all

 con=L2DatabaseFactory.getInstance().getConnection() 
You are getting an Unknown Source error

Re: Unclosed connection

Posted: Sat Oct 01, 2011 3:54 pm
by tukune
use try finally

:evil: Bad

Code: Select all

conn=L2DatabaseFactory.getInstance().getConnection()xxx = conn.prepareStatement("SELECT ....")blabla...try : L2DatabaseFactory.close(conn)except: pass
:D Good

Code: Select all

try :    conn=L2DatabaseFactory.getInstance().getConnection()    xxx = conn.prepareStatement("SELECT ....")    blabla...finally :    L2DatabaseFactory.close(conn)

Re: Unclosed connection

Posted: Sat Oct 01, 2011 4:01 pm
by angkor_tm
What I do change in this code?

Code: Select all

        if event == "create" :            con=L2DatabaseFactory.getInstance().getConnection()            param = eventParam1.replace("."," ")            if param == "no_name" :                return showText(st,"Info","Please, enter the scheme name!","True","Return","main")            else :                ins = con.prepareStatement("INSERT INTO buffer_scheme_list (player_id,scheme_name) VALUES (?,?)")                ins.setString(1, str(st.player.getObjectId()))                ins.setString(2, param)                try :                    ins.executeUpdate()                    ins.close()                    con.close()                except : pass            return rebuildMainHtml(st)
Maybe:

Code: Select all

        if event == "create" :            con=L2DatabaseFactory.getInstance().getConnection()            param = eventParam1.replace("."," ")            if param == "no_name" :                return showText(st,"Info","Please, enter the scheme name!","True","Return","main")            else :                ins = con.prepareStatement("INSERT INTO buffer_scheme_list (player_id,scheme_name) VALUES (?,?)")                ins.setString(1, str(st.player.getObjectId()))                ins.setString(2, param)                try :                    ins.executeUpdate()                    ins.close()                    con.close()+                   L2Databasefactory.close(con)                except : pass            return rebuildMainHtml(st)

Re: Unclosed connection

Posted: Sat Oct 01, 2011 4:46 pm
by angkor_tm
tukune wrote:use try finally
Thx I try

Re: Unclosed connection

Posted: Sun Oct 02, 2011 2:48 pm
by dreni
Lol I'm exactly trying to fix the same thing... Did you manage to find out where the error comes from? I think that the whole script has to be "rewritten"...

Re: Unclosed connection

Posted: Sun Oct 02, 2011 3:55 pm
by angkor_tm
My last version, but Unclose connection still present
Who help plz?
buffer.zip

Re: Unclosed connection

Posted: Mon Oct 03, 2011 12:20 pm
by tukune
:evil: Bad

Re: Unclosed connection

Posted: Mon Oct 03, 2011 12:34 pm
by angkor_tm
I try this

Code: Select all

try :    conn=L2DatabaseFactory.getInstance().getConnection()    xxx = conn.prepareStatement("SELECT ....")    blabla...finally :    L2DatabaseFactory.close(conn)
But --- in console syntax error...
Maybe you help me? =)

Re: Unclosed connection

Posted: Mon Oct 03, 2011 6:00 pm
by Stake
angkor_tm wrote:I try this
try :
    conn=L2DatabaseFactory.getInstance().getConnection()
    xxx = conn.prepareStatement("SELECT ....")
    blabla...
finally :
    L2DatabaseFactory.close(conn)
But --- in console syntax error...
Maybe you help me? =)
That was just a starting example. :)

Re: Unclosed connection

Posted: Mon Oct 03, 2011 7:02 pm
by angkor_tm
I now :shock: , I change all script, but after I have many syntax error.
Example:
Before

Code: Select all

def getclassbuff(id):       conn=L2DatabaseFactory.getInstance().getConnection()    getTipo = conn.prepareStatement("SELECT * FROM buffer_buff_list WHERE buffId=\""+id+"\"")    gt=getTipo.executeQuery()    val = 0    if gt :        gt.next()        try : val = gt.getInt("buff_class")        except : pass    try : L2DatabaseFactory.close(conn)    except : pass    return val
After

Code: Select all

def getclassbuff(id):   try :    conn=L2DatabaseFactory.getInstance().getConnection()    getTipo = conn.prepareStatement("SELECT * FROM buffer_buff_list WHERE buffId=\""+id+"\"")    gt=getTipo.executeQuery()    val = 0    if gt :        gt.next()        try : val = gt.getInt("buff_class")        except : passfinally :        L2DatabaseFactory.close(conn)    except : pass    return val
Where I mistake?

Re: Unclosed connection

Posted: Tue Oct 04, 2011 12:37 am
by tukune