aspose file tools*
The moose likes JDBC and the fly likes increase database connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "increase database connection" Watch "increase database connection" New topic
Author

increase database connection

santhosh kumar vk
Ranch Hand

Joined: Aug 25, 2009
Posts: 146
hi

I am developing web application using struts and also using database in my product I have defined 15 connection,
In runtime how to increase more than 15 connection.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42635
    
  65
How have you "defined" 15 connections - are you using a connection pool? In that case, just give it a larger maximum size (maybe 50), and the pool will automatically use more connections as needed.


Ping & DNS - my free Android networking tools app
santhosh kumar vk
Ranch Hand

Joined: Aug 25, 2009
Posts: 146
it will take automatically or we have to do it manually to increase the connection(i.e if we give max 50) using connection pool
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42635
    
  65
That depends on how the pool is set up, and you haven't told us how that's done. Are you doing that in code of yours, or are you using a pool that's predefined by the servlet container? If the former, which libraray are you using? If the latter, which container are you using?
santhosh kumar vk
Ranch Hand

Joined: Aug 25, 2009
Posts: 146
I am using the following code


drivers=oracle.jdbc.driver.OracleDriver
logfile=dbpool.log

pool.url=jdbcracle:thin:@myHost.myDomain:1521:test
pool.user=b_lightyear
pool.password=BeyondInfinity
pool.maxpool=10
pool.maxconn=30
pool.expiry=180
pool.validator=snaq.db.Select1Validator

here is the maximum connection is 30 how to handle 31 request and also a new doubt if we are using 30 connection after some time one connection is free, the container how will it know free connection then it assigned to new request.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42635
    
  65
here is the maximum connection is 30 how to handle 31 request and also a new doubt if we are using 30 connection after some time one connection is free, the container how will it know free connection then it assigned to new request.

Please get into the habit of using punctuation; it's really hard to follow your writing without it.

Depending on the inner workings of the connection pool and the servlet container, the request may either get rejected or it may have to wait until a connection becomes available. Using a larger pool size isn't necessarily the best answer if the DB is already handling 30 requests, though. Making the client waiting may be better in order not to swamp the DB.
santhosh kumar vk
Ranch Hand

Joined: Aug 25, 2009
Posts: 146
please give me example to create database connection using connection pool to make dynamically increase connection
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42635
    
  65
Connection pools *do* dynamically increase the pool size, but not beyond the limit given in the setup. That's a good thing, because opening ever more connections will just hog the DB. Either your code isn't correctly returning the connections to the pool, or there are many long-running DB jobs (in which case opening more connections isn't a smart thing to do - the DB is likely already overloaded).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: increase database connection