Contact Us
  
 
 
    SearchSearch   RegisterRegister   Log inLog in 

Connection pooling problem in tomcat and linux

Connection pooling problem in tomcat and linux

 
Post new topic   Reply to topic     Forum Index -> Tomcat Installation Problems
View previous topic :: View next topic  
Author Message
pridas



Joined: 21 Feb 2007
Posts: 2

PostPosted: Wed Feb 21, 2007 7:24 am    Post subject: Connection pooling problem in tomcat and linux Reply with quote




I have getting connection pooling problem in fedora core 6. i am using apache tomcat 5.5.20 for linux version.
i have made enteries in context.xml in conf folder and also have tried in server.xml file in conf folder. and have made entry in WEB-INF/web.xml as

Code:
<description>MySQL Test App</description>
  <resource-ref>
      <description>DB Connection</description>
      <res-ref-name>jdbc/PooledDB</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
  </resource-ref>


and in conf/context.xml

Code:

       <Resource name="jdbc/PooledDB"

   auth="Container"

   type="javax.sql.DataSource"

   factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"

   username="root"

   password=""

   driverClassName="com.mysql.jdbc.Driver"

   url="jdbc:mysql://localhost:3306/ace?autoReconnect=true"

   maxWait="1000"

   removeAbandoned="true"

   maxActive="30"

   maxIdle="10"

   removeAbandonedTimeout="60"

   logAbandoned="true"/>


and also tried to put this code in conf/server.xml as


Code:

    <Context path="/DBTest" docBase="DBTest"
        debug="5" reloadable="true" crossContext="true">

    <!-- maxActive: Maximum number of dB connections in pool. Make sure you
         configure your mysqld max_connections large enough to handle
         all of your db connections. Set to 0 for no limit.
         -->

    <!-- maxIdle: Maximum number of idle dB connections to retain in pool.
         Set to -1 for no limit.  See also the DBCP documentation on this
         and the minEvictableIdleTimeMillis configuration parameter.
         -->

    <!-- maxWait: Maximum time to wait for a dB connection to become available
         in ms, in this example 10 seconds. An Exception is thrown if
         this timeout is exceeded.  Set to -1 to wait indefinitely.
         -->

    <!-- username and password: MySQL dB username and password for dB connections  -->

    <!-- driverClassName: Class name for the old mm.mysql JDBC driver is
         org.gjt.mm.mysql.Driver - we recommend using Connector/J though.
         Class name for the official MySQL Connector/J driver is com.mysql.jdbc.Driver.
         -->
   
    <!-- url: The JDBC connection url for connecting to your MySQL dB.
         The autoReconnect=true argument to the url makes sure that the
         mm.mysql JDBC Driver will automatically reconnect if mysqld closed the
         connection.  mysqld by default closes idle connections after 8 hours.
         -->

  <Resource name="jdbc/PooledDB" auth="Container" type="javax.sql.DataSource"
               maxActive="100" maxIdle="30" maxWait="10000"
               username="root" password="" driverClassName="com.mysql.jdbc.Driver"
               url="jdbc:mysql://localhost:3306/ace?autoReconnect=true"/>

</Context>



But it is still throwing error of connection refused

Quote:

org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create PoolableConnectionFactory (Server connection failure during transaction. Due to underlying exception: 'java.net.SocketException: java.net.ConnectException: Connection refused'.

** BEGIN NESTED EXCEPTION **

java.net.SocketException
MESSAGE: java.net.ConnectException: Connection refused

STACKTRACE:

java.net.SocketException: java.net.ConnectException: Connection refused
at com.mysql.jdbc.StandardSocketFactory.connect(StandardSocketFactory.java:156)
at com.mysql.jdbc.MysqlIO.<init>(MysqlIO.java:284)
at com.mysql.jdbc.Connection.createNewIO(Connection.java:2666)
at com.mysql.jdbc.Connection.<init>(Connection.java:1474)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:266)
at org.apache.tomcat.dbcp.dbcp.DriverConnectionFactory.createConnection(DriverConnectionFactory.java:37)
at org.apache.tomcat.dbcp.dbcp.PoolableConnectionFactory.makeObject(PoolableConnectionFactory.java:290)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.validateConnectionFactory(BasicDataSource.java:877)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:851)
at org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)


if any one know this solution please help me
Back to top
View user's profile Send private message
ainya



Joined: 21 Feb 2007
Posts: 4

PostPosted: Wed Feb 21, 2007 2:02 pm    Post subject: Connection pooling problem in tomcat and linux Reply with quote

I also got same problem in fedore core 6 and tomcat 5.5.20 in few days before. i tried too many things for it.
i got many suggestion for it.

1. check jdbc permission in tomcat/config/catalina.policy
Code:
 
   grant{   
     permission java.net.SocketPermission    "*.localhost:8080",
"accept,connect,listen,resolve";
}

but unforturenately it didnot worked with my case, it still shown error of connection refused

2. Check it which port you are running mysql normally it is 3306
Code:

        #mysql -h IPAddress -u root -p
 

if it is connecting without any error. then use this ip in your url string
Use 127.0.0.1 instead 192.168.123 lan TCP/IP otherwise you have to bind this ip to localhost by bind-ip 192.168.1.123
Quote:
url="jdbc:mysql://127.0.0.1:3306/ace?autoReconnect=true"

or
last optional step
3. remove "skip-networking" in /etc/my.cnf file of mysql configure. with # and restart mysqld service
#service mysqld restart
good luck
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Tomcat Installation Problems All times are GMT
Page 1 of 1

 
Jump to:  
  Quick Post a Reply Topic
     
  Name (required)  
     
  Email Address (will not be published) (required)  
     
  Subject of topic (required)  
     
   
     
   
     
  Advertisement  
     
 
     


  More Links  
 
JSP Introduction
JSP Setup
Simple JSP Example
JSP Variable
Array Declaration in JSP
JSP Forms and User Input
Form Validation
JSP Cookies
JSP Session Object
Loop, content collection, iterator, conditional check in JSP
JSP Application Object
JSP Include
JSP Response Object
JSP Request Object
JSP Error Handling
JSP File Handling Object
JSP Action Tag
JSP Implicit Objects
JSP Declaration
JSP Directive
JDBC Introduction
JDBC Driver
JDBC Connection
JDBC Prepared/Statement
JDBC ResultSet
JDBC Close Connection object
JDBC Insert
JDBC Display Records
JDBC Update
JDBC Delete
JDBC Sorting
JDBC Query
JDBC Exception
JDBC Add Batch
JDBC Transaction/RollBack