SingleConnectionDataSource dataSource = new SingleConnectionDataSource(); dataSource.setDriverClassName("com.mysql.jdbc.Driver"); dataSource.setUrl("jdbc:mysql://".concat(user.getIpAddr()).concat(":").concat(user.getMysqlPort())); dataSource.setUsername(user.getMysqlLogin()); dataSource.setPassword(user.getMysqlPasswd()); jdbcTemplate = new JdbcTemplate(dataSource); then I execute the query:
extens = jdbcTemplate.query(query, ROW_MAPPER_EXTEN); so, if the remote server does not respond at all (well, for example, an error in the IP address), then I need to set a timeout for such a case.
I tried:
try { dataSource.setLoginTimeout(100); } catch (SQLException se) { log.warn(se.toString()); } But in the end an exception is generated:
java.lang.UnsupportedOperationException: setLoginTimeout