Dear Dan,

Thanks for your response!

I have cross checked the user / password configuration. All is correct. As
i mentioned that initially i am getting the object of connection but after
some time (After few hits to database from application) my web app goes to
slow and than it stops working i i got the below exception-
*org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot get a connection,
pool error Timeout waiting for idle object*

I searched for this and find that reason is "maxWait" ms then i set it to
-1 i think which tends to unlimited time. Still i am facing the same
problem.

Can you please let me know what others reason can cause this exception.


*Best Regards,    *

*Saurabh Sarasvat*




On Fri, Apr 4, 2014 at 5:16 PM, Daniel Mikusa <dmik...@gopivotal.com> wrote:

> On Apr 4, 2014, at 1:19 AM, Saurabh Saraswat <ssaras...@pivotalindia.com>
> wrote:
>
> > 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 ?
>
> There are a couple possibilities.
>
> 1.) Look at "deployXML" attribute of your <Host> tag.  If this is set to
> false, it will disable parsing the context XML descriptor embedded inside
> the application.  This defaults to true, unless you are running with a
> security manager, then it defaults to false.
>
>
> http://tomcat.apache.org/tomcat-7.0-doc/config/host.html#Standard_Implementation
>
> 2.) Look at the "copyXML" attribute of both your <Host> and <Context>
> tags.  This needs to be set to true, because the default in Tomcat 7 is
> false.
>
>
> http://tomcat.apache.org/tomcat-7.0-doc/config/host.html#Standard_Implementation
>
> http://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Standard_Implementation
>
> If both attributes are set properly, you should see the
> META-INF/context.xml file from your application copied to
> "$CATALINA_BASE/conf/Catalina/localhost".
>
> >
> > But when i am putting this context.xml in ${CATALINA-BASE}/conf folder
> then
> > its working.
> >
> > <?xml version="1.0" encoding="UTF-8"?>
> >
> >
> > <Context>
> >  <Resource name="jdbc/MaxDB" auth="Container" type="javax.sql.DataSource"
> >               maxActive="100" maxIdle="30" maxWait="-1"
> >               username="root" password="root"
> > driverClassName="com.mysql.jdbc.Driver"
> >
> >
> url="jdbc:MySQL://localhost:3306/MaxDB?zeroDateTimeBehavior=convertToNull"/>
> >
> > </Context>
> >
> > *2. Mapping in web.xml*
> >
> > <resource-ref>
> > <description>MySql DataSource</description>
> > <res-ref-name>jdbc/MaxDB</res-ref-name>
> > <res-type>javax.sql.DataSource</res-type>
> > <res-auth>Container</res-auth>
> > </resource-ref>
> >
> > *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;
> >       try
> >       {
> >          conn= getConnection();
> >
> >          .....................................
> >         // do the required stuff
> >
> >       }
> >       catch (Exception ex)
> >        {
> >
> >        }
> >        finally
> >        {
> >          conn.close();
> >        }
> >
> > }
> >
> > *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;
> >        try
> >        {
> >            ctx = new InitialContext();
> >            datasource = (DataSource)
> > ctx.lookup("java:/comp/env/jdbc/MaxDB");
> >            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*
>
> This means it was unable to get a connection from the pool within
> "maxWait" ms.  There are a few reasons this could happen, but I'd guess
> it's because of the next error that you reported.
>
> >
> > Then i got the exception-
> >
> > *org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create
> > PoolableConnectionFactory (Access denied for user 'root'@'localhost'
> (using
> > password: YES))*
>
> Seems like you can't connect to the database.  Have you double checked
> your user / password / host configuration info?
>
> Dan
>
> >
> > 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
> > answer.
> >
> > Hope that you all are expert and your suggestion will be valuable for me.
> >
> > Thanking You!
> >
> > *Best Regards,    *
> >
> > *Saurabh Sarasvat*
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: users-h...@tomcat.apache.org
>
>

Reply via email to