File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Connection pooling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Connection pooling" Watch "Connection pooling" New topic
Author

Connection pooling

lee anthony
Ranch Hand

Joined: Jan 23, 2004
Posts: 35
hi
i was trying pull connectio pooling features
by replacing
<data-source type="org.apache.struts.legacy.GenericDataSource">
with
<data-source type="org.apache.commons.dbcp.BasicDataSource">
in my struts config xml
=========Struts-config.xml=================
my datasource looks somthing like...
<!-- <data-source type="org.apache.struts.legacy.GenericDataSource">==================================== Data Source Configuration -->
<!-- ==================================== Data Source Configuration -->
<!-- <data-source type="org.apache.commons.dbcp.BasicDataSource">==================================== Data Source Configuration -->
<data-sources>
<data-source type="org.apache.commons.dbcp.BasicDataSource">
<set-property property="autoCommit"
value="false"/>
<set-property property="description"
value="eProject Data Source Configuration"/>
<set-property property="driverClass"
value="org.postgresql.Driver"/>
<set-property property="maxCount"
value="1000"/>
<set-property property="minCount"
value="1"/>
<set-property property="password"
value="test"/>
<set-property property="url"
value="jdbc ostgresql://192.168.1.202/ep"/>
<set-property property="user"
value="pguser"/>
</data-source>

</data-sources>
But while in running my tomcat server it throw a exception....
<!-- <data-source type="org.apache.struts.legacy.GenericDataSource">==================================== Data Source Configuration -->
<!-- ==================================== Data Source Configuration -->
<!-- <data-source type="org.apache.commons.dbcp.BasicDataSource">==================================== Data Source Configuration -->
<data-sources>
<data-source type="org.apache.commons.dbcp.BasicDataSource">
<set-property property="autoCommit"
value="false"/>
<set-property property="description"
value="eProject Data Source Configuration"/>
<set-property property="driverClass"
value="org.postgresql.Driver"/>
<set-property property="maxCount"
value="1000"/>
<set-property property="minCount"
value="1"/>
<set-property property="password"
value="test"/>
<set-property property="url"
value="jdbc ostgresql://192.168.1.202/ep"/>
<set-property property="user"
value="pguser"/>
</data-source>
</data-sources>
============Error from Tomcat=========
SEVERE: Initializing application data source org.apache.struts.action.DATA_SOURCE
org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'jdbc ostgresql://192.168.1.202/ep', cause:
java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getDriver(DriverManager.java:243)
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:743)
at org.apache.commons.dbcp.BasicDataSource.setLogWriter(BasicDataSource.java:576)
at org.apache.struts.action.ActionServlet.initModuleDataSources(ActionServlet.java:1087)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:472)
at javax.servlet.GenericServlet.init(GenericServlet.java:256)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1044)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:887)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3948)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4271)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1125)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:816)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1125)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:518)
at org.apache.catalina.core.StandardService.start(StandardService.java:519)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:2343)
at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
======================================
Can anybody help me ...or advice me a better way for including connection pooling features Thanks ..do help
Lee
giang nguyen
Ranch Hand

Joined: May 13, 2003
Posts: 42
Originally posted by lee anthony:
hi
i was trying pull connectio pooling features
by replacing
<data-source type="org.apache.struts.legacy.GenericDataSource">
with
<data-source type="org.apache.commons.dbcp.BasicDataSource">
in my struts config xml
=========Struts-config.xml=================
my datasource looks somthing like...
<!-- <data-source type="org.apache.struts.legacy.GenericDataSource">==================================== Data Source Configuration -->
<!-- ==================================== Data Source Configuration -->
<!-- <data-source type="org.apache.commons.dbcp.BasicDataSource">==================================== Data Source Configuration -->
<data-sources>
<data-source type="org.apache.commons.dbcp.BasicDataSource">
<set-property property="autoCommit"
value="false"/>
<set-property property="description"
value="eProject Data Source Configuration"/>
<set-property property="driverClass"
value="org.postgresql.Driver"/>
<set-property property="maxCount"
value="1000"/>
<set-property property="minCount"
value="1"/>
<set-property property="password"
value="test"/>
<set-property property="url"
value="jdbc ostgresql://192.168.1.202/ep"/>
<set-property property="user"
value="pguser"/>
</data-source>

</data-sources>
But while in running my tomcat server it throw a exception....
<!-- <data-source type="org.apache.struts.legacy.GenericDataSource">==================================== Data Source Configuration -->
<!-- ==================================== Data Source Configuration -->
<!-- <data-source type="org.apache.commons.dbcp.BasicDataSource">==================================== Data Source Configuration -->
<data-sources>
<data-source type="org.apache.commons.dbcp.BasicDataSource">
<set-property property="autoCommit"
value="false"/>
<set-property property="description"
value="eProject Data Source Configuration"/>
<set-property property="driverClass"
value="org.postgresql.Driver"/>
<set-property property="maxCount"
value="1000"/>
<set-property property="minCount"
value="1"/>
<set-property property="password"
value="test"/>
<set-property property="url"
value="jdbc ostgresql://192.168.1.202/ep"/>
<set-property property="user"
value="pguser"/>
</data-source>
</data-sources>
============Error from Tomcat=========
SEVERE: Initializing application data source org.apache.struts.action.DATA_SOURCE
org.apache.commons.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'jdbc ostgresql://192.168.1.202/ep', cause:
java.sql.SQLException: No suitable driver
at java.sql.DriverManager.getDriver(DriverManager.java:243)
at org.apache.commons.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:743)
at org.apache.commons.dbcp.BasicDataSource.setLogWriter(BasicDataSource.java:576)
at org.apache.struts.action.ActionServlet.initModuleDataSources(ActionServlet.java:1087)
at org.apache.struts.action.ActionServlet.init(ActionServlet.java:472)
at javax.servlet.GenericServlet.init(GenericServlet.java:256)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1044)
at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:887)
at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3948)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4271)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1125)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:816)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1125)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:518)
at org.apache.catalina.core.StandardService.start(StandardService.java:519)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:2343)
at org.apache.catalina.startup.Catalina.start(Catalina.java:581)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
======================================
Can anybody help me ...or advice me a better way for including connection pooling features Thanks ..do help
Lee

What Application server do you use? You should use the connection pooling support from Application server. Configure a datasource and a connection pool in server and your application can use the pool. This way is much better than using connection pooling from Struts which should be used only if your application server does not support connection pooling.


SCJP 1.4, SCWCD
lee anthony
Ranch Hand

Joined: Jan 23, 2004
Posts: 35
hi
i am using tomcat as my web server ....

please do
Lee
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Connection pooling