top of page

Subscribe to Wisdom

Thanks for Subscribing!

  • Writer's pictureDimit Chadha

Define JNDI Name in Tomcat

You can enable connection to database using tomcat configurations. Define JNDI settings in tomcat server.xml for connecting any database type. Follow the steps below

  • Modify /conf/context.xml. Include the following JNDI names

<ResourceLink global="jdbc/{name1}" name="jdbc/{name2}" />

  • Modify /conf/server.xml. Find and add the new resource

<Resource
        auth="Container"             
        logAbandoned="true"
        maxIdle="-1"
        maxWait="10000"
        removeAbandoned="true"
        validationQuery="SELECT CURRENT_TIMESTAMP"
        driverClassName="com.mysql.jdbc.Driver"
        name="jdbc/{name1}"
        password="*****" username="abc"
        url="jdbc:mysql://localhost/dbaname" />

  • If your application uses Hibernate , Use the JNDI name in .cfg.xml as

<property name="connection.datasource">
  java:/comp/env/jdbc/{name2}
</property>

16 views0 comments

Recent Posts

See All

Comments


Modern Digital Watch
bottom of page