Java Reference
In-Depth Information
DataSource ds = tds;
Connection con = ds.getConnection(dbUserName,dbPassword);
Statement stmt;
ResultSet rs = null;
String SQLQuery = "SELECT l.Password, c.Email FROM LOGIN l, "+
"CONTACTINFO c WHERE l.MemberID = c.MemberID "+
"AND UserName = '"+username+"';";
stmt = con.createStatement();
rs = stmt.executeQuery(SQLQuery);
while(rs.next()){
password = rs.getString("Password");
email = rs.getString("Email");
}
con.close();
}catch(ClassNotFoundException e1){
System.err.println(e1.getMessage());
}catch(SQLException e2){
System.err.println(e2.getMessage());
}
if(email==null){
return "Bad Email";
}else{
emailPassword(email,username,password);
return "OK";
}
}
public void emailPassword(String email,String memberName,String
password){
String host = "mail";
String from = "webmaster@j-machines.com";
Properties props = System.getProperties();
props.put("mail.smtp.host", host);
// Get session
Session session = Session.getDefaultInstance(props, null);
// Define message
Search WWH ::




Custom Search