//保存邮件信息
public boolean saveEmail(EmailDTO emailDTO,Connection conn)
{
String preSql = "insert into emailinfo values(?,?,?,?,?)";
PreparedStatement pstmt = null;
try
{
pstmt = conn.prepareStatement(preSql);
pstmt.setString(1, emailDTO.getMailDate());
pstmt.setString(2, emailDTO.getFromList());
pstmt.setString(3, emailDTO.getTitle());
pstmt.setString(4, emailDTO.getContent());
if (emailDTO.getAttFilePath() != null) {
pstmt.setString(5, emailDTO.getAttFilePath());
}
else {
pstmt.setString(5, "");
}
pstmt.setString(6, emailDTO.getUserID());
int flag = pstmt.executeUpdate();
if (flag == 1)
{
return true;
}
}
catch(SQLException e)
{
e.printStackTrace();
}
finally
{
close(pstmt,null);
}
return false;
}
按照书上所说,finally中的程序段是肯定会执行的,但是在try的大括号中有句return true,不明白的是,如果return true已经执行了,finally会不会执行到,程序应该是按顺序执行的,但这里不清楚它的流程!谢谢!!
德玛西亚99
长风秋雁
相关分类