Reputation: 1
class Entity
@Entity
@Table
public class Camera {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String name;
private String place;
private String address;
public Long getId() {
return id;
}
public String getName() {
return name;
}
public String getPlace() {
return place;
}
public void setId(Long id) {
this.id = id;
}
//Constructors, getters and setters are not shown here
}
application.properties configuration file
spring.datasource.url= jdbc:mysql://localhost:3306/springbootdb
spring.datasource.username=root
spring.datasource.password=
server.port=9000
I have this error
Exception in thread "Thread-3" org.springframework.dao.InvalidDataAccessResourceUsageException: could not extract ResultSet; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet
Caused by: org.hibernate.exception.SQLGrammarException: could not extract ResultSet
Caused by: org.hibernate.exception.SQLGrammarException: could not extract ResultSet
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: La table 'springbootdb.camera' n'existe pas
I have to create manually table in the database to work :( Any idea ? is it a problem in the configuration file ?Thanks for your help :)
Upvotes: 0
Views: 3454
Reputation: 1387
Add the following property in your application.properties
file:
spring.jpa.hibernate.ddl-auto=update
This will initialize your data base. Have a look at other properties as well according to spring docs:
https://docs.spring.io/spring-boot/docs/current/reference/html/howto-database-initialization.html
Upvotes: 1