» Find Revision
L2J Revision Number: 4422
L2JDP Revision Number: 7669
Hi all,
I'm a developer and I'm almost new to L2J. I would like to write some simple mods and scripts in order to learn more about the L2J system.
While i was looking for documentation, I found a lot of posts about "unclosed SQL connections" and I started to worry about them. I would like to write good code, so may you tell me what is the right way to connect to the database and close everything without any error? (both for java and python)
Here is a simple scheme of what I'm currently using, is it right?
Java scheme:
The main question is about the line 12... which one is the right close() method?
Code: Select all
try { con = L2DatabaseFactory.getInstance().getConnection(); statement = con.prepareStatement("SQL QUERY"); rset = statement.executeQuery(); // ANY NEEDED OPERATION} catch (SQLException e) { // HANDLE EXCEPTIONS} finally { try { con.close(); // OR L2DatabaseFactory.close(con)???? statement.close(); rset.close(); } catch (Exception e) { // HANDLE EXCEPTIONS }}
Here is an example posted by ThE_PuNiSheR: viewtopic.php?f=46&t=18071&p=95665&hili ... %3A#p96989
Thanks for all your great work!