error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jesmi
    New Member
    • Apr 2007
    • 53

    error

    public void sendMail(String smtpServer,Stri ng to,String from,String subject,String body ) throws Exception{


    try{
    SendMail.send(s mtpServer,to,fr om,subject,body );

    log.info("Mail delivered to: " +to);
    System.out.prin t("Mail Delivered !!!"+to);


    try{
    Connection con = null;
    PreparedStateme nt stmt = null;
    ResultSet rs = null;
    List result=null;
    Map resultMap = null;
    con = Utilities.getDb Connection();
    result = new ArrayList();


    stmt = con.prepareStat ement("INSERT INTO call_history " +
    "(pis_cd,email, remarks) " +
    " values(?,?,?)") ;

    stmt.setString( 1,pisCd);
    stmt.setString( 2,email);
    stmt.setString( 3,remarks);

    stmt.executeUpd ate();

    con.commit();
    log.info("Added a new message: " + pisCd +" by "+ pisCd);
    //System.out.prin tln("Added a new bank: " + bankDesc +" by "+ us.getName());
    }

    //error starts from here
    catch (SQLException errSql){
    con.rollback();
    log.error("err: "+ errSql);
    throw errSql;

    }}
    catch (Exception err){
    if (con != null) con.rollback();
    log.error("err: "+ err);
    throw err;

    }finally {

    try {
    if (rs != null) rs.close();
    if (stmt != null) stmt.close();
    if (con != null) con.close();

    } catch (Exception err){
    log.debug("cant send mail due to: "+err );
    throw new Exception(" Please check smtp, admin email address. "+err);
    }
    }

    }

    error in stmt,con,rs

    plz help me
  • r035198x
    MVP
    • Sep 2006
    • 13225

    #2
    Originally posted by jesmi
    public void sendMail(String smtpServer,Stri ng to,String from,String subject,String body ) throws Exception{


    try{
    SendMail.send(s mtpServer,to,fr om,subject,body );

    log.info("Mail delivered to: " +to);
    System.out.prin t("Mail Delivered !!!"+to);


    try{
    Connection con = null;
    PreparedStateme nt stmt = null;
    ResultSet rs = null;
    List result=null;
    Map resultMap = null;
    con = Utilities.getDb Connection();
    result = new ArrayList();


    stmt = con.prepareStat ement("INSERT INTO call_history " +
    "(pis_cd,email, remarks) " +
    " values(?,?,?)") ;

    stmt.setString( 1,pisCd);
    stmt.setString( 2,email);
    stmt.setString( 3,remarks);

    stmt.executeUpd ate();

    con.commit();
    log.info("Added a new message: " + pisCd +" by "+ pisCd);
    //System.out.prin tln("Added a new bank: " + bankDesc +" by "+ us.getName());
    }

    //error starts from here
    catch (SQLException errSql){
    con.rollback();
    log.error("err: "+ errSql);
    throw errSql;

    }}
    catch (Exception err){
    if (con != null) con.rollback();
    log.error("err: "+ err);
    throw err;

    }finally {

    try {
    if (rs != null) rs.close();
    if (stmt != null) stmt.close();
    if (con != null) con.close();

    } catch (Exception err){
    log.debug("cant send mail due to: "+err );
    throw new Exception(" Please check smtp, admin email address. "+err);
    }
    }

    }

    error in stmt,con,rs

    plz help me
    1.) Please use code tags when posting code
    2.) What errors are you getting?

    Comment

    • hirak1984
      Contributor
      • Jan 2007
      • 316

      #3
      It seems that u have errors regarding database connection and not in mailing program1
      can u explain the exact errors u got?
      Originally posted by jesmi
      public void sendMail(String smtpServer,Stri ng to,String from,String subject,String body ) throws Exception{


      try{
      SendMail.send(s mtpServer,to,fr om,subject,body );

      log.info("Mail delivered to: " +to);
      System.out.prin t("Mail Delivered !!!"+to);


      try{
      Connection con = null;
      PreparedStateme nt stmt = null;
      ResultSet rs = null;
      List result=null;
      Map resultMap = null;
      con = Utilities.getDb Connection();
      result = new ArrayList();


      stmt = con.prepareStat ement("INSERT INTO call_history " +
      "(pis_cd,email, remarks) " +
      " values(?,?,?)") ;

      stmt.setString( 1,pisCd);
      stmt.setString( 2,email);
      stmt.setString( 3,remarks);

      stmt.executeUpd ate();

      con.commit();
      log.info("Added a new message: " + pisCd +" by "+ pisCd);
      //System.out.prin tln("Added a new bank: " + bankDesc +" by "+ us.getName());
      }

      //error starts from here
      catch (SQLException errSql){
      con.rollback();
      log.error("err: "+ errSql);
      throw errSql;

      }}
      catch (Exception err){
      if (con != null) con.rollback();
      log.error("err: "+ err);
      throw err;

      }finally {

      try {
      if (rs != null) rs.close();
      if (stmt != null) stmt.close();
      if (con != null) con.close();

      } catch (Exception err){
      log.debug("cant send mail due to: "+err );
      throw new Exception(" Please check smtp, admin email address. "+err);
      }
      }

      }

      error in stmt,con,rs

      plz help me

      Comment

      Working...