Search code examples
springoracleoracle-cloud-infrastructurewallet

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


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


Solution

  • i resolved this way,

    spring:
      datasource:
        driver-class-name: oracle.jdbc.OracleDriver
        url: jdbc:oracle:thin:@<***TLSNAME>?TNS_ADMIN=D:/Wallet
        username: username
        password: password