简体   繁体   中英

How to Connect to Oracle Database in Grails 3 Project with Intellij IDEA?

I'm trying to run a Grails 3 app with Intellij IDEA,but I don't know how to connect to oracle database, and where should I put the oracle jdbc driver? Here is my code in application.yml --- hibernate: cache: queries: false use_second_level_cache: true use_query_cache: false region.factory_class: 'org.hibernate.cache.ehcache.EhCacheRegionFactory'

dataSource:
    pooled: true
    jmxExport: true
    driverClassName: oracle.jdbc.driver.OracleDriver
    username: "wy"
    password: "19901110"

environments:
    development:
        dataSource:
            dbCreate: update
            url: jdbc:oracle:thin:@//localhost:1521/DBW
    test:
        dataSource:
            dbCreate: update
            url: jdbc:oracle:thin:@//localhost:1521/DBW
    production:
        dataSource:
            dbCreate: update
            url: jdbc:oracle:thin:@//localhost:1521/DBW
            properties:
                jmxEnabled: true
                initialSize: 5
                maxActive: 50
                minIdle: 5
                maxIdle: 25
                maxWait: 10000
                maxAge: 600000
                timeBetweenEvictionRunsMillis: 5000
                minEvictableIdleTimeMillis: 60000
                validationQuery: SELECT 1
                validationQueryTimeout: 3
                validationInterval: 15000
                testOnBorrow: true
                testWhileIdle: true
                testOnReturn: false
                jdbcInterceptors: ConnectionState
                defaultTransactionIsolation: 2 # TRANSACTION_READ_COMMITTED

---
---
grails:
    profile: web
    codegen:
        defaultPackage: keepup
    spring:
        transactionManagement:
            proxies: false
info:
    app:
        name: '@info.app.name@'
        version: '@info.app.version@'
        grailsVersion: '@info.app.grailsVersion@'
spring:

    groovy:
        template:
            check-template-location: false

---
grails:
    mime:
        disable:
            accept:
                header:
                    userAgents:
                        - Gecko
                        - WebKit
                        - Presto
                        - Trident
        types:
            all: '*/*'
            atom: application/atom+xml
            css: text/css
            csv: text/csv
            form: application/x-www-form-urlencoded
            html:
              - text/html
              - application/xhtml+xml
            js: text/javascript
            json:
              - application/json
              - text/json
            multipartForm: multipart/form-data
            pdf: application/pdf
            rss: application/rss+xml
            text: text/plain
            hal:
              - application/hal+json
              - application/hal+xml
            xml:
              - text/xml
              - application/xml
    urlmapping:
        cache:
            maxsize: 1000
    controllers:
        defaultScope: singleton
    converters:
        encoding: UTF-8
    views:
        default:
            codec: html
        gsp:
            encoding: UTF-8
            htmlcodec: xml
            codecs:
                expression: html
                scriptlets: html
                taglib: none
                staticparts: none
endpoints:
    jmx:
        unique-names: true

and I put the jdbc driver into here: jdbc driver

Hope someone can solve my problem

Thank You Very Much!!!

To allow your application to use Oracle as a database, you have to add the jar file of Oracle jdbc driver into the Lib folder, inside your project directory. This can be done by simply copying the driver file into the Lib folder. After that, simply modify your Application.yml file.

假设您使用的是JDK,请将您的Oracle jar放在[JAVA_HOME] / jre / lib / ext中

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM