我正在创建一个ruby脚本来检查url的响应状态,如果它等于504,它会将邮件发送到另一个电子邮件地址.出于某种原因,我得到了这个:/usr/lib/ruby/1.9.1/net/smtp.rb:960:in 'check_auth_response': 534-5.7.14 <https://accounts.google.com/ContinueSignIn?sarp=1&scc=1&plt=AKgnsbv9z (Net::SMTPAuthenticationError)
我检查了身份验证数据并且它们是有效的.也许代码中可能存在错误:
require 'mail'
options = { :address => "smtp.gmail.com",
:port => 587,
:user_name => '<myusername>',
:password => '<mypassword>',
:authentication => 'plain',
:enable_starttls_auto => true }
Mail.defaults do
delivery_method :smtp, options
end
Mail.deliver do
to 'dude920228@gmail.com'
from 'dude92@dude92.koding.com'
subject 'Test'
body 'Hurray!!! Test email!'
end
Run Code Online (Sandbox Code Playgroud)
哦,我收到谷歌的通知,一个不太安全的应用程序试图访问我的帐户,所以我设置不太安全的应用程序可以使用我的帐户.
我有一个连接到MySQL数据库的类.我想让它更具普遍性.我不确定自己.如果指定数据库名称,我的类可以连接任何服务器.
String url="jdbc:mysql://"+host+":"+port+"/"+dbname;
Run Code Online (Sandbox Code Playgroud)
有人能告诉我,如何在没有指定数据库名称的情况下连接(例如使用create database命令)?使用是否正确:
String url="jdbc:mysql://"+host+":"+port
Run Code Online (Sandbox Code Playgroud)
或者它使用其他语法?提前致谢!
我正在尝试使用JSch在Java中实现图形ssh浏览器。我想检索一个ChannelSftp.ls调用的结果,但是它给了我一个nullpointer异常...我检查了会话,它已打开并登录。当我打开exec的通道并发送ls命令时,我可以检索到目录内容为String。代码如下:
public Vector listContents () {
Channel channel = null;
ConnectionThread conn = SSHBrowser.conn;
Session sess = conn.getSession();
System.out.println(sess.getUserName()); //prints out the given username, not null, so the session is initialized
try {
channel = sess.openChannel("sftp");
} catch (JSchException ex) {
ex.printStackTrace();
}
Vector<ChannelSftp.LsEntry> result = null;
try {
result = ((ChannelSftp) channel).ls("/srv"); // throws nullpointer here
for (ChannelSftp.LsEntry dir : result) {
System.out.print(dir.getLongname());
}
} catch (SftpException e) {
e.printStackTrace();
}
return result;
}
Run Code Online (Sandbox Code Playgroud)
我得到的堆栈跟踪如下:
at com.jcraft.jsch.ChannelSftp.ls(ChannelSftp.java:1747) …Run Code Online (Sandbox Code Playgroud)