Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Creating and using a connection pool

2 views
Skip to first unread message

gga

unread,
Jun 4, 2001, 11:17:54 AM6/4/01
to
Hi

I am just learning about WL (v6sp1) and am at leat a few weeks away from
being sdent to an Admin class. I have a set up simple JSP which I have
successfully used to access an Oracle database using the Oracle Thin driver.

I now wnat to try to do this using a connection pool for the next step in
our prototyping process. Is this as simple as setting up a JDBC connection
pool using the same driver via the WL Console and making some changes to the
JSP? Or must I create DataSources as well? I have not completely grasped a
good understanding from the documentation as to what is required for the
connection pool, and what is optional.

A nudge in the right direction would be greatly appreciated.

Thanks.
Gary


Sree Bodapati

unread,
Jun 4, 2001, 11:27:17 AM6/4/01
to
Yes its as simple but you will be using the WebLogic pool driver instead.
There are other ways as well you should refer to weblogic documentation on
how to access database at

http://e-docs.bea.com/wls/docs60/servlet/progtasks.html#171619

after you setup the pool heres the way you can access the pool from your
jsp.


// Begin jsp example
<!doctype html public "-//w3c/dtd HTML 4.0//en">

<!-- Copyright (c) 1999-2000 by BEA Systems, Inc. All Rights Reserved.-->

<html>
<head>
<title>Simple Select</title>
</head>
<body bgcolor=#FFFFFF>
<p><img src="images/BEA_Button_Final_web.gif" align=right>
<H1>Simple Select</h1>
<p>

<%@ page import="
java.io.*,
java.sql.*,
javax.servlet.*,
javax.servlet.http.*,
java.util.Properties,
weblogic.db.jdbc.*
"%>

<%
Connection conn = null;
try {

Class.forName("weblogic.jdbc.pool.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:weblogic:pool:mySQLpool", null);
// substitute mySQLpool with what ever pool name you created in WLS

Statement stmt = null;
ResultSet rs = null;

stmt = conn.createStatement();
rs = stmt.executeQuery("select * from test1");

%>

<%
while (rs.next()) {
out.println(rs.getString("myname"));
%>


<%
}
%>

<%
}
catch (Exception e){
out.print("Connection Failed" + e.getMessage());
}
finally {
if(conn != null)
try{
conn.close();
} catch (Exception e){
out.print("Exception:" + e);
}
}
%>

<p>
<font size=-1>Copyright (c) 1999-2000 by BEA Systems, Inc. All Rights
Reserved.
</font>

</body>
</html>

//End jsp example.

"gga" <gary...@yahoo.com> wrote in message
news:3b1b...@newsgroups.bea.com...

gga

unread,
Jun 5, 2001, 9:14:05 AM6/5/01
to
Well..I guess it wasn't THAT simple <gr>. I suspect I'm maybe missing
something in my PATH or CLASSPATH? Here's what I get when I start the
server:

####<Jun 4, 2001 3:32:44 PM EDT> <Error> <JDBC Connection Pool> <WIN2000IIS>
<myserver> <main> <system> <> <000000> <Cannot startup connection pool
"njprotoPool" weblogic.common.ResourceException:
Could not create pool connection. The DBMS driver exception was:
java.sql.SQLException: Io exception: SO Exception was generated
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:114)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:156)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:269)
at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:210)
at
oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:251)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:224)
at
weblogic.jdbc.common.internal.ConnectionEnvFactory.makeConnection(Connection
EnvFactory.java:155)
at
weblogic.jdbc.common.internal.ConnectionEnvFactory.createResource(Connection
EnvFactory.java:114)
at
weblogic.common.internal.ResourceAllocator.makeResources(ResourceAllocator.j
ava:649)
at
weblogic.common.internal.ResourceAllocator.<init>(ResourceAllocator.java:243
)
at
weblogic.jdbc.common.internal.ConnectionPool.startup(ConnectionPool.java:322
)
at weblogic.jdbc.common.JDBCService.addDeployment(JDBCService.java:91)
at
weblogic.management.mbeans.custom.DeploymentTarget.addDeployment(DeploymentT
arget.java:283)
at
weblogic.management.mbeans.custom.DeploymentTarget.addDeployments(Deployment
Target.java:233)
at
weblogic.management.mbeans.custom.DeploymentTarget.updateServerDeployments(D
eploymentTarget.java:194)
at
weblogic.management.mbeans.custom.DeploymentTarget.updateDeployments(Deploym
entTarget.java:158)
at java.lang.reflect.Method.invoke(Native Method)
at
weblogic.management.internal.DynamicMBeanImpl.invokeLocally(DynamicMBeanImpl
.java:562)
at
weblogic.management.internal.DynamicMBeanImpl.invoke(DynamicMBeanImpl.java:5
48)
at
weblogic.management.internal.ConfigurationMBeanImpl.invoke(ConfigurationMBea
nImpl.java:285)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1555)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
at weblogic.management.internal.MBeanProxy.invoke(MBeanProxy.java:437)
at weblogic.management.internal.MBeanProxy.invoke(MBeanProxy.java:178)
at $Proxy27.updateDeployments(Unknown Source)
at
weblogic.management.configuration.ServerMBean_CachingStub.updateDeployments(
ServerMBean_CachingStub.java:2299)
at
weblogic.management.mbeans.custom.ApplicationManager.startConfigManager(Appl
icationManager.java:240)
at
weblogic.management.mbeans.custom.ApplicationManager.start(ApplicationManage
r.java:122)
at java.lang.reflect.Method.invoke(Native Method)
at
weblogic.management.internal.DynamicMBeanImpl.invokeLocally(DynamicMBeanImpl
.java:562)
at
weblogic.management.internal.DynamicMBeanImpl.invoke(DynamicMBeanImpl.java:5
48)
at
weblogic.management.internal.ConfigurationMBeanImpl.invoke(ConfigurationMBea
nImpl.java:285)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1555)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
at weblogic.management.internal.MBeanProxy.invoke(MBeanProxy.java:437)
at weblogic.management.internal.MBeanProxy.invoke(MBeanProxy.java:178)
at $Proxy20.start(Unknown Source)
at
weblogic.management.configuration.ApplicationManagerMBean_CachingStub.start(
ApplicationManagerMBean_CachingStub.java:435)
at weblogic.management.Admin.startApplicationManager(Admin.java:1030)
at weblogic.management.Admin.finish(Admin.java:491)
at weblogic.t3.srvr.T3Srvr.start(T3Srvr.java:429)
at weblogic.t3.srvr.T3Srvr.run(T3Srvr.java:170)
at weblogic.Server.main(Server.java:35)

at
weblogic.jdbc.common.internal.ConnectionEnvFactory.makeConnection(Connection
EnvFactory.java:169)
at
weblogic.jdbc.common.internal.ConnectionEnvFactory.createResource(Connection
EnvFactory.java:114)
at
weblogic.common.internal.ResourceAllocator.makeResources(ResourceAllocator.j
ava:649)
at
weblogic.common.internal.ResourceAllocator.<init>(ResourceAllocator.java:243
)
at
weblogic.jdbc.common.internal.ConnectionPool.startup(ConnectionPool.java:322
)
at weblogic.jdbc.common.JDBCService.addDeployment(JDBCService.java:91)
at
weblogic.management.mbeans.custom.DeploymentTarget.addDeployment(DeploymentT
arget.java:283)
at
weblogic.management.mbeans.custom.DeploymentTarget.addDeployments(Deployment
Target.java:233)
at
weblogic.management.mbeans.custom.DeploymentTarget.updateServerDeployments(D
eploymentTarget.java:194)
at
weblogic.management.mbeans.custom.DeploymentTarget.updateDeployments(Deploym
entTarget.java:158)
at java.lang.reflect.Method.invoke(Native Method)
at
weblogic.management.internal.DynamicMBeanImpl.invokeLocally(DynamicMBeanImpl
.java:562)
at
weblogic.management.internal.DynamicMBeanImpl.invoke(DynamicMBeanImpl.java:5
48)
at
weblogic.management.internal.ConfigurationMBeanImpl.invoke(ConfigurationMBea
nImpl.java:285)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1555)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
at weblogic.management.internal.MBeanProxy.invoke(MBeanProxy.java:437)
at weblogic.management.internal.MBeanProxy.invoke(MBeanProxy.java:178)
at $Proxy27.updateDeployments(Unknown Source)
at
weblogic.management.configuration.ServerMBean_CachingStub.updateDeployments(
ServerMBean_CachingStub.java:2299)
at
weblogic.management.mbeans.custom.ApplicationManager.startConfigManager(Appl
icationManager.java:240)
at
weblogic.management.mbeans.custom.ApplicationManager.start(ApplicationManage
r.java:122)
at java.lang.reflect.Method.invoke(Native Method)
at
weblogic.management.internal.DynamicMBeanImpl.invokeLocally(DynamicMBeanImpl
.java:562)
at
weblogic.management.internal.DynamicMBeanImpl.invoke(DynamicMBeanImpl.java:5
48)
at
weblogic.management.internal.ConfigurationMBeanImpl.invoke(ConfigurationMBea
nImpl.java:285)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1555)
at com.sun.management.jmx.MBeanServerImpl.invoke(MBeanServerImpl.java:1523)
at weblogic.management.internal.MBeanProxy.invoke(MBeanProxy.java:437)
at weblogic.management.internal.MBeanProxy.invoke(MBeanProxy.java:178)
at $Proxy20.start(Unknown Source)
at
weblogic.management.configuration.ApplicationManagerMBean_CachingStub.start(
ApplicationManagerMBean_CachingStub.java:435)
at weblogic.management.Admin.startApplicationManager(Admin.java:1030)
at weblogic.management.Admin.finish(Admin.java:491)
at weblogic.t3.srvr.T3Srvr.start(T3Srvr.java:429)
at weblogic.t3.srvr.T3Srvr.run(T3Srvr.java:170)
at weblogic.Server.main(Server.java:35)
>
####<Jun 4, 2001 3:33:06 PM EDT> <Notice> <WebLogicServer> <WIN2000IIS>
<myserver> <main> <system> <> <000216> <WebLogic Server started>
####<Jun 4, 2001 3:33:09 PM EDT> <Notice> <WebLogicServer> <WIN2000IIS>
<myserver> <ListenThread> <system> <> <000202> <ListenThread listening on
port 7001>
####<Jun 4, 2001 3:33:10 PM EDT> <Notice> <WebLogicServer> <WIN2000IIS>
<myserver> <SSLListenThread> <system> <> <000202> <SSLListenThread listening
on port 7002>


Thanks.


Mike Mormando

unread,
Jun 5, 2001, 10:15:38 AM6/5/01
to
I've done it, with the Oracle thin driver and it works fine. I did have to
download the classes12.zip file from Oracle, which is the driver for 8.1.7,
but it's working fine against 8.1.5 database.
I just had to modify the script that starts WLS to add the classes12.zip to
the classpath, and everything worked great.
Mike

"gga" <gary...@yahoo.com> wrote in message
news:3b1b...@newsgroups.bea.com...

Sree Bodapati

unread,
Jun 5, 2001, 10:14:24 AM6/5/01
to
your pool tag should look something like this,

<JDBCConnectionPool CapacityIncrement="1"
DriverName="oracle.jdbc.driver.OracleDriver" InitialCapacity="1"
MaxCapacity="3" Name="oraclePool"
Properties="user=UID;password=PWD" Targets="myserver"
URL="jdbc:oracle:thin:@ServerIPAddress:PORT:ServiceName"/>

HTH


"gga" <gary...@yahoo.com> wrote in message

news:3b1cdb7f$1...@newsgroups.bea.com...

gga

unread,
Jun 5, 2001, 11:41:05 AM6/5/01
to
Thanks for all the help.

It turns out that my problem was related to the pool tag. I had the service
name in both the Properties as well as the URL. I realized this after
looking at the Sree's example. That was enough to confuse things so the
pool wouldnt start.

Thanks again folks.
Gary

"gga" <gary...@yahoo.com> wrote in message

news:3b1b...@newsgroups.bea.com...

0 new messages