Julia
Julia

Reputation: 61

Spring Boot cannot successfully POST data to db (ORA-00942)

I'm new to Spring Boot. I've stucked in the problem of creating new data (POST) for a whole day. The error shows that I did not connect successfully to the db (ORA-00942).

Due to some privacy issues, I cannot copy-paste my work through my device. Therefore, I'm going to try my best to describe my logic and type out part of my codes. Any ideas would be a huge help! Thanks a million!

  1. I have five packages here, which are basically classified by (1.)SpringBootApplication package, (2.)Repository package(3.)Service package (4.)Controller package (5.)Entity package
  2. Basically, I do not edit in (1.)SpringBootApplication package, it's kept originally as default.
  3. In my (5.)Entity package, I have written an Entity class that matches my db. Let's say the class name of this Entity is called TitleOfMyDb. Here, Ive written the correspond @id properly, and I also write the setters and getters correctly.
  4. In the (3.)Service package, there is an Interface and a class. The class is basically the implementation of the interface. Now, this is the trimmed implementation of the service class.
@Autowired 
private ExRepository exRepository;

@Overrride
public TitleOfMyDb createExampleMethod(String a, String b){
TitleOfMyDb titleOfMyDb = new TitleOfMyDb();
titleOfMyDb .setA(a);
titleOfMyDb .setB(b);
return exRepository.save(titleOfMyDb) //save method is originated from Repository instinctively.
  1. In my (4.)Controller package, i have a class which is ExController:
 @Autowired  
private ExService exService;

 @GetMapping("/test") 
public TitleOfMyDb createSomething
(@RequestParam(value="aa") String a, @RequestParam(value="bb") String b){
TitleOfMyDb object = exService.createExampleMethod(a, b)
return object;
}
  1. In my (2.)Repository package, I do not add more codes there, it's kept originally as well. because it already has the instinctive method that allows me to save() my entity with the repository.

Afterwards, when I try to run my spring boot, it shows error of ORA-00942. Also, when I type http://localhost:8080/test through my browser, I can only see nothing but error. The error message was quite complex, sorry that I really cannot copy-paste it through my device. Basically, it does not connect to my db properly. Any help or guide on my logic and thinking process is really appreciated. Thank you!!!

Upvotes: 0

Views: 309

Answers (2)

trung92dnit
trung92dnit

Reputation: 1

Error mean you don't have permision or your table incorrect. Please check entity. Make sure table : TitleOfMyDb exist in database. If you don't specific table with anotation @table hibernate automatic pick your name entity TitleOfMyDb

Upvotes: 0

libanbn
libanbn

Reputation: 270

ORA-00942: table or view does not exist

"You tried to execute a SQL statement that references a table or view that either does not exist, that you do not have access to, or that belongs to another schema and you didn't reference the table by the schema name."

I'd see if the database table is correct and double check the SQL query.

Ref: https://www.techonthenet.com/oracle/errors/ora00942.php

Upvotes: 0

Related Questions