Access Database with Java using JDBC
Last updated: 2025-09-14
Steps:
-
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) |
-
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[]
-
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[]
-
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[]
-
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[]
-
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.

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