SEVERE: Unable to create initial connections of pool - tomcat 7 with context.xml file

后端 未结 4 1926
故里飘歌
故里飘歌 2020-12-11 16:30

I tried to run project on tomcat 7.0.52 and initialize to DB through context.xml file.

But it throws bunch of exceptions, I couldn\'t figur

4条回答
  •  遥遥无期
    2020-12-11 16:56

    I have also dealt with this exception after a fully working context.xml setup was adjusted. I didn't want environment details in the context.xml, so I took them out and saw this error. I realized I must fully create this datasource resource in code based on System Property JVM -D args.

    Original error with just user/pwd/host removed: org.apache.tomcat.jdbc.pool.ConnectionPool init SEVERE: Unable to create initial connections of pool.

    Removed entire contents of context.xml and try this: Initialize on startup of app server the datasource object sometime before using first connection. If using Spring this is good to do in an @Configuration bean in @Bean Datasource constructor.

    package to use: org.apache.tomcat.jdbc.pool.*

    PoolProperties p = new PoolProperties();
    p.setUrl(jdbcUrl);
                p.setDriverClassName(driverClass);
                p.setUsername(user);
                p.setPassword(pwd);
                p.setJmxEnabled(true);
                p.setTestWhileIdle(false);
                p.setTestOnBorrow(true);
                p.setValidationQuery("SELECT 1");
                p.setTestOnReturn(false);
                p.setValidationInterval(30000);
                p.setValidationQueryTimeout(100);
                p.setTimeBetweenEvictionRunsMillis(30000);
                p.setMaxActive(100);
                p.setInitialSize(5);
                p.setMaxWait(10000);
                p.setRemoveAbandonedTimeout(60);
                p.setMinEvictableIdleTimeMillis(30000);
                p.setMinIdle(5);
                p.setLogAbandoned(true);
                p.setRemoveAbandoned(true);
                p.setJdbcInterceptors(
                  "org.apache.tomcat.jdbc.pool.interceptor.ConnectionState;"+
                  "org.apache.tomcat.jdbc.pool.interceptor.StatementFinalizer");
                org.apache.tomcat.jdbc.pool.DataSource ds = new org.apache.tomcat.jdbc.pool.DataSource();
                ds.setPoolProperties(p);
                return ds;
    

提交回复
热议问题