473,419 Members | 1,647 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,419 software developers and data experts.

server.xml:has to do anything with database access pools

reviewing tomcat 6 server.xml found this:
Expand|Select|Wrap|Line Numbers
  1. <!--
  2.     <Connector executor="tomcatThreadPool"
  3.                port="8080" protocol="HTTP/1.1" 
  4.                connectionTimeout="20000" 
  5.                redirectPort="8443" />
  6.     -->  
has to do anything with database access pools? to work such must uncomment this? what else uncomment?
Aug 24 '10 #1
5 1777
Oralloy
988 Expert 512MB
Perhaps you should look it up in the documentation.

What's your real problem?
Aug 24 '10 #2
I am unable run ready made textbook code about db pools...although mysql db file.sql run success... and run SELECT success...

for pools is needed special mysql ds driver or config in xml server files?
Aug 24 '10 #3
chaarmann
785 Expert 512MB
Do you mean database connection pools? That is storing the old database connection for re-use and high performance after you made your SQL-inquiry?
That has nothing to do with the database type itself, like Oracle or MySql, and if you program it, you don't need any database-specific driver or XML-entries. I have done it in just just a few lines of plain java code, deriving this class from a common object-pool-class I wrote.
Aug 25 '10 #4
"common object-pool-class I wrote" can you post it here?
Aug 25 '10 #5
chaarmann
785 Expert 512MB
Of course I could simply list my complete code here, but I am here to help and not sell my code for free. Spoonfeed-code will not help you at all, because you would not understand all the problems and solutions I went through while developing it. We are not at rentACoder.com, so it's the other way around here: You list the code you have programmed so far, and we are here to help if you are stuck or tell you how to make it better.

As a favor, and to give you a head-start, I will tell you the concept:

A pool is a storage where you store your DB-connections. You can borrow a connection from the pool and after usage you give it back to the pool. For a single thread, there is no problem and you only have one connection at all in the pool. But for multiple threads you need more. For example the first thread borrows one, then the second thread borrows another one (the pool just creates a new one, opens it and and gives it back, because the first one is still in use). Then the first thread gives back its connection. Then a third thread borrows one (the pool just returns the connection the first thread had used before). Then the third and second thread give back the connections. (the pool ends up with 2 unused connections). That's all easy to implement, but the complicated part is the timeout: if a connection is not used for a long time or is not returned, it should be closed and the object should be destroyed. Here you have to deal with concurrent threads and synchronization.

Here is the schema:

Expand|Select|Wrap|Line Numbers
  1.  public class ConnectionPool extends ObjectPool
  2. {
  3.     public Connection borrowConnection()
  4.     {
  5.         // check-out a connection from pool with:  return (Connection) super.checkOut();
  6.     }
  7.     public returnConnection(Connection c)
  8.     {
  9.         // check-in a connection back into pool with: super.checkIn(c);
  10.     }
  11.     private ConnectionPool()
  12.     {
  13.         // read driverName, url, username, password from configuration file (or pass them as parameter of this constructor) and store them in local variables.
  14.         // register driver with: DriverManager.registerDriver(...)
  15.     }
  16.     Object create()
  17.     {
  18.         // return a new connection with DriverManager.getConnection(url, username, password)
  19.     }
  20.     boolean validate(Object o)
  21.     {
  22.         // return true/false if a connection is opened/closed
  23.     }
  24.     expire(Object o)
  25.     {
  26.         // close connection
  27.     }
  28. }
  29.  
Now the ObjectPool:
Expand|Select|Wrap|Line Numbers
  1.  public abstract class ObjectPool
  2. {
  3.     private final Hashtable pool = new Hashtable() // stores object as key and creation time, unused-status and additional info as value
  4.  
  5.     abstract Object create();
  6.     abstract validate(Object o);
  7.     abstract expire(Object o);
  8.  
  9.     ObjectPool()
  10.     {
  11.         // create CleanUpThread(this);
  12.         // start cleanUpThread
  13.     }
  14.     public void finalize()
  15.     {
  16.         // stop cleanUpThread
  17.     }
  18.     synchronized Object checkOut()
  19.     {
  20.         // get an unused object from pool. It also should still be valid, (for example a connection that was not closed by external database), by calling validate().  If there is none, create one calling create(). Return it and mark it as used.
  21.     }
  22.     synchronized void checkIn(Object o)
  23.     {
  24.         // mark corresponding object in pool as unused.
  25.     }
  26.     synchronized void cleanUp()
  27.     {
  28.         // This function will be called by the cleanupThread. It goes through all objects inside the pool and removes the timed-out and invalid ones.
  29.     }
  30. }
  31.  
Now the CleanupThread:
Expand|Select|Wrap|Line Numbers
  1.  class CleanUpThread extends Thread
  2. {
  3.     CleanUpThread(ObjectPool pool)
  4.     {
  5.         // continue to run even if current parent thread was detroyed, by this.setDaemon(true)
  6.     }
  7.     public void run()
  8.     {
  9.         // do in a loop until stopped: sleep for 10 seconds with sleep(1000 * 10), then wake up and call pool.cleanUp()
  10.     }
  11.  
  12. }
  13.  
Aug 26 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Bob Murdoch | last post by:
I'm using IIS on W2k, using ODBC access to the database (which is on the same server as IIS). The system is designed to generate reports from users after they have walked thru a few pages,...
1
by: Ron L | last post by:
I am trying to setup a solution that will include a client which will access a database via remoting calls. I am hosting my remoting project in IIS, and am using Windows Integrated security. ...
2
by: Szaki | last post by:
Hello, I have a some xml file and database. How import this file to database? I must do aplication in VB .NET whose show imports some xml file to database SQL SERVER 2000? Do you have any idea?...
1
by: Arjen | last post by:
Hello, If I choose to use a database then I need to use multiple tables. With a XML file I can select "my objects" as once. I think that there will be around 10.000 records (objects). I want...
9
by: Steven Ung | last post by:
Hello all, I'm having the following error dump from an ASP.net application. The program is to calculate MRP and it involves complex queries looping thru hundreds of records in an few SQL 2000...
4
by: Shawn H. Mesiatowsky | last post by:
I have a strange problem here. I have my development computer with IIS installed, and we have a SQL server as well on a windows 2000 server. both are members of a domain. I have restricted access...
4
by: geodev | last post by:
I have developed a small application using ASP.NET and VB.NET on my development machine it works great. When I copy across the files manually to my test machine and create a Virtual Directory all...
2
by: | last post by:
Dear Groups, I am trying to develop a simple client <-> server application where (for database security reasons) the server only has access to the centralised database (and a file repository),...
3
by: sammyloo | last post by:
Hi all, I'm experiencing a problem using ASP.NET web services to access a different server with SQL Server 2000 database. And I get the error of the following Exception Details:...
3
hariharanmca
by: hariharanmca | last post by:
Subject : I want to Connect Flash with Database ('Access' or 'Sql Server' or some Idea). My tool is to create a form desigen (Login Register) in flash and connect it to database. It will...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.