473,324 Members | 2,456 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,324 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 1771
Oralloy
985 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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.