Archived

This forum has been archived. Please start a new discussion on GitHub.

How to use the built-in database connection?

I read eric.hill's reply on http://www.zeroc.com/forums/help-center/2880-where-do-new-developers-start.html. This is the solution I have found ever,but I'm a newbie on Ice and OTL, I want to know the details how to use the Ice built-in thread pool instead of creating my own thread pool for database connections. Can anyone give me some code snippet or a demo project?

I very appreciate for it.

Comments

  • matthew
    matthew NL, Canada
    The Ice built in thread pool is not a general purpose thread pool. It is used for dispatching requests on servants, AMI callbacks and AMD invocations. I'm afraid that if you need a thread pool for your database connections, you'll need to do that yourself.
  • If I create servant evictor to access database directly and not use database connection pool, is it feasible?
  • benoit
    benoit Rennes, France
    Hi,

    You can implement a servant locator like the Freeze evictor that uses OTL instead. The calls on the servant locator will be dispatched from threads of the Ice thread pool.

    If OTL database connections can't be used concurrently by multiple threads (which is likely) you will have to either implement a pool of database connections (if this isn't already provided by OTL) or setup one database connection per thread (you can use the Ice::ThreadHook callbacks for this purpose, see here in the Ice manual for more information).

    You can checkout the demos from the demo/Ice/database directory for some examples on how to use Ice with an SQL database (Oracle in the demos).

    Cheers,
    Benoit.
  • Thanks,Benoit.

    Yes,OTL does not support multiple threads and does not provide db connections pool. I must create a pool of db connections by myself. I think when I use one database connection per thread,has it an high performance or scalability? How to control the maximum number of thread connecting to database, which property represent it in server's configuration file?

    One more question: I checked my ice install(3.3.1 for windows) directory,and can not find demo/ice/database,I think this demo maybe important for me, Can you give me a web link for downloading it?
  • benoit
    benoit Rennes, France
    Sorry, the directory I gave you was wrong, the database examples are located in the C:\Ice-3.3.1\demo\Database directory.

    If you choose to create one database connection per thread, the number of connections will depend on the number of threads configured for your Ice server thread pool. By default, the server thread pool has a fixed size of 1 thread. This can be configured with the Ice thread poool properties. See also here for more information on the Ice threading model.

    Cheers,
    Benoit.
  • Hi,Benoit.

    I could not find C:\Ice-3.3.1\demo\Database directory.
    I find C:\Ice-3.3.1-VC90\demo\Freeze\customEvictor directory.
    It has CurrentDatabase.h and CurrentDatabase.cpp, but it seem using Berkeley DB not Oracle.

    Where is the oracle demo ?
  • benoit
    benoit Rennes, France
    Ok, the Database demos are not supported with the VC90 distribution, they are only supported with the VC80 distribution (installed by default in C:\Ice-3.3.1). This should be mentioned in the C:\Ice-3.3.1-VC90\README file.

    You should either download and install the Visual Studio 2005 binaries or if you just want to take a look at the demos, you can also download the demo archive from our download page here.

    Cheers,
    Benoit.
  • I find it.
    Thanks for Your Appreciation!