Hama Saadwn Hama Saadwn -4 years ago 85
Java Question

Why I can't use @PathVariable?

I can't find the problem in my code, I want to retrieve data by using an id from the link and @PathVariable

my controller :

@RequestMapping( "/reklam" )
public class RklamController {

public String reklamPage(@PathVariable String advertise_id, ModelMap model) throws IOException {

DataSource dataSource = DataSourceGenerator.getDataSource();

AdvertiseDaoImpl adD = new AdvertiseDaoImpl(dataSource);
Advertise advertise = adD.getAd(advertise_id);

int count = advertise.getCounter();
if( count == 0 ){
count = 1;
count += 1;


model.addAttribute("advertise", advertise);

return "reklam"; } }

and dao :

public Advertise getAd(String id) {

JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);

String sql = " select * from Advertise where advertise_id = ? ";

Advertise advertise = (Advertise) jdbcTemplate.queryForObject(sql,new Object[]{id},
new BeanPropertyRowMapper(Advertise.class));

return advertise;
}catch (DataAccessException e){


return null;

when i run it it shows :

enter image description here

it shows this line 5 times :

Thu Mar 23 16:43:30 AST 2017 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.

Answer Source

finally i found the problem , it was because of i left some fields null in the database and i used select * query , it can be fixed buy changing the query or not leaving a field null , but i don't understood why , can anyone explain ?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download