4

I'm searching for information on database connectivity (Firebird in my case) with IntraWeb Applications.

I especially need to know the difference(s) involved in using the database on the TDataModule with LockDataModule function, or using the database on the UserSessionUnit. For example i need to have the database totally disconnected if no users are using the server, and at most 30 users will be connected.

I may at worst have to connect to some old paradox Database and i need a structure that could handle that (i know that i'll have to generate a folder based on WebApplication.AppID to handle sessions). At worst...

Thanks in advance for any piece of information or useful links you could provide me ^^

mjn
  • 36,362
  • 28
  • 176
  • 378
Darkendorf
  • 463
  • 11
  • 28
  • 1
    Does an IntraWeb session have no lifecycle methods (OnSessionEnd) which can be used to disconnect from the database server? – mjn Jan 12 '12 at 15:43

2 Answers2

6

Scenario 1 - You leave "Pool Data Connections" unchecked in the Intraweb Application Wizard

In this scenario the wizard creates a ServerController, a UserSession but not a DataModule. You place your database, session and dataset components on the UserSession.

Whenever a new user connects to your website a new instance of the UserSession is created and a connection to the database is made. When the ServerController.SessionTimeOut expires due to user inactivity the UserSession is destroyed and that particular connection to the database is severed.

For 30 concurrent users this model will probably be fine for you and should guarantee that all database connections will be severed when the website is not in use.

Scenario 2 - You check "Pool Data Connections" in the Intraweb Application Wizard

As well as the ServerController and the UserSession the wizard will create an empty DataModule. You place your database, session and dataset components on the DataModule.

The ServerModule has a TIWDataModulePool component on it which has PoolCount property.

When your application starts it creates PoolCount instances of the DataModule each one of which makes a connection to the database. As your pages require database access they call LockDataModule and UnlockDataModule to temporarily make use of one of the DataModule instances from the pool.

When your application closes the DataModule instances in the pool are destroyed and their connections to the database are closed.

This model is appropriate when having an open database connection per user would exceed the capabilities of your database server. For just 30 users connecting to a FireBird database I don't believe it would be required.

Community
  • 1
  • 1
LachlanG
  • 4,047
  • 1
  • 23
  • 35
  • Re: "When your application closes ... connections to the database are closed" - does "application" also mean "web app user session" for IntraWeb? – mjn Jan 13 '12 at 10:28
  • mjn - no it doesn't. User sessions are independent from the application. – LachlanG Jan 13 '12 at 20:37
  • Is there a way to configure a maximum DataModule lifetime for unused DataModule pool entries? As some databases can get a hiccup if connections / transactions are open for a long time. For these databases they should be closed after a while (and can be reinstantiated again immediately) – mjn Jan 14 '12 at 15:43
  • There is a TIWDataModulePool.Active property if set to False causes the DataModules to be freed. You'd have to code in the scheduling yourself. – LachlanG Jan 14 '12 at 21:17
  • This is the best description on Pool Data Connections i found on the web. Much better than the one on the dr Bob's book i am reading, because you say "This model is appropriate when having an open database connection per user would exceed the capabilities of your database server", that is in fact the key point to understand. – UnDiUdin Apr 16 '14 at 13:03
0

You may want to consider using a component set like kbmMW by http://www.components4programmers.com/ I have used this for years with Desktop apps ans now with IW apps. I deploy my apps as Services and currently having a few issues deploying as an ISAPI. kbmMW is well suited for an app with lots of connections as it offers connection pooling etc... It has many features and benefits. Check out site for yourself.

I use the Enterprise version, though I think the free version may be useful to you.

Cheers!

-Lou

Lou
  • 1
  • 1
    thanks for sharing your products, datasnap seems perfect for my new developments, but if you can give me some differences between this and delphi xe2 datasnap i'll give it a try. – Darkendorf Jun 27 '12 at 08:24