Access Database with Java using JDBC

Last updated: 2025-09-14

Steps:

  1. Create Maven project with the following pom.xml:

Unresolved include directive in modules/6.x.x/pages/frameworks/jk-framework/jk-framework-data/java-simple-jdbc-tutorial.adoc - include::inc/simple/pom.xml[]

If you are using Eclipse, be sure to refresh your project (select your project→ right click→ Maven→ Update Project)

  1. Create database script file and place it at src/main/resources/script.sql with the following contents:

Unresolved include directive in modules/6.x.x/pages/frameworks/jk-framework/jk-framework-data/java-simple-jdbc-tutorial.adoc - include::inc/simple/src/main/resources/script.sql[]
  1. Create config file at src/main/resources/config.properties with the following contents:

Unresolved include directive in modules/6.x.x/pages/frameworks/jk-framework/jk-framework-data/java-simple-jdbc-tutorial.adoc - include::inc/simple/src/main/resources/config.properties[]
  1. Create class Account as a model at src/main/java/com/app/models/Account.java with the following contents:

Unresolved include directive in modules/6.x.x/pages/frameworks/jk-framework/jk-framework-data/java-simple-jdbc-tutorial.adoc - include::inc/simple/src/main/java/com/app/models/Account.java[]
  1. Create class Account2 as a model at src/main/java/com/app/models/Account2.java with the following contents:

Unresolved include directive in modules/6.x.x/pages/frameworks/jk-framework/jk-framework-data/java-simple-jdbc-tutorial.adoc - include::inc/simple/src/main/java/com/app/models/Account2.java[]
  1. Create App class at src/main/java/com/app/App.java with the following contents:

Unresolved include directive in modules/6.x.x/pages/frameworks/jk-framework/jk-framework-data/java-simple-jdbc-tutorial.adoc - include::inc/simple/src/main/java/com/app/App.java[]

Thats it, now run your App class.

Output

Full example source-code can be found at https://github.com/smartapi-com/j-framework-data-jdbc-example