|
Database Pool. (package com.abc.db, dbpool.jar) In order to use database pool you need to replace DriverManager.getConnection(..) to PoolDbManager.getConnection(..) . That is it !!!. You must always close connection. Pool will not close connection it will release that connection for reuse. In order to get best performance you need to open connection only when you need it and close immediately after you used it. You do not need to pass connection object down thru your hierarchy of your objects. Let them open their own connections. Pool will automatically grow/shrink but between of Min/Max amount ( You can change Min/Max from admin servlet). If amount of busy connections exceeds of Max number your request for connection will be put on hold till someone release connection. For different combination of system/user/password PoolDbManager will create new pool. Please note that they are case sensitive. So for user = "george" and user="George" PoolDbManager creates two different pools. "Thread Function" manager. (package com.abc.db dbpool.jar) Often in server application ( in our case pool ) we need to monitor some recourses and perform some action. For example pool must monitor all connections and shrink our grow if he needs to. Usually we are creating daemon thread for this. But let say we have 10 different things to monitor. Then we will flood our system with threads. "Thread function" manager is supposed to solve that problem. It has one thread which will switch between functions. Your monitor must implement Runable interface and call ThreadFuncManager.insert( Runnable run, long m_lDelay, bool bRunImmediately ) to add itself. Then method run will be called each time when m_lDelay milliseconds expires. (Note: it's not guaranteed that it will be called after exactly that time, it could be up to twice that time). To remove monitor function you should call ThreadFuncManager.remove( Runnable run ). Pool administrator. (package com.abc.dbpoolservlet , dbpool.jar) It's a servlet which help you administer DatabasePool. Of course you can always write your own if you do not like this one. You can create new pool or change settings for old one. This servlet is using template package( frankly all my projects are using this package ) so you can change background color (or anything else ) to fit into your web site design. In order to run this servlet you must make prodtemplate.jar ( or devtemplate.jar) available in class path of your JVM. Also com.abc.db( pool itself ) package must be available. In order to setup servlet you must 1. copy txt files to folder, Server must have write permission to that folder. 2. Setup alias Pool ( on your webserver ) to point on com.abc.dbpoolservlet.PoolServlet 3. set parameter TemplatePath for Pool to point on folder where you copied txt files. (like that TemplatePath=C:\DbPoolServlet\Template\). Please note '\' at the end. Sometime you need specify double '\\' instead of '\', it depends from your system. 4. Test it.
If you have any question/problem please use feedback button on http://template.da.ru Thanks. George. |