cancel
Showing results for 
Search instead for 
Did you mean: 
Iivo
Mission Specialist
Mission Specialist
  • 1,488 Views

AD421 MySQL connection with camel-jpa

Hello,

I'm studying the AD421 Camel Development course and for practice I'm trying to connect Camel to a MySQL server with camel-jpa in a new project (started the project from scratch). The Camel component reference is quite thin and I think I'm stuck with configuring the persistenceUnit (documentation says it is "required" and that's about it). I tried to copy some code from the "schedule-database" exercise, for example persistence.xml and configuration from camel context, but didn't succeed. It currently complains about "javax.persistence.PersistenceException: No persistence providers available for "mysql" after trying the following discovered implementations: NONE".

What steps are required to configure an empty project to use MySQL with camel-jpa? Which dependencies are required in pom.xml? What configuration is required? Do you have some starter template with the bare minimum configuration?

Thank you!

Labels (1)
0 Kudos
1 Reply
Iivo
Mission Specialist
Mission Specialist
  • 1,275 Views

I was able to use these starters:

POM:
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-sql-starter</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>

<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.29</version>
</dependency>

application.properties:
spring.datasource.url=jdbc:mysql://hostname/database
spring.datasource.username=username
spring.datasource.password=password
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

and then in route:

.to("sql:select * from words where word=:#word")

0 Kudos
Join the discussion
You must log in to join this conversation.