What happens when all the connections in the pool are in use i.e. if the max
size of the pool is set to 5 in weblogic properties and there are 5 client
programs that are using the DB at the same time.
Will the next client requesting a connection block until a connection
becomes available or will they get an error/exception ?
The documentation on database connection pools in weblogic properties makes
no mention of this.
Regards
Lawrence Lourduraj
VocaLoca Inc.
I don't know anything about your ConnectionManager class.
Can you give it a try with our pool driver or mssql driver and let's see if that makes any difference.
Here is the code snippet to replicate your problem and as soon as i
hit max connections,
i always end up with resource unavailable exception
<%
Driver myDriver = (Driver) Class.forName("weblogic.jdbc.mssqlserver4.Driver").newInstance();
Connection conn1 = DriverManager.getConnection("jdbc:weblogic:pool:sqlPool",
null);
out.println("1st connection");
Connection conn2 = DriverManager.getConnection("jdbc:weblogic:pool:sqlPool",
null);
out.println("2nd connection");
Connection conn3 = DriverManager.getConnection("jdbc:weblogic:pool:sqlPool",
null);
out.println("3rd connection");
Connection conn4 = DriverManager.getConnection("jdbc:weblogic:pool:sqlPool",
null);
out.println("4th connection");
Connection conn5 = DriverManager.getConnection("jdbc:weblogic:pool:sqlPool",
null);
out.println("5th connection");
%>
My pool definition:::
weblogic.jdbc.connectionPool.sqlPool=\
url=jdbc:weblogic:mssqlserver4,\
driver=weblogic.jdbc.mssqlserver4.Driver,\
initialCapacity=1,\
maxCapacity=4,\
capacityIncrement=1,\
loginDelaySecs=3,\
allowShrinking=true,\
shrinkPeriodMins=15,\
refreshMinutes=1,\
refreshTestMinutes=1,\
testTable=ejbAccounts,\
testConnsOnReserve=true,\
testConnsOnRelease=true,\
props=user=sa;password=;server=cyrus
weblogic.allow.reserve.weblogic.jdbc.connectionPool.sqlPool=everyone
Thanks,
-Kumar
Lawrence Lourduraj wrote:
Kumar:Thanks for your prompt reply.
We did a very simple test as follows in our JSP,
<%
ConnectionManager cm1 = new ConnectionManager ();
java.sql.Connection c1 = cm1.getConnection ();ConnectionManager cm2 = new ConnectionManager ();
Connection c2 = cm2.getConnection ();ConnectionManager cm3 = new ConnectionManager ();
Connection c3 = cm3.getConnection ();ConnectionManager cm4 = new ConnectionManager ();
Connection c4 = cm4.getConnection ();ConnectionManager cm5 = new ConnectionManager ();
Connection c5 = cm5.getConnection ();ConnectionManager cm6 = new ConnectionManager ();
Connection c6 = cm6.getConnection ();%>
ConnectionManager is a user defined class that manages our DB connections
and we call its "getConnection ()" whenever we need a connection. We
expected the JSP to hang indefinitely or get some kind of error/exception
since our pool size is 5. But the page loaded in the browser right away
without any problems.We are using WebLogic 4.5.1 with MS SQL 7.0
Could it be that the pool max in WebLogic properties is just the initial max
and then it increases the pool by the increment size until it runs out of
connections ?--
Regards
Lawrence Lourduraj
VocaLoca Inc.
Kumar Allamraju <kumar.a...@beasys.com> wrote in message
news:3914AB4C...@beasys.com...
>
>
> Lawrence Lourduraj wrote:
>
> > Friends,
> >
> > What happens when all the connections in the pool are in use i.e. if the
max
> > size of the pool is set to 5 in weblogic properties and there are 5
client
> > programs that are using the DB at the same time.
> >
>
> Hi Lawrence,
>
> You will get resource exception, such as
> Exception in thread "main" java.sql.SQLException:
> weblogic.common.ResourceException: No resources available.
>
> -Kumar
by default: If all the pool connections are in-use at the time, and the pool has
grown to its maximum size, the client will hang indefinitely until some user frees
up a pool connection, at which time the waiting client will get it. The client can
alter this behavior by setting a connection property to have it hang a maximum
of XX seconds before either getting a connection or an exception stating the
pool is too busy.
If your client is a serverside class, such as a servlet, EJB, JSP etc, it will be
using the pool driver or the jts driver (DataSources will use these under the
covers). Because there are a fixed number of execute threads in the server
we do not want a client to hang indefinitely waiting for a pool connection,
and furthermore, JavaSoft decided to make numerous DriverManager calls
class synchronized, so if you use them to get a connection and they cause a
wait, *all other threads doing JDBC* may be halted, even those with a
working connection, because drivers log info and exceptions using DriverManager.
println(), also class-synchronized. Therefore, by default, our poo driver will
wait a maximum of 5 seconds before either getting a freed-up connection or
throwing an exception.
To more fully address this issue for EJBs, our jts driver will return a connection
object instantly, always, to prevent DriverManager calls from waiting. However,
we defer getting the underlying pool connection till the first JDBC call made on
the connection object. Therefore whatever JDBC call it is, may hang for that
5 seconds, then maybe get the exception mentioned above. At least it is only the
one thread that will wait.
Lawrence Lourduraj wrote:
> Friends,
>
> What happens when all the connections in the pool are in use i.e. if the max
> size of the pool is set to 5 in weblogic properties and there are 5 client
> programs that are using the DB at the same time.
>
> Will the next client requesting a connection block until a connection
> becomes available or will they get an error/exception ?
>
> The documentation on database connection pools in weblogic properties makes
> no mention of this.
>
> Regards
>
> Lawrence Lourduraj
>
> VocaLoca Inc.
--
PS: Folks: BEA WebLogic is in S.F., and now has some entry-level positions for
people who want to work with Java and E-Commerce infrastructure products. Send
resumes to j...@beasys.com
--------------------------------------------------------------------------------
The Weblogic Application Server from BEA
JavaWorld Editor's Choice Award: Best Web Application Server
Java Developer's Journal Editor's Choice Award: Best Web Application Server
Crossroads A-List Award: Rapid Application Development Tools for Java
Intelligent Enterprise RealWare: Best Application Using a Component Architecture
http://weblogic.beasys.com/press/awards/index.htm
Thanks for your very helpful reply.
My client is a server side class and is using the jts driver to connect to
the pool and we see the behavior exactly as you described. However is there
a way a server side client can wait for a user defined time (or infinite) to
get a connection while using a jts or pool driver perhaps by using a t3
driver ? If not can I wait until I get a connection by some other means ?
what are BEA's recommendations for being able to satisfy all connection
requests. I understand that I can increase the pool size but there is a
limit to it and we can have many simultaneous visitors to our web site.
Also please tell me where I can find documentation on setting the wait time
for external clients ? general and API info on Weblogic JDBC ?
Finally is there an API to access the weblogic properties in my server side
classes without having to read the WebLogic properties file.
Many Thanks
My pool in weblogic properties,
weblogic.jdbc.connectionPool.lawrDB=\
url=jdbc:weblogic:mssqlserver4:lawr@lawrence:1433,\
driver=weblogic.jdbc.mssqlserver4.Driver,\
loginDelaySecs=2,\
initialCapacity=1,\
maxCapacity=5,\
capacityIncrement=1,\
allowShrinking=true,\
shrinkPeriodMins=5,\
testTable=testTable,\
refreshTestMinutes=10,\
testConnsOnReserve=true,\
testConnsOnRelease=true,\
props=user=guest;password=guest;server=lawrence;\
weblogic.allow.reserve.weblogic.jdbc.connectionPool.lawrDB=everyone
weblogic.allow.reset.weblogic.jdbc.connectionPool.lawrDB=everyone
weblogic.allow.shrink.weblogic.jdbc.connectionPool.lawrDB=everyone
code to get and use the connection,
java.sql.Connection c1 = DriverManager.getConnection
("jdbc:weblogic:jts:lawrDB");
java.sql.Statement s1 = c1.createStatement ();
s1.executeUpdate ("insert into table1 values ('a', '123456789', '1/1/1960',
1)");
--
Regards
Lawrence Lourduraj
VocaLoca Inc.
Joseph Weinstein <j...@weblogic.com> wrote in message
news:39185820...@weblogic.com...