[odb-users] oracle connection pool cause too many INACTIVE session

Boris Kolpackov boris at codesynthesis.com
Tue Jan 15 07:48:13 EST 2013


Hi,

spiritonly at gmail.com writes:

> I use following code to get database instance for singleton, but when
> i close my exe, there are many INACTIVE sessions in oracle.
>
> [...]
> 
> static odb::database* get(const std::string& user, const std::string&
>                           password, const std::string& dbName)
> {
>   auto_ptr<odb::oracle::connection_factory> connection_pool(new
>     odb::oracle::connection_pool_factory (1, 10));
>   static odb::oracle::database _database(user, password, dbName, 0, 0, 0,
>                                          connection_pool);
>   return &_database;
> }

The arguments you pass to the connection_pool_factory constructor are
invalid. max_connections (the first argument) should be greater or equal
to min_connections (the second argument).

Once this is fixed, the pooled connections will be automatically closed
when the database instance is destroyed, which in your case will happen
automatically if the application terminates normally (i.e., by returning
from main() or by calling exit()).

Boris



More information about the odb-users mailing list