2

I have strange problem. I can't run my spring app when I change connection from MySQL to Oracle (19c). When I am using MySQL everything is fine. My app is really simple, its doing nothing, it is sample empty project for test connection.

Here is my application.properties (MySQL):

spring.datasource.url=jdbc:mysql://localhost:3306/fckOracle
spring.datasource.username = root
spring.datasource.password = student
spring.datasource.driverClassName=com.mysql.cj.jdbc.Driver

and part of pom.xml (MySQL),

<dependency>
     <groupId>mysql</groupId>
     <artifactId>mysql-connector-java</artifactId>
     <scope>runtime</scope>
</dependency>

Here is my application.properties (Oracle 19c)

spring.datasource.url=jdbc:oracle:thin:@localhost:1521:orcl
spring.datasource.username=ALBERT
spring.datasource.password=student
spring.datasource.driver-class-name=oracle.jdbc.OracleDriver

and part of pom.xml (Oracle 19c)

<dependency>
     <groupId>com.oracle.ojdbc</groupId>
     <artifactId>ojdbc8</artifactId>
</dependency>

Okay, when I am trying to run my app with oracle connection, compiler can't load dialect. Program is frozen and localhost:8080 doesn't work, and here is my console: enter image description here

I have tried a lot of dialects Oracle12cDialect, Oracle10gDialect..., result is always the same, with one exception! When I change the dialect to this:

spring.jpa.database-platform=org.hibernate.dialect.HSQLDialect

My app starts, but with error:

java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist

localhost8080 is working, but I cant do any operation on my oracle database.

Anyone have idea how to fix this oracle configuration?

Harry Coder
  • 2,429
  • 2
  • 28
  • 32
Harord
  • 57
  • 1
  • 2
  • 10
  • Did you try this? https://stackoverflow.com/questions/57715024/hibernate-dialect-for-oracle-19 – aksappy Dec 27 '19 at 17:13
  • Well, yes i saw that but i am not full understand what is the problem. Did hibernate get some bug with dialect 12c? In that post, that guy said, "It is already solved in the newer 5.4 releases" My version of hibernate is 5.4.9.Final. Then i think this problem does not concern me, is it? – Harord Dec 27 '19 at 17:20
  • did you try setting your dialect to `hibernate.dialect = org.hibernate.dialect.Oracle12cDialect` and remove any other properties related to other **database dialects**. – Brooklyn99 Dec 27 '19 at 17:30
  • did you tried ``` com.oracle.ojdbc ojdbc10 19.3.0.0 ``` – RamPrakash Dec 27 '19 at 17:31
  • Santossh Kumhar, i did :/ RamPrakash, i tried this and i get that error: https://textuploader.com/1oycz – Harord Dec 27 '19 at 17:44
  • Which version Java are you using? – Harry Coder Dec 27 '19 at 17:52
  • java 1.8 ...... – Harord Dec 27 '19 at 17:57
  • The exception message is self-explanatory: table or view does not exist. There is a missing table or view in your database schema, that your application needs. It has nothing to do with a dialect (which shouldn't be set to HSQLDialect, since you're using Oracle, and not MySQL). – JB Nizet Dec 27 '19 at 18:02
  • JB Nizet, if i change dialect to (for example): Oracle12cDialect, i dont have any errors. My app is frozen while loading dialect. – Harord Dec 27 '19 at 18:07
  • What makes you think it's frozen? And why do you set the dialect instead of letting Hibernate discover which one to use by itself? – JB Nizet Dec 27 '19 at 18:16
  • It's frozen because my localhost:8080 doesn't work. And any java code after line "SpringApplication.run(DemoApplication.class, args);" aren't executed. When i change my database connection to MySQL, everything is okay (localhost:8080 works) and java code after that line "springapplication.run" are executed – Harord Dec 27 '19 at 18:27
  • If i will set dialect or i will not, it really doesn't matter. Problem is the same. My program is frozen while loading dialect. When i am using MySQL i dont have that problem. – Harord Dec 27 '19 at 18:30
  • `And any java code after line "SpringApplication.run(DemoApplication.class, args);" aren't executed.` What lines of code are you talking about? – Toerktumlare Dec 27 '19 at 23:19
  • Well i meant that was that line which is executing in spring apps to launch app. That was all my program, only that line. If i put some code under that line spring.run, this code won't be executed. That was happen when i was using oracle instead of mysql. Doesn't matter now... I donwloaded oracle 11gR2 and that was solution to my problem :/ – Harord Dec 28 '19 at 00:55
  • Can you please show your Applicaton class? – Simon Martinelli Dec 28 '19 at 10:11
  • https://textuploader.com/1oy25 – Harord Dec 28 '19 at 15:58

1 Answers1

1

I have exact same issue, one thing that helps is to use old ojdbc8 driver for oracle DB, so replace your existing one with:

<dependency>
    <groupId>com.oracle.database.jdbc</groupId>
    <artifactId>ojdbc8</artifactId>
    <version>12.2.0.1</version>
</dependency>

But I would love to see the solution for newer drivers, because I have exact same problem and I have to use 19.3.0.0 drivers

Also about this error

java.sql.SQLSyntaxErrorException: ORA-00942: table or view does not exist

Try setting spring.jpa.hibernate.ddl-auto to update or create-drop. This way Hibernate will generate schema and tables automaticaly and also drop them (when used create-drop). It is especially usefull, when you are still experimenting with model of your application.

Jacek Sawko
  • 190
  • 2
  • 7