Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.antonromanov.springboothelloworld;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.jdbc.core.JdbcTemplate;
- import org.springframework.stereotype.Service;
- import javax.sql.DataSource;
- @Service
- public class DaoService {
- private final JdbcTemplate template;
- public int getCount() {
- return template.queryForObject(
- "SELECT COUNT(*) FROM test_jdbc.public.user", Integer.class);
- }
- @Autowired
- public DaoService(DataSource dataSource) {
- this.template = new JdbcTemplate(dataSource);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement