package hls.plugin.weixin.qiye;

import java.io.PrintStream;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.SQLException;

public class WeCatDaoImpl
  implements IWeChatDao
{
  public static void main(String[] args)
  {
    FndAtmAttachment fnd = new FndAtmAttachment("1", "1", "1", "1", 1, "1", 1, "1", "1");
    boolean ss = new WeCatDaoImpl().save(fnd);
    System.out.println(ss);
  }

  public boolean save(FndAtmAttachment fnd) {
    boolean success = false;
    Connection conn = null;
    CallableStatement pst = null;
    try {
      conn = DBUtil.getConnection();
      pst = conn
        .prepareCall("{ call fnd_atm_attachment_all_pkg.insert_fnd_atm_attachment(?,?,?,?,?,?,?,?,?,?) }");
      pst.registerOutParameter(1, 4);
      pst.setString(2, fnd.getSource_pk_value());
      pst.setString(3, fnd.getFile_type_code());
      pst.setString(4, fnd.getMime_type());
      pst.setString(5, fnd.getFile_name());
      pst.setInt(6, fnd.getFile_size());
      pst.setString(7, fnd.getFile_path());
      pst.setInt(8, fnd.getUser_id());
      pst.setString(9, fnd.getTable_name());
      pst.setString(10, fnd.getTable_pk_value());
      pst.execute();
      conn.commit();
      success = true;
    } catch (SQLException e) {
      e.printStackTrace();
      try
      {
        if (pst != null)
          pst.close();
        if (conn != null)
          conn.close();
      } catch (SQLException e1) {
        e1.printStackTrace();
      }
    }
    finally
    {
      try
      {
        if (pst != null)
          pst.close();
        if (conn != null)
          conn.close();
      } catch (SQLException e) {
        e.printStackTrace();
      }
    }
    return success;
  }
}