Database connection pooling in ROSDK


(Bob Murdoch) #1

We have a SOAP service in ROSDK. Each session creates a connection to a database, runs queries, and returns the results. There is a built-in delay, therefore, on every request as the database connection is established.

How can I create a “session pool” or “database connection pool” in order to have already-established connections that can be reused for each new request? The solution, of course, has to take into account whether all pooled connections are in use when a new session is started, and either expand the connection pool or wait.

It appears this is available in Data Abstract, but we are using ROSDK.

(EvgenyK) #2


you can have some dictionary like TDictionary<connection_string, TList<connection_object>> where you can store your connections for reusing.
when correspondent connection is detected, it will be removed from correspondent TList and after using, it will be added into correspondent TList.

(Bob Murdoch) #3

Thank you Evgeny. It appears there is no ROSDK built in method to handle this, so we would need to roll our own.

This may be a stupid question - we own DataAbstract as well, but for our internal application server that our client app connects to.

Is it possible to build a SOAP service with DataAbstract that would be exactly like the service we have now in ROSDK, but in order to take advantage of connection pooling?

I’d rather spend time on application features than architectural ones.

(EvgenyK) #4

Yes, it is possible.
In minimal configuration, you should drop DriverManager and ConnectionManager to server datamodule, relink them and specify connection string.

in your code you can get connection with ConnectionManager.NewConnection().
for getting native TCustomConnection instance, you can use code like

//dacon: IDAConnection;
cc := TCustomConnection((dacon as IDAConnectionObjectAccess).ConnectionObject);