This tutorial will walk you through the process of creating a jOOQ example with MySQL.
What you'll need
- JDK 1.7+
- Maven 3+
- MySQL 5.6+
Stack
- Java
- jOOQ
Init project structure, dependencies and database
Project structure
├── src
│ └── main
│ └── java
│ └── com
│ └── hellokoding
│ └── jooq
│ ├── model
│ │ ├── tables
│ │ │ ├── records
│ │ │ │ └── AuthorRecord.java
│ │ │ └── Author.java
│ │ ├── DefaultCatalog.java
│ │ ├── Keys.java
│ │ ├── Library.java
│ │ └── Tables.java
│ └── Application.java
├── create_db.sql
└── pom.xml
Files and sub-directories in com/hellokoding/jooq/model
directory will be auto generated by jOOQ. We only play with pom.xml
, create_db.sql
and com/hellokoding/jooq/Application.java
Project dependencies
jooq-codegen-maven
plugin's used for generate domain and DAO objects in com/hellokoding/jooq/model
Create database
Run below script to create a sample MySQL database
Run
System.property()
's bound to systemProperty
of exec-maven-plugin
configuration in pom.xml
Run with this command mvn clean compile exec:java -Dexec.mainClass=com.hellokoding.jooq.Application -Dexec.cleanupDaemonThreads=false
Source code
https://github.com/hellokoding/hellokoding-courses/tree/master/java-examples/java-jooq-mysql