Hello Avinash

I'm not expert but this is rather simple :
in web/META-INF/context.xml write something like :

<Context>
  <Resource name="jdbc/tomcattest"
    type="javax.sql.DataSource"
    username="root"
    password="pass"
    driverClassName="com.mysql.jdbc.Driver"

url="jdbc:mysql://localhost:3306/databasename?useSSL=false&amp;zeroDateTimeBehavior=convertToNull&amp;jdbcCompliantTruncation=false&amp;characterEncoding=utf8"
  />
</Context>

in web/WEB-INF/web.xml add in <web-app> tag :
  <resource-ref>
    <res-ref-name>
      jdbc/tomcattest
    </res-ref-name>
    <res-type>
      javax.sql.DataSource
    </res-type>
  </resource-ref>

and in a java class add this :

public class T3Servlet extends HttpServlet
{
  @Resource(name="jdbc/tomcattest")
  public DataSource ds;


You will normally have a data source in your class, by injection, using tomcat database pool.


On 18/07/2017 12:26, Avinash Krishnan wrote:
I am trying to implement Apache Tomcat 8.5.15  "Tomcat JDBC Connection
Pool" using the steps mentioned in the guide.

Can some one help me to understand how this connection pooling has to be
done.

Is the Plain Java Method,by implementing Pool Properties is an alternative
to the JNDI lookup based pooling ? When I implement using Pool Properties,
there isn't any provision to set up the Factory to
org.apache.tomcat.jdbc.pool.DataSourceFactory"
and I always get invalid arguments in call.

On a different note, I tried by adding to context.xml . And implementing
JNDI lookup from context. But that time,I get
"org.apache.tomcat.dbcp.dbcp2.BasicDataSource cannot be cast to
org.apache.tomcat.jdbc.pool.DataSource" even after setting factory to
DataSourceFactory.


--
Riccardo Cohen
+33 6 09 83 64 49
E5Group
http://www.5flow.com


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to