1

I have used spring boot in my project and I have the few properties of my oracle database that needs to be specified.They are:

Schema Name=OWNER
Password=OWNER
Database Name=DCGCDB

It is located in my server so the IP to connect is 192.168.1.5 and the Port Number is 1521.

So in my application.properties file i have made some settings to connect database and here it is:

# Oracle settings
spring.datasource.url=jdbc:oracle:thin:192.168.1.5:1521:DCGCDB
spring.datasource.username=OWNER
spring.datasource.password=OWNER
spring.datasource.driver.class=oracle.jdbc.driver.OracleDriver

## Hibernate Properties
# The SQL dialect makes Hibernate generate better SQL for the chosen database
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect

# Hibernate ddl auto (create, create-drop, validate, update)
spring.jpa.hibernate.ddl-auto = update

spring.jpa.show-sql=true

# logging
logging.pattern.console=%d{yyyy-MM-dd HH:mm:ss} %-5level %logger{36} - %msg%n
logging.level.org.hibernate.SQL=debug
#logging.level.org.hibernate.type.descriptor.sql=trace
#logging.level.=debug

But when building the project I am getting error like:

o.s.b.a.orm.jpa.DatabaseLookup - Unable to determine jdbc url from
datasource org.springframework.jdbc.support.MetaDataAccessException:
Could not get Connection for extracting meta-data; nested exception is
org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to
obtain JDBC Connection; nested exception is
java.sql.SQLRecoverableException: IO Error: The Network Adapter could
not establish the connection    at
org.springframework.jdbc.support.JdbcUtils.extractDatabaseMetaData(JdbcUtils.java:328)

I have added the oracle jar file in pom.xml

<dependency>
    <groupId>com.oracle</groupId>
    <artifactId>ojdbc6</artifactId>
    <version>11.2.0</version>
</dependency>

And also executed the statement mvn install:install-file -Dfile=oracle-ojdbc6-11.2.0.3.jar -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0 -Dpackaging=jar to install the oracle jar file.

M. Deinum
  • 115,695
  • 22
  • 220
  • 224
ashwin karki
  • 643
  • 5
  • 19
  • 35

2 Answers2

2

Following the Oracle FAQ page, the way you have defined your JDBC URL is wrong. That needs correction firstly, from this:

Old JDBC URL: jdbc:oracle:thin:192.168.1.5:1521:DCGCDB

to this:

New JDBC URL: jdbc:oracle:thin@//192.168.1.5:1521/YourOracleServiceName

Considering DCGCDB is your Oracle's Service name.

Secondly, there is a difference in the dialect that is being used for Oracle. I don't know why!!!

You could possibly use org.hibernate.dialect.Oracle10gDialect for the dialect instead of org.hibernate.dialect.MySQL5InnoDBDialect.

Hope this helps!!!

N00b Pr0grammer
  • 4,503
  • 5
  • 32
  • 46
-1

Try removing DataSourceAutoConfiguration from code like this.

@SpringBootApplication
@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})

also verify all properties are set, eg.

spring.datasource.url= 
spring.datasource.username=<username>
spring.datasource.password=<password>
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.jpa.database-platform=org.hibernate.dialect.MySQL5Dialect
spring.jpa.hibernate.ddl-auto=update
Dark Knight
  • 8,218
  • 4
  • 39
  • 58