由sql server 2008和2012重置Tomcat连接池

时间:2021-04-19 13:22:22

I have 5 different modules connecting sql server 2008 and 2012 using Tomcat connection pooling.

我有5个不同的模块使用Tomcat连接池连接sql server 2008和2012。

In the Tomcat7\conf\context.xml

在Tomcat7 \ conf \ context.xml中

<Resource auth="Container" driverClassName="net.sourceforge.jtds.jdbc.Driver" logAbandoned="true" maxActive="100" maxIdle="30" maxWait="10000" name="jdbc/testservice2" password="abc" removeAbandoned="true" removeAbandonedTimeout="60" type="javax.sql.DataSource" 
    url="jdbc:jtds:sqlserver://localhost;databaseName=testdb;SelectMethod=Cursor" username="abc"/>

Module 1 - In the Tomcat7\conf\localhost\Module1.XML

第1单元 - 在Tomcat7 \ conf \ localhost \ Module1.XML中

<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/Module1">
    <Resource name="jdbc/testdb" auth="Container" type="javax.sql.DataSource"
               maxActive="100" maxIdle="30" maxWait="10000" removeAbandoned="true" removeAbandonedTimeout="60"
               username="abc" password="abc" driverClassName="net.sourceforge.jtds.jdbc.Driver"
               url="jdbc:jtds:sqlserver://localhost;databaseName=testdb;SelectMethod=Cursor"/>

Module 2 - In the Tomcat7\conf\localhost\Module2.XML

第2单元 - 在Tomcat7 \ conf \ localhost \ Module2.XML中

<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/Module2">
    <Resource name="jdbc/testdb" auth="Container" type="javax.sql.DataSource"
               maxActive="100" maxIdle="30" maxWait="10000" removeAbandoned="true" removeAbandonedTimeout="60"
               username="abc" password="abc" driverClassName="net.sourceforge.jtds.jdbc.Driver"
               url="jdbc:jtds:sqlserver://localhost;databaseName=testdb;SelectMethod=Cursor"/>
</Context>

Module 3 - In the Tomcat7\conf\localhost\Module3.XML

第3单元 - 在Tomcat7 \ conf \ localhost \ Module3.XML中

<Context antiJARLocking="true" path="/Module3">
    <Resource name="jdbc/testdb" auth="Container" type="javax.sql.DataSource"
               maxActive="100" maxIdle="30" maxWait="10000" removeAbandoned="true" removeAbandonedTimeout="60"
               username="abc" password="abc" driverClassName="net.sourceforge.jtds.jdbc.Driver"
               url="jdbc:jtds:sqlserver://localhost;databaseName=testdb;SelectMethod=Cursor"/>
</Context>

Module 4 - In the Tomcat7\conf\localhost\Module4.XML

第4单元 - 在Tomcat7 \ conf \ localhost \ Module4.XML中

<Context antiJARLocking="true" path="/Module4">
    <Resource name="jdbc/testdb" auth="Container" type="javax.sql.DataSource"
               maxActive="100" maxIdle="30" maxWait="10000" removeAbandoned="true" removeAbandonedTimeout="60"
               username="abc" password="abc" driverClassName="net.sourceforge.jtds.jdbc.Driver"
               url="jdbc:jtds:sqlserver://localhost;databaseName=testdb;SelectMethod=Cursor"/>
</Context>

I'm experiencing the below error on QA server as well as staging server? 06-Apr-2015 07:43:28 ERROR DBAccess:49 - I/O Error: Connection reset by peer: socket write error

我在QA服务器和登台服务器上遇到以下错误? 06-Apr-2015 07:43:28错误DBAccess:49 - I / O错误:通过对等方重置连接:套接字写入错误

What's wrong with my Tomcat 7 connection pool configuration? why it's rejected by sql server

我的Tomcat 7连接池配置有什么问题?为什么它被sql server拒绝了

1 个解决方案

#1


1  

You are trying to use all the modules simultaneously in which you have defined the 'Resource' with same name i.e. name="jdbc/testdb" as far as i know this name has to be unique because it is jndi bound with the value you give to name attribute(see tomcat document https://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Resource_Definitions ). If you define a datasource with same name in different modules(web apps) see that they are not in use simultaneously. Somewhere in your server this is happening. To be safe use different name for 'Resource'. Another thing-Is 'Resource' with name="jdbc/testservice2" being used in any of your five modules you have mentioned. Cause I don't see a connection between any of your five modules with this 'Resource'.

您正在尝试同时使用所有模块,其中您已使用相同名称定义了“资源”,即name =“jdbc / testdb”,据我所知,此名称必须是唯一的,因为它与您给出的值绑定了jndi name属性(参见tomcat文档https://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Resource_Definitions)。如果在不同模块(Web应用程序)中定义具有相同名称的数据源,请看它们未同时使用。在服务器的某个地方,这种情况正在发生。为安全起见,请使用“资源”的不同名称。另一件事 - 在您提到的五个模块中的任何一个模块中使用名称为“jdbc / testservice2”的“资源”。因为我没有看到任何五个模块与这个'资源'之间的连接。

#1


1  

You are trying to use all the modules simultaneously in which you have defined the 'Resource' with same name i.e. name="jdbc/testdb" as far as i know this name has to be unique because it is jndi bound with the value you give to name attribute(see tomcat document https://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Resource_Definitions ). If you define a datasource with same name in different modules(web apps) see that they are not in use simultaneously. Somewhere in your server this is happening. To be safe use different name for 'Resource'. Another thing-Is 'Resource' with name="jdbc/testservice2" being used in any of your five modules you have mentioned. Cause I don't see a connection between any of your five modules with this 'Resource'.

您正在尝试同时使用所有模块,其中您已使用相同名称定义了“资源”,即name =“jdbc / testdb”,据我所知,此名称必须是唯一的,因为它与您给出的值绑定了jndi name属性(参见tomcat文档https://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Resource_Definitions)。如果在不同模块(Web应用程序)中定义具有相同名称的数据源,请看它们未同时使用。在服务器的某个地方,这种情况正在发生。为安全起见,请使用“资源”的不同名称。另一件事 - 在您提到的五个模块中的任何一个模块中使用名称为“jdbc / testservice2”的“资源”。因为我没有看到任何五个模块与这个'资源'之间的连接。