Я хочу получать информацию о домене через Whois и отображать информацию в утилите cURL.Я написал код, но я запускаю проект, я получаю сообщение об ошибке.Кроме того, когда я хочу узнать информацию о домене в терминале, выдает ошибку.Когда я запускаю через netbins, он выдает эту ошибку
Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) on project whois: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1]
To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.
For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Когда я хочу узнать информацию о домене, выдается такая ошибка
C:\Users\Adil>curl -H "Content-Type: application/json" -d "{\"domain\":\"ххх.kz\"}"
localhost:8080/api/whois
{"timestamp":"2019-09-23T03:12:55.405+0000","status":500,"error":"Internal Server Error","message":"Failed to obtain JDBC Connection; nested exception is java.sql.SQLException: Access denied for user 'root'@'localhost' (using password: YES)","path":"/api/whois"}
Временная модель
@Data
@AllArgsConstructor
@ToString
public class TemporaryModel {
Long id;
Long oid;
String name;
Long tld;
String registrant;
String c_admin;
String c_tech;
String c_bill;
Date expired;
}
WhoisAppliaction
@SpringBootApplication
public class WhoisApplication {
public static void main(String[] args) {
SpringApplication.run(WhoisApplication.class, args);
}
@PostConstruct
public void init() {
// Setting Spring Boot SetTimeZone
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
}
}
WhoisResponce
@Data
public class WhoisResponse {
private DomainInfo info;
private Agent agent;
private List<NameServerInfo> nameServerInfos;
public WhoisResponse(DomainInfo info, Agent agent, List<NameServerInfo> nameServerInfos) {
this.info = info;
this.agent = agent;
this.nameServerInfos = nameServerInfos;
}
}
Агент
@Data
public class Agent {
String NIC;
String name;
String phone;
String fax;
String email;
}
DomainInfo
@Data
@AllArgsConstructor
public class DomainInfo {
String domainName;
String name;
String organizationName;
String streetAddress;
String city;
String state;
String postalCode;
String country;
LocalDateTime domainCreated;
LocalDateTime lastModified;
String status;
String registarCreated;
String currentRegistar;
}
NameServerInfo
public class NameServerInfo {
String url;
String ip;
}
Репозиторий
@org.springframework.stereotype.Repository
public class Repository {
private static Logger logger = Logger.getLogger(Repository.class.getName());
@Autowired
private JdbcTemplate template;
private String findDomainInfo = "select * from r_domain where name = ?";
public TemporaryModel findDomainInfo(String domain) {
logger.log(Level.INFO, "searching by domain: " + domain);
try {
TemporaryModel temporaryModel = template.queryForObject(
findDomainInfo,
new Object[]{domain},
new DomainRowMapper()
);
logger.log(Level.INFO, "found: " + temporaryModel);
return temporaryModel;
} catch (EmptyResultDataAccessException e) {
logger.log(Level.INFO, "not found by domain: " + domain);
return null;
}
}
}
class DomainRowMapper implements RowMapper<TemporaryModel> {
@Override
public TemporaryModel mapRow(ResultSet rs, int i) throws SQLException {
return new TemporaryModel(
rs.getLong("id"),
rs.getLong("oid"),
rs.getString("name"),
rs.getLong("tld"),
rs.getString("registrant"),
rs.getString("c_admin"),
rs.getString("c_tech"),
rs.getString("c_bill"),
rs.getDate("expired")
);
}
}
Контроллер
@RestController
@RequestMapping("api/whois")
public class Controller {
@Autowired
Repository repository;
@PostMapping
public TemporaryModel whois(@RequestBody Request request) {
return repository.findDomainInfo(request.domain);
}
}
Свойства приложения
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/domain31?serverTimezone=UTC
spring.datasource.username=root
spring.datasource.password=123456