package org.airsonic.player.dao;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;

import javax.sql.DataSource;

public class GenericDaoHelper implements DaoHelper {

    final JdbcTemplate jdbcTemplate;

    final NamedParameterJdbcTemplate namedParameterJdbcTemplate;

    final DataSource dataSource;

    public GenericDaoHelper(
            DataSource dataSource
    ) {
        this.dataSource = dataSource;
        this.jdbcTemplate = new JdbcTemplate(dataSource);
        this.namedParameterJdbcTemplate = new NamedParameterJdbcTemplate(dataSource);
    }

    @Override
    public JdbcTemplate getJdbcTemplate() {
        return jdbcTemplate;
    }

    @Override
    public NamedParameterJdbcTemplate getNamedParameterJdbcTemplate() {
        return namedParameterJdbcTemplate;
    }

    @Override
    public DataSource getDataSource() {
        return dataSource;
    }
}
