DB, Sessions and Persistence with IntraWeb 12 in Delphi XE2

3.9k views Asked by At

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 ^^

2

There are 2 answers

5
LachlanG On BEST ANSWER

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.

1
Lou On

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