Home > Mobile >  How to connect Spring and Oracle db (oracle cloud) 19c
How to connect Spring and Oracle db (oracle cloud) 19c

Time:10-08

if i try to connect this error show oracle.net.ns.NetException: Invalid connection string format, a valid format is: "host:port:sid" (CONNECTION_ID=plSfz1GBTiKKWbZqZbjUrA==)

i think yml datasource or jpa is wrong... but I checked out gogle anywhere but, oracle cloud(wallet) <-> spring is I can't found it plz help me!

this is my build.gradle

plugins {
    id 'org.springframework.boot' version '2.5.4'
    id 'io.spring.dependency-management' version '1.0.11.RELEASE'
    id 'java'
    id 'war'
}

group = ''
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'

configurations {
    compileOnly {
        extendsFrom annotationProcessor
    }
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.projectlombok:lombok:1.18.20'
    implementation 'junit:junit:4.13.1'
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    compileOnly 'org.projectlombok:lombok:1.18.12'
    annotationProcessor 'org.projectlombok:lombok:1.18.12'
    runtimeOnly 'com.oracle.database.jdbc:ojdbc8'
    implementation 'com.oracle.ojdbc:ucp'
    implementation 'com.oracle.database.security:oraclepki'
    implementation 'com.oracle.database.security:osdt_core'
    implementation 'com.oracle.database.security:osdt_cert'
    annotationProcessor 'org.projectlombok:lombok'
    providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

test {
    useJUnitPlatform()
}

this is my application.yml

# local, dev, prod 공통 설정
server:
  port: 8080
  tomcat:
    uri-encoding: UTF-8





spring:
  datasource:
    driver-class-name: oracle.jdbc.OracleDriver
    url: jdbc:oracle:thin:@[TNSNAME]?TNS_ADMIN=./src/main/resources/Wallet
    username: 
    password: 
  jpa:
    database-platform: org.hibernate.dialect.Oracle12cDialect
    open-in-view: true
    hibernate:
      ddl-auto: none
#      ddl-auto: create-drop
#      ddl-auto: validate

CodePudding user response:

Follow this descriptive blog and tally the configuration steps performed Configuring the Oracle JDBC drivers in a SpringBoot project

CodePudding user response:

if You use TNS_ADMIN, it has to be path to TNS_ADMIN file, and Your connection has to be declared in tnsnames.ora. I hope that this helps: https://docs.oracle.com/en/cloud/paas/autonomous-database/adbsa/connect-jdbc-thin-wallet.html#GUID-BE543CFD-6FB4-4C5B-A2EA-9638EC30900D Please read. If this doesn't help, then we'll try something else.

Best regards, Aleksandar

  • Related