Using Spring JdbcTemplate to store and retrive values into DB

In This example i will demonstrate you Spring example to insert and select values from oracle DB. The insertForum() method below shows the amount of code you need to write to insert data using JDBC.

1. Create Java POJO Class ex. Forum which contains getter and setter method for field as mentioned below.
    private int forumId;
    private String forumName;
    private String forumDesc;


1.1 create parameterized constructor as below.
  public Forum(int forumId, String forumName, String forumDesc) {
        this.forumId = forumId;
        this.forumName = forumName;
        this.forumDesc = forumDesc;
    }
 

2. Create Interface ex. ForumDAO which contains insert and select methods
package com.learning.dao;
import com.learning.core.Forum;
public interface ForumDAO {

    public void insertForum(Forum forum);
    public Forum selectForum(int forumId);
}