Hi I have some code which has a couple of errors which i cannot find a solution.
Below is code to access the unix environment in java using shhtools. I however get errors around the shh.connect and FTPException statements. Could someone have a look and let me know what I need to add to fix these problems please
Many thanks
CODE
package DataCapture;
public class Main {
public static void main(String args[]) {
String serverName = "xx";
String portNumber = "xx";
String userName = "xx";
String password = "xx";
String databaseName = "xx";
UnixConn Uconn = new UnixConn(serverName, portNumber, userName, password);
}
}
CODE
public class UnixConn {
public UnixConn(String serverName, String portNumber, String userName, String password){
String host = serverName;
String port = portNumber;
String filePath ="";
SshClient ssh = new SshClient();
ssh.connect(host, port); //The method connect(String, HostKeyVerification) in the type SshClient is not applicable for the arguments (String, String)
//Authenticate
PasswordAuthenticationClient passwordAuthenticationClient = new PasswordAuthenticationClient();
passwordAuthenticationClient.setUsername(userName);
passwordAuthenticationClient.setPassword(password);
int result = ssh.authenticate(passwordAuthenticationClient);
if(result != AuthenticationProtocolState.COMPLETE){
throw new FTPException("Login to " + host + ":" + port + " " + userName + "/" + password + " failed"); //FTPException cannot be resolved to a type
}
//Open the SFTP channel
SftpClient client = ssh.openSftpClient();
//Send the file
client.put(filePath);
//disconnect
client.quit();
ssh.disconnect();
}
}