package net.sevecek.dailyplanet;

import java.sql.*;
import javax.sql.*;
import org.mariadb.jdbc.*;
import org.springframework.context.annotation.*;
import org.springframework.dao.*;
import org.springframework.jdbc.core.*;
import org.springframework.jdbc.datasource.*;
import org.springframework.transaction.*;
import org.springframework.transaction.annotation.*;
import org.springframework.web.servlet.config.annotation.*;
import net.sevecek.boot.standalone.*;
import net.sevecek.boot.war.*;

@Configuration
@ComponentScan
@EnableWebMvc
public class ApplicationConfig extends DefaultWebMvcConfigurer {

    @Bean
    public DataSource dataSource() throws SQLException {
        MariaDbDataSource dataSource;
        dataSource = new MariaDbDataSource();
        dataSource.setUrl("jdbc:mysql://localhost/DailyPlanet");
        dataSource.setUser("student");
        dataSource.setPassword("password");
        return dataSource;
    }

    @Bean
    public JdbcTemplate pokladacDotazu(DataSource dataSource) {
        JdbcTemplate pokladacDotazu;
        pokladacDotazu = new JdbcTemplate(dataSource);
        return pokladacDotazu;
    }

    @Bean
    public RowMapper<Autor> prevodnikTridyAutor() {
        RowMapper<Autor> prevodnikTridyAutor;
        prevodnikTridyAutor = BeanPropertyRowMapper.newInstance(Autor.class);
        return prevodnikTridyAutor;
    }

}
