DB Connection

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

Oleg_79
Posts: 161
Joined: 25 Feb 2011, 10:31
Location: Ukraine, Donetsk

DB Connection

Postby Oleg_79 » 28 Dec 2017, 10:04

Hi!
When I get db connection from DbManager i need close them or no?

Code: Select all

Connection connection = getParentExtension().getParentZone().getDBManager().getConnection();

...

if (connection != null)
    try{connection.close();}catch (SQLException ignored){}
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: DB Connection

Postby Lapo » 30 Dec 2017, 08:34

Hi,
yes absolutely. Not closing the connection will cause resource leaking.
Take a look at the example here:
http://smartfoxserver.com/blog/custom-l ... -database/

In particular the "Handling Exceptions" section.

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 32 guests