Skip to content

Instantly share code, notes, and snippets.

@dnaismyth
Created October 28, 2017 17:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dnaismyth/7fe0def16462a1437ce32ed42a639dae to your computer and use it in GitHub Desktop.
Save dnaismyth/7fe0def16462a1437ce32ed42a639dae to your computer and use it in GitHub Desktop.
Base JDBC parent class
import javax.sql.DataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
@Repository
@Transactional
public class BaseJDBCRepository {
@Autowired
private Environment environment;
protected NamedParameterJdbcTemplate jdbcTemplate;
@Autowired
public void setDataSource(DataSource dataSource){
this.jdbcTemplate = new NamedParameterJdbcTemplate(dataSource);
}
public String readQueryFromProperties(String query){
return environment.getProperty(query);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment