Database resource pooled connections

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

Database resource pooled connections

#1

Postby Segi » Tue May 12, 2015 5:02 pm

My application retrieves information about an eBase database connection resource:

Code: Select all

if (system.getDatabaseConnection(connection).getMetaData().driverName.indexOf("MySQL") != -1) {
...
}
It seems that every time that this line in my script runs, it uses up a pooled connection because after a little while, I get an error that no more connections are available for that resource.

Is that a correct assumption ? If it is, why would it use a pooled connection even when I am not actually using this database resource to run any kind of query.
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#2

Postby Jon » Tue May 12, 2015 5:36 pm

Yes, that's a correct assumption, it's returning you a database connection because you've asked for one! You have to always make sure that you close a database connection after you've finished with it regardless of what you use it for, as described in the javadoc for system.getDatabaseConnection().

Code: Select all

var con = system.getDatabaseConnection(connection);
try {
   if (con.getMetaData().driverName.indexOf("MySQL") != -1) {
      ...
   } 
}
finally {
   if (con) con.close();
}
0 x


Who is online

Users browsing this forum: No registered users and 21 guests