Connexion BDD v1

This commit is contained in:
jleroy
2024-04-23 08:12:45 +02:00
parent 2fcafc0ea1
commit b253aa55b0
4 changed files with 46 additions and 3 deletions

View File

@@ -17,6 +17,7 @@ import java.util.List;
@Repository
@Primary
public class ArticleRepositoryImpl implements ArticleRepository {
private static final Logger logger = LoggerFactory.getLogger(ArticleRepositoryImpl.class);
private JdbcTemplate jdbcTemplate;
private NamedParameterJdbcTemplate namedJdbcTemplate;
@@ -37,17 +38,16 @@ public class ArticleRepositoryImpl implements ArticleRepository {
return article;
}
}
public ArticleRepositoryImpl(JdbcTemplate jdbcTemplate, NamedParameterJdbcTemplate namedJdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;
this.namedJdbcTemplate = namedJdbcTemplate;
}
@Override
public List<Article> findAllArticle() {
String sql = "SELECT * FROM ARTICLES_VENDUS";
List<Article> articles = jdbcTemplate.query(sql, new ArticleRowMapper());
return articles;
}

View File

@@ -2,6 +2,7 @@ package fr.eni.enchere.dal;
import fr.eni.enchere.bo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
@@ -12,10 +13,12 @@ import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
@Primary
public class UserRepositoryImpl implements UserRepository {
private final JdbcTemplate jdbcTemplate;
private NamedParameterJdbcTemplate namedParameterJdbcTemplate;
@Autowired
public UserRepositoryImpl(JdbcTemplate jdbcTemplate, NamedParameterJdbcTemplate namedJdbcTemplate) {
this.jdbcTemplate = jdbcTemplate;