A small problem with unclosed connection

Support for the latest build of L2J Server, get help here with installations, upgrades, problems.
Do not post bugs reports here, use viewforum.php?f=77 instead.
There is no support for other server builds than the official provided by l2jserver.com
Forum rules
READ NOW: L2j Forums Rules of Conduct
Post Reply
Removed20180815
Posts: 93
Joined: Tue Jan 09, 2007 12:41 pm

A small problem with unclosed connection

Post by Removed20180815 »

If you want to receive support we need this info to help you properly.
» Find Revision
L2J Revision: 4524
L2JDP Revision: 7832

I know it has been talked over and over, but pls read :P Well i have a buffer and i get an unclosed connection.I checked all the script and seems fine(after reading alot the forum i closed some conections by myself and recheck everything) BUT i am having problems i think with one function and cant be sure if the connection is closed properly.
This is the function in python:

Code: Select all

 def buildConfigList(section): # getting all available configs            HTML_MESSAGE = HEADER            conn=L2DatabaseFactory.getInstance().getConnection()            getCount = conn.prepareStatement("SELECT COUNT(*) FROM buffer_configuration WHERE section_id=?")            getCount.setString(1,str(section))            act=getCount.executeQuery()            if act :                act.next()                try :                    configCount = act.getString("COUNT(*)")                except :                    configCount = "0"            else :                configCount = "0"            getName = conn.prepareStatement("SELECT section_name FROM buffer_config_sections WHERE section_id=?")            getName.setString(1,str(section))            act=getName.executeQuery()            if act :                act.next()                try :                    sectionName = act.getString("section_name")                except :                    sectionName = "0"            else :                sectionName = "0"            HTML_MESSAGE += sectionName + " Configuration - <font color=\"LEVEL\">"+configCount+"</font> configs<br>"            getList = conn.prepareStatement("SELECT configDesc,configName,configValue FROM buffer_configuration WHERE section_id=? ORDER BY configDesc ASC")            getList.setString(1,str(section))            getConfigList = getList.executeQuery()            while (getConfigList.next()) :                try :                    desc = getConfigList.getString("configDesc")                    name = getConfigList.getString("configName")                    HTML_MESSAGE += "<button value=\""+desc+"\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " viewSelectedConfig "+name+" "+str(section)+" 0\" width=200 height=22 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\">"                except :                    HTML_MESSAGE += "Error loading configuration list...<br>"                    conn.close()            try :                conn.close()            except :                pass            HTML_MESSAGE += "<br><button value=\"Back\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect selectConfigSections 0 0\" width=150 height=22 back=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\" fore=\"L2UI_CT1.Windows_DF_Drawer_Bg_Darker\">"            HTML_MESSAGE += FOOTER            return HTML_MESSAGE 
I think this is the only problem since the rest of the script i checked and i am not sure with this one. So i would rly apreciate if someone can confirm if the connection is closed ok. Thanks and respect.
hope
Posts: 1160
Joined: Thu Aug 30, 2007 5:17 pm

Re: A small problem with unclosed connection

Post by hope »

well if you still get an error then it has not been fixed post error message you are getting now
Removed20180815
Posts: 93
Joined: Tue Jan 09, 2007 12:41 pm

Re: A small problem with unclosed connection

Post by Removed20180815 »

i said in the first post, its the message that shows when there is an unclosed connection. Thanks for reading.
hope
Posts: 1160
Joined: Thu Aug 30, 2007 5:17 pm

Re: A small problem with unclosed connection

Post by hope »

so u dont want help ok have fun
Removed20180815
Posts: 93
Joined: Tue Jan 09, 2007 12:41 pm

Re: A small problem with unclosed connection

Post by Removed20180815 »

bro if you wanna help me, just tell me if the script i posted in the first post has unclosed connections. Thats all. Im not a smart ass its just a simple thing. I didnt print screened the error since is well knowen. In server console it shows the message: Unclosed Connection! And then the long message with python. Its not hard.
Again, if you wanna help me just tell me if the script(function) in the first post has unclosed connection, and if yes how should i close it in that case, since im not sure how to. So if you wanna help you can...
Thank you and respect.
User avatar
jurchiks
Posts: 6769
Joined: Sat Sep 19, 2009 4:16 pm
Location: Eastern Europe

Re: A small problem with unclosed connection

Post by jurchiks »

And then the long message with python.
Copy-paste that damn message here and stop arguing...
If you have problems, FIRST TRY SOLVING THEM YOURSELF, and if you get errors, TRY TO ANALYZE THEM, and ONLY if you can't help it, THEN ask here.
Otherwise you will never learn anything if all you do is copy-paste!
Discussion breeds innovation.
Removed20180815
Posts: 93
Joined: Tue Jan 09, 2007 12:41 pm

Re: A small problem with unclosed connection

Post by Removed20180815 »

Here it is:


Thx and sry...

Edit: The problem is if you create a scheme and dont add a name then you get that unclosed connection. Just tested, i created scheme and didnt put name for scheme, and after that checked the console and boom the error. There was no one on the server only me and did that so its 100% from that.
Here is the create function:

Code: Select all

         if event == "create" :            con=L2DatabaseFactory.getInstance().getConnection()            param = eventParam1.replace("."," ")            if param == "no_name" :                return showText("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(player.getObjectId()))                ins.setString(2, param)                try :                    ins.executeUpdate()                    ins.close()                    con.close()                except :                    pass                try : con.close()                except : pass            return rebuildMainHtml(st) 
Last edited by Removed20180815 on Wed Mar 29, 2017 10:35 pm, edited 1 time in total.
hope
Posts: 1160
Joined: Thu Aug 30, 2007 5:17 pm

Re: A small problem with unclosed connection

Post by hope »

this is what i asked for in the first place was not hard to do
Removed20180815
Posts: 93
Joined: Tue Jan 09, 2007 12:41 pm

Re: A small problem with unclosed connection

Post by Removed20180815 »

i said that the error is common because you don't get anything from it, that's why i didn't posted it in the first place. You don't get where the error is, line or script or anything... that's why i haven't posted it. Anyway i hope now i can get some help... ty
Removed20180815
Posts: 93
Joined: Tue Jan 09, 2007 12:41 pm

Re: A small problem with unclosed connection

Post by Removed20180815 »

well i tried myself to resolve the problem and still cant figure it out. Here is how i tried to close the connection:

Code: Select all

         if event == "create" :            con=L2DatabaseFactory.getInstance().getConnection()            param = eventParam1.replace("."," ")            if param == "no_name" :                try :                    return showText("Info","Please, enter the scheme name!","True","Return","main")                    con.close()                except :                    pass                try : con.close()                except : pass                       else :                ins = con.prepareStatement("INSERT INTO buffer_scheme_list (player_id,scheme_name) VALUES (?,?)")                ins.setString(1, str(player.getObjectId()))                ins.setString(2, param)                try :                    ins.executeUpdate()                    ins.close()                    con.close()                except :                    pass                try : con.close()                except : pass            return rebuildMainHtml(st) 
See the first part after if. There is the problem. If someone tryes to create a scheme and doesnt put name, just press create with no name for scheme then the unclosed connection appears. I tryed to solve it but need some more advanced help.
Thx for your time.
ps: sry for double post, needed a clean post.
User avatar
jurchiks
Posts: 6769
Joined: Sat Sep 19, 2009 4:16 pm
Location: Eastern Europe

Re: A small problem with unclosed connection

Post by jurchiks »

Code: Select all

if event == "create" :    name = eventParam1.replace("."," ")    if name == "no_name" or name == "" :        return showText("Info","Please, enter the scheme name!","True","Return","main")    con=L2DatabaseFactory.getInstance().getConnection()    try :        ins = con.prepareStatement("INSERT INTO buffer_scheme_list (player_id,scheme_name) VALUES (?,?)")        ins.setString(1, str(player.getObjectId()))        ins.setString(2, name)        ins.executeUpdate()        ins.close()    except : pass    try :        L2DatabaseFactory.close(con)    except : pass    return rebuildMainHtml(st)
If you have problems, FIRST TRY SOLVING THEM YOURSELF, and if you get errors, TRY TO ANALYZE THEM, and ONLY if you can't help it, THEN ask here.
Otherwise you will never learn anything if all you do is copy-paste!
Discussion breeds innovation.
Removed20180815
Posts: 93
Joined: Tue Jan 09, 2007 12:41 pm

Re: A small problem with unclosed connection

Post by Removed20180815 »

pff thx alot mate. How didn't i think of moving the connection after the check...:) Thx alot works like a charm.
Post Reply