You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Chen Chunwei <ou...@cn.panasonic.com> on 2008/04/01 08:44:38 UTC

Help on

Hi all,

I've configured a data source at struts-config.xml. This data source use oracle thin jdbc driver. And I've already included the ojdbc.jar. Also, the oracle database I'm trying to connect is OK. But I just can't make the data source get the connection. It always throws a SQLException: Timeout awaiting connection. Can anyone give some help? Following is my <data-source>.
----------------------------------------------------------------------------------------------
  <data-source key="org.apache.struts.action.DATA_SOURCE">
   <set-property property="password" value="passw0rd" />
   <set-property property="minCount" value="" />
   <set-property property="maxCount" value="" />
   <set-property property="user" value="planuser" />
   <set-property property="driverClass"
    value="oracle.jdbc.driver.OracleDriver" />
   <set-property property="description"
    value="Oracle 9i Database - Struts Test" />
   <set-property property="url"
    value="jdbc:oracle:thin:@10.192.225.8:1521:wpsprod" />
   <set-property property="readOnly" value="false" />
   <set-property property="autoCommit" value="false" />
   <set-property property="loginTimeout" value="30" />
  </data-source>
----------------------------------------------------------------------------------------------

Thanks

Talos

Re: Help on

Posted by Antonio Petrelli <an...@gmail.com>.
2008/4/1, Chen Chunwei <ou...@cn.panasonic.com>:
>
> Personally, I do wanna use JNDI. But the project I'm going to do is based
> on struts 1.1 and using <data-source> to connect to db. So I have to learn
> on these things first and learn the advanced things later after work :-)



Notice that JNDI support depends on the container. Even Tomcat 4.1.xsupports it.

Antonio

Re: Help on

Posted by Chen Chunwei <ou...@cn.panasonic.com>.
Thanks

Personally, I do wanna use JNDI. But the project I'm going to do is based on struts 1.1 and using <data-source> to connect to db. So I have to learn on these things first and learn the advanced things later after work :-)

Talos

----- Original Message ----- 
From: "Antonio Petrelli" <an...@gmail.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Tuesday, April 01, 2008 3:54 PM
Subject: Re: Help on <data-source>


2008/4/1, Chen Chunwei <ou...@cn.panasonic.com>:
>
> By the way, can I say that, if I use <data-source> in my struts
> application, then the struts servlet manages the connection? That is, when
> the application is deployed, the struts servlet will automaticly create
> connections of numbers specified by "minCount". And the application just
> fetch the connection created to use?



It's not the servlet that manages the connections, but the data source, that
acts also as a connection pool. For more information, see:
http://commons.apache.org/dbcp/
This data source is created by the servlet.
The reason why it is deprecated is that it mixes the Controller and the
Model layers of the MVC model.

Antonio

Re: Help on

Posted by Antonio Petrelli <an...@gmail.com>.
2008/4/1, Chen Chunwei <ou...@cn.panasonic.com>:
>
> By the way, can I say that, if I use <data-source> in my struts
> application, then the struts servlet manages the connection? That is, when
> the application is deployed, the struts servlet will automaticly create
> connections of numbers specified by "minCount". And the application just
> fetch the connection created to use?



It's not the servlet that manages the connections, but the data source, that
acts also as a connection pool. For more information, see:
http://commons.apache.org/dbcp/
This data source is created by the servlet.
The reason why it is deprecated is that it mixes the Controller and the
Model layers of the MVC model.

Antonio

Re: Help on

Posted by Chen Chunwei <ou...@cn.panasonic.com>.
Thanks Antonio

Now I can make it connected. 

By the way, can I say that, if I use <data-source> in my struts application, then the struts servlet manages the connection? That is, when the application is deployed, the struts servlet will automaticly create connections of numbers specified by "minCount". And the application just fetch the connection created to use?

Talos

----- Original Message ----- 
From: "Antonio Petrelli" <an...@gmail.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Tuesday, April 01, 2008 3:27 PM
Subject: Re: Help on <data-source>


2008/4/1, Chen Chunwei <ou...@cn.panasonic.com>:
>
> java.sql.SQLException: Io Exception: The Network Adapter could not
> establish the connection



It seems that you cannot reach the Oracle server... can you ping it? Are you
able to see it through a sql client?

Antonio

Re: Help on

Posted by Antonio Petrelli <an...@gmail.com>.
2008/4/1, Chen Chunwei <ou...@cn.panasonic.com>:
>
> java.sql.SQLException: Io Exception: The Network Adapter could not
> establish the connection



It seems that you cannot reach the Oracle server... can you ping it? Are you
able to see it through a sql client?

Antonio

Re: Help on

Posted by Chen Chunwei <ou...@cn.panasonic.com>.
Here's the whole stacktrace. Note: the language version of my Tomcat 5.5 is Chinese. So I replaced some non-English text with translated English.

Talos
--------------------------------begin----------------------------------------------------------------

2008-4-1 15:07:22 org.apache.catalina.startup.HostConfig checkResources
Infomation: Reloading context [/Week 3 DbAccess]
2008-4-1 15:07:22 org.apache.struts.util.PropertyMessageResources <init>
Infomation: Initializing, config='org.apache.struts.util.LocalStrings', returnNull=true
2008-4-1 15:07:22 org.apache.struts.util.PropertyMessageResources <init>
Infomation: Initializing, config='org.apache.struts.action.ActionResources', returnNull=true
2008-4-1 15:07:23 org.apache.struts.util.PropertyMessageResources <init>
Infomation: Initializing, config='com.psh.struts.ApplicationResources', returnNull=true
2008-4-1 15:07:23 org.apache.struts.legacy.GenericDataSource createConnection
Infomation:    createConnection()
2008-4-1 15:08:00 org.apache.struts.action.ActionServlet initModuleDataSources
Error: Initializing application data source org.apache.struts.action.DATA_SOURCE
java.sql.SQLException: Io Exception: The Network Adapter could not establish the connection
 at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
 at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
 at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:255)
 at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387)
 at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:439)
 at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
 at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
 at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
 at org.apache.struts.legacy.GenericDataSource.createConnection(GenericDataSource.java:805)
 at org.apache.struts.legacy.GenericDataSource.open(GenericDataSource.java:741)
 at org.apache.struts.action.ActionServlet.initModuleDataSources(ActionServlet.java:1085)
 at org.apache.struts.action.ActionServlet.init(ActionServlet.java:472)
 at javax.servlet.GenericServlet.init(GenericServlet.java:212)
 at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1139)
 at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:966)
 at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3956)
 at org.apache.catalina.core.StandardContext.start(StandardContext.java:4230)
 at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1116)
 at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1214)
 at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:293)
 at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
 at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1306)
 at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1570)
 at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1579)
 at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1559)
 at java.lang.Thread.run(Unknown Source)
2008-4-1 15:08:00 org.apache.catalina.core.ApplicationContext log
Infomation: Marking servlet action as unavailable
2008-4-1 15:08:00 org.apache.catalina.core.StandardContext loadOnStartup
Error: Servlet /Week 3 DbAccess threw load() exception
javax.servlet.UnavailableException: Initializing application data source org.apache.struts.action.DATA_SOURCE
 at org.apache.struts.action.ActionServlet.initModuleDataSources(ActionServlet.java:1091)
 at org.apache.struts.action.ActionServlet.init(ActionServlet.java:472)
 at javax.servlet.GenericServlet.init(GenericServlet.java:212)
 at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1139)
 at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:966)
 at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3956)
 at org.apache.catalina.core.StandardContext.start(StandardContext.java:4230)
 at org.apache.catalina.startup.HostConfig.checkResources(HostConfig.java:1116)
 at org.apache.catalina.startup.HostConfig.check(HostConfig.java:1214)
 at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:293)
 at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:120)
 at org.apache.catalina.core.ContainerBase.backgroundProcess(ContainerBase.java:1306)
 at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1570)
 at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.processChildren(ContainerBase.java:1579)
 at org.apache.catalina.core.ContainerBase$ContainerBackgroundProcessor.run(ContainerBase.java:1559)
 at java.lang.Thread.run(Unknown Source)
2008-4-1 15:11:10 org.apache.struts.util.PropertyMessageResources <init>
Infomation: Initializing, config='org.apache.struts.taglib.logic.LocalStrings', returnNull=true

------------------------------------end--------------------------------------------------------------------------


----- Original Message ----- 
From: "Antonio Petrelli" <an...@gmail.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Tuesday, April 01, 2008 3:13 PM
Subject: Re: Help on <data-source>


2008/4/1, Chen Chunwei <ou...@cn.panasonic.com>:
>
> Thanks.
>
> I've tried to specify minCount=2 and maxCount=4. But I've encountered a
> new exception: The Network Adapter could not establish the connection. Is
> that mean something wrong with my network connection?



Can I see the complete stacktrace?

Antonio

Re: Help on

Posted by Antonio Petrelli <an...@gmail.com>.
2008/4/1, Chen Chunwei <ou...@cn.panasonic.com>:
>
> Thanks.
>
> I've tried to specify minCount=2 and maxCount=4. But I've encountered a
> new exception: The Network Adapter could not establish the connection. Is
> that mean something wrong with my network connection?



Can I see the complete stacktrace?

Antonio

Re: Help on

Posted by Chen Chunwei <ou...@cn.panasonic.com>.
I'm using struts 1.1

----- Original Message ----- 
From: "Vinny" <xa...@gmail.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Tuesday, April 01, 2008 2:52 PM
Subject: Re: Help on <data-source>


What version of struts?
Data-source got deprecated at some point. I forget the version.



On 4/1/08, Chen Chunwei <ou...@cn.panasonic.com> wrote:
> Hi all,
>
> I've configured a data source at struts-config.xml. This data source use
> oracle thin jdbc driver. And I've already included the ojdbc.jar. Also, the
> oracle database I'm trying to connect is OK. But I just can't make the data
> source get the connection. It always throws a SQLException: Timeout awaiting
> connection. Can anyone give some help? Following is my <data-source>.
> ----------------------------------------------------------------------------------------------
>   <data-source key="org.apache.struts.action.DATA_SOURCE">
>    <set-property property="password" value="passw0rd" />
>    <set-property property="minCount" value="" />
>    <set-property property="maxCount" value="" />
>    <set-property property="user" value="planuser" />
>    <set-property property="driverClass"
>     value="oracle.jdbc.driver.OracleDriver" />
>    <set-property property="description"
>     value="Oracle 9i Database - Struts Test" />
>    <set-property property="url"
>     value="jdbc:oracle:thin:@10.192.225.8:1521:wpsprod" />
>    <set-property property="readOnly" value="false" />
>    <set-property property="autoCommit" value="false" />
>    <set-property property="loginTimeout" value="30" />
>   </data-source>
> ----------------------------------------------------------------------------------------------
>
> Thanks
>
> Talos

-- 
Sent from Gmail for mobile | mobile.google.com

The future is here. It's just not widely distributed yet.
-William Gibson

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org

Re: Help on

Posted by Vinny <xa...@gmail.com>.
What version of struts?
Data-source got deprecated at some point. I forget the version.



On 4/1/08, Chen Chunwei <ou...@cn.panasonic.com> wrote:
> Hi all,
>
> I've configured a data source at struts-config.xml. This data source use
> oracle thin jdbc driver. And I've already included the ojdbc.jar. Also, the
> oracle database I'm trying to connect is OK. But I just can't make the data
> source get the connection. It always throws a SQLException: Timeout awaiting
> connection. Can anyone give some help? Following is my <data-source>.
> ----------------------------------------------------------------------------------------------
>   <data-source key="org.apache.struts.action.DATA_SOURCE">
>    <set-property property="password" value="passw0rd" />
>    <set-property property="minCount" value="" />
>    <set-property property="maxCount" value="" />
>    <set-property property="user" value="planuser" />
>    <set-property property="driverClass"
>     value="oracle.jdbc.driver.OracleDriver" />
>    <set-property property="description"
>     value="Oracle 9i Database - Struts Test" />
>    <set-property property="url"
>     value="jdbc:oracle:thin:@10.192.225.8:1521:wpsprod" />
>    <set-property property="readOnly" value="false" />
>    <set-property property="autoCommit" value="false" />
>    <set-property property="loginTimeout" value="30" />
>   </data-source>
> ----------------------------------------------------------------------------------------------
>
> Thanks
>
> Talos

-- 
Sent from Gmail for mobile | mobile.google.com

The future is here. It's just not widely distributed yet.
-William Gibson

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Help on

Posted by Chen Chunwei <ou...@cn.panasonic.com>.
Thanks.

I've tried to specify minCount=2 and maxCount=4. But I've encountered a new exception: The Network Adapter could not establish the connection. Is that mean something wrong with my network connection?

I'm using Struts 1.1

Talos

----- Original Message ----- 
From: "Antonio Petrelli" <an...@gmail.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Tuesday, April 01, 2008 2:58 PM
Subject: Re: Help on <data-source>


Please Chen, the next time you post a question, say that you are using
Struts 1.1 *always*.
See the answers below.

2008/4/1, Chen Chunwei <ou...@cn.panasonic.com>:
>    <set-property property="minCount" value="" />
>    <set-property property="maxCount" value="" />

I think this is the problem: specify a value for "minCount" and "maxCount".
And remember to close the connection once you used it!
Notice that, for default, a commons-dbcp datasource will be used,
while I suggest to use the Oracle datasource.
And, BTW, as Vinny said, the datasource support in Struts is
deprecated, I suggest you to use JNDI and configure the datasource in
your container.

Antonio

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org

Re: Help on

Posted by Antonio Petrelli <an...@gmail.com>.
Please Chen, the next time you post a question, say that you are using
Struts 1.1 *always*.
See the answers below.

2008/4/1, Chen Chunwei <ou...@cn.panasonic.com>:
>    <set-property property="minCount" value="" />
>    <set-property property="maxCount" value="" />

I think this is the problem: specify a value for "minCount" and "maxCount".
And remember to close the connection once you used it!
Notice that, for default, a commons-dbcp datasource will be used,
while I suggest to use the Oracle datasource.
And, BTW, as Vinny said, the datasource support in Struts is
deprecated, I suggest you to use JNDI and configure the datasource in
your container.

Antonio

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org