tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Saurabh Saraswat <>
Subject SQLNestedException in Connection Pooling With Tomcat 7.0.39
Date Fri, 04 Apr 2014 05:19:46 GMT
Dear All,

I am doing connection pooling with tomcat 7.0.39 and MySQL 5.5.After
searching on google and with your help i have done the below things.
Even i am able to get the connection successfully using this but getting
some trouble and exception.
I am explaining you all steps done by me-

*1. Have created a context.xml*

I have put this context.xml in the META-INF folder of my application. but
when i am deploying the web app to the server then it is not creating its
copy to ${CATALINA-BASE}/conf/Catalina/locathost. Why is that so ?

But when i am putting this context.xml in ${CATALINA-BASE}/conf folder then
its working.

<?xml version="1.0" encoding="UTF-8"?>

  <Resource name="jdbc/MaxDB" auth="Container" type="javax.sql.DataSource"
               maxActive="100" maxIdle="30" maxWait="-1"
               username="root" password="root"



*2. Mapping in web.xml*

 <description>MySql DataSource</description>

*3. Then on my servlet i am getting the object of connection like this-*

    private static InitialContext ic;
    protected static DataSource datasource;
    private static Context ctx;

public void doSomeStuff() throws DatabaseException
       Connection conn = null;
          conn= getConnection();

         // do the required stuff

       catch (Exception ex)



*4. This is the method in my DAO Class i am using this method to get the
object of connection at all of my servlet.*

   protected static Connection getConnection() throws DatabaseException
        Connection conn = null;
            ctx = new InitialContext();
            datasource = (DataSource)
            conn = datasource.getConnection();
        catch (Exception ex)

        return conn;

Using all this i am able to get connection. But if number of hits increases
to the server and Initially i got the the below exception-

*org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot get a connection,
pool error Timeout waiting for idle object*

Then i got the exception-

*org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create
PoolableConnectionFactory (Access denied for user 'root'@'localhost' (using
password: YES))*

Please assist me to know the root cause of the problem. I have searched it
on google and have read lots of forum but did not get the satisfactory

Hope that you all are expert and your suggestion will be valuable for me.

Thanking You!

*Best Regards,    *

*Saurabh Sarasvat*

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message