How do you configure a JNDI datasource in Grails 3.x?

╄→гoц情女王★ 提交于 2019-12-04 15:10:27
sfgroups

your correct above didn't work. I followed below steps, its working now for me.

  1. tomcat context.xml file defined like this:

    Resource name="grailsDB"
    
  2. application.yml added this production datasource.

    production:
        dataSource:
            dbCreate: update
            jndiName: java:comp/env/grailsDB
    
  3. created the grails-app/conf/DataSource.groovy file, based on https://grails.github.io/grails-doc/3.0.x/ref/Plug-ins/dataSource.html document.

    dataSource {
        jndiName = "java:comp/env/grailsDB"
    }
    
  4. created the war file using grails war command.

  5. deployed in tomcat and tested it by adding deleting the sample data.

    Here is software versions I tested with.

APPLICATION STATUS
    Environment: production
    App profile: web
    App version: 0.1
    Grails version: 3.0.3
    Groovy version: 2.4.3
    JVM version: 1.8.0_65

Hope this helps.

thanks -SR

In application.yml I replaced url with this value,it work for me. you can try the same.

 production:
        dataSource:
            dbCreate: update            
            jndiName: java:comp/env/jdbc/dbjndiname
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!