Reputation: 673
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.
Upvotes: 1
Views: 7464
Reputation: 4647
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!!!
Upvotes: 2