java - Change dataset according to url path -
i have java spring boot project 3 webservices each uses different databases. databases work fine, , using annotations have managed switch databases according services. thing need change connection according 1 of path parameters.
my service:
@service public class clientservice { @autowired @qualifier("client") // set client db private jdbctemplate jdbctemplate; @transactional(readonly=true) public list<clientdto> findclient(string clientnum) { string sql = "select * client cli_number = ? "; return jdbctemplate.query(sql, new object[] {client}, new clientdtorowmapper());}
in controller have:
@requestmapping("/client")
and
@requestmapping(value = "/{clientnum}/", method = requestmethod.get)
i need pass countryid on path, , change db according countryid, without having declare different webservices each country,as use same query.
path should be:
@requestmapping(value = "/{clientnum}/{countryid}'", method = requestmethod.get)
and
if countryid = 1 @qualifier(clientdb1) elseif countryid = 2 @qualifier(clientdb2) else @qualifier(clientdb3)
i have tried changing @qualifier inside findclient doesn't work.
Comments
Post a Comment