Пример #1
1
	/**
	 * 获取游戏接口参数
	 * 
	 * @param id 
	 *        游戏接口参数编号
	 * @return 游戏接口参数
     */
	public wh.game.model.GameInterfaceParams get(int id) throws Exception{
		wh.game.model.GameInterfaceParams model = null;
		Map<String, Object> inParameters = new HashMap<String, Object>();
		inParameters.put("GameInterfaceParamsId", id);
		
		OutParameters outParameters = new OutParameters();
		outParameters.putOutParmType("ErrNo", java.sql.Types.INTEGER);
		outParameters.putOutParmType("ErrMsg", java.sql.Types.NVARCHAR);
        
		ResultSet rs = null;
		CallableStatement cstmt = null;
		int errNo = 0;
		String errMsg = "";
		try {
			rs = SQLHelper.runProcedure(Config.CONNECTION_STRING_ULD, "{call WH_Game_GameInterfaceParams_Get(?,?,?)}", inParameters, outParameters);
			if (rs != null) {
				rs.next();
				model = getModel(rs);
				
				cstmt = (CallableStatement)rs.getStatement();
				errNo = cstmt.getInt("ErrNo");
				errMsg = cstmt.getString("ErrMsg");
			}
		} catch (Exception e) {
			throw new Exception(e.getMessage(), e);
		} finally{
			SQLHelper.closeAll(cstmt);
		}
		
		MyErr.checkErr(errNo, errMsg);
		return model;
	}
Пример #2
0
  public int updateStatus(String status, String lineNo) {
    int success = 0;
    String stRef;
    System.out.println("entered update ");
    if (status.equals("deactivate")) {
      System.out.println("in if deacti");
      stRef = "T";
    } else if (status.equals("activate")) {
      stRef = "A";
    } else {
      stRef = "";
      System.out.println("incorrect status");
    }
    try {
      System.out.println("in try");
      csRef = conRef.prepareCall(Queries.UPDATE_PROC);
      csRef.setString(1, lineNo);
      csRef.setString(2, stRef);
      csRef.registerOutParameter(3, Types.INTEGER);
      csRef.execute();
      System.out.println("output: " + csRef.getInt(3));
      /*psRef=conRef.prepareStatement("update enterprise set status=? where line_no=?");
      psRef.setString(1,stRef);
      psRef.setString(2,lineNo);
      if(status.equals("deactivate"))
      {
      	psRef.setString(1,"T");
      }
      else
      {
      	psRef.setString(1,"A");
      }*/
      success = csRef.getInt(3);
      System.out.println(success);
      if (success > 0) {
        System.out.println("updated status");
        conRef.commit();
      }
      /*success=psRef.executeUpdate();
      System.out.println(success);
      	if(success>0)
      	{
      		System.out.println("updated status");
      		conRef.commit();
      	}*/
    } catch (SQLException e) {
      e.printStackTrace();
    }

    return success;
  }
Пример #3
0
  /**
   *
   *
   * <PRE>
   * Desc : Excute Procedure SP_INSERT_CUST_FROM_SEG
   * </PRE>
   *
   * @param RetrieveModel
   * @return RetrieveModel
   */
  public RetrieveModel execProcedure(Connection con, RetrieveModel retrieve) throws StoreException {
    CallableStatement cstmt = null;
    ResultSet rset = null;

    try {

      cstmt = con.prepareCall("begin SP_INSERT_CUST_FROM_SEG(?, ?, ?, '', ?, ?, ?, ?, ?); end;");

      int index = 1;
      cstmt.setString(index++, retrieve.getString("flag"));
      cstmt.setString(index++, retrieve.getString("promo_no"));
      cstmt.setString(index++, retrieve.getString("segment_code"));
      cstmt.setString(index++, retrieve.getString("proc_date"));
      cstmt.setString(index++, retrieve.getString("user_id"));
      cstmt.registerOutParameter(index++, java.sql.Types.INTEGER);
      cstmt.registerOutParameter(index++, java.sql.Types.INTEGER);
      cstmt.registerOutParameter(index++, java.sql.Types.VARCHAR);

      // = log Save Data ---------------------
      StringBuffer logString = new StringBuffer();
      logString.append(retrieve.getString("flag"));
      logString.append("/");
      logString.append(retrieve.getString("promo_no"));
      logString.append("/");
      logString.append(retrieve.getString("segment_code"));
      logString.append("/");
      logString.append(retrieve.getString("proc_date"));
      logString.append("/");
      logString.append(retrieve.getString("user_id"));
      logString.append("/");
      logSave.info(logString.toString());

      // == 프로시져를 실행합니다.
      cstmt.executeUpdate();

      retrieve.put("out_proc_cnt", cstmt.getInt(6));
      retrieve.put("out_rtn", cstmt.getInt(7));
      retrieve.put("out_rtn_msg", ComUtils.NVL(cstmt.getString(8), ""));

    } catch (SQLException se) {
      logSave.error(
          "[PromoSegmentSvc.execProcedure() SQLException : ERR-" + se.getErrorCode() + ":" + se);
      throw new StoreException(se.getMessage());
    } catch (Exception e) {
      logSave.error("[PromoSegmentSvc.execProcedure() Exception : ERR-" + e.getMessage());
      throw new StoreException(e.getMessage());
    } finally {
      DBUtils.freeConnection(null, null, null, cstmt, null, rset);
    }
    return retrieve;
  }
Пример #4
0
  @Override
  public int save(java.sql.Connection connection) {
    int nParam = 1;
    CallableStatement callableStatement = null;

    mnLastDbActionResult = SLibConstants.UNDEFINED;

    try {
      callableStatement =
          connection.prepareCall("{ CALL erp.finu_tax_bas_save(" + "?, ?, ?, ?, ?, ?, ?) }");
      callableStatement.setInt(nParam++, mnPkTaxBasicId);
      callableStatement.setString(nParam++, msTaxBasic);
      callableStatement.setBoolean(nParam++, mbIsDeleted);
      callableStatement.setInt(nParam++, mbIsRegistryNew ? mnFkUserNewId : mnFkUserEditId);
      callableStatement.registerOutParameter(nParam++, java.sql.Types.SMALLINT);
      callableStatement.registerOutParameter(nParam++, java.sql.Types.SMALLINT);
      callableStatement.registerOutParameter(nParam++, java.sql.Types.CHAR);
      callableStatement.execute();

      mnPkTaxBasicId = callableStatement.getInt(nParam - 3);
      mnDbmsErrorId = callableStatement.getInt(nParam - 2);
      msDbmsError = callableStatement.getString(nParam - 1);

      if (mnDbmsErrorId != 0) {
        throw new Exception(msDbmsError);
      } else {
        // Save aswell the taxes

        nParam = 1;

        for (int i = 0; i < mvDbmsTaxes.size(); i++) {
          mvDbmsTaxes.get(i).setPkTaxBasicId(mnPkTaxBasicId);
          if (mvDbmsTaxes.get(i).save(connection) != SLibConstants.DB_ACTION_SAVE_OK) {
            throw new Exception(SLibConstants.MSG_ERR_DB_REG_SAVE_DEP);
          }
        }

        mbIsRegistryNew = false;
        mnLastDbActionResult = SLibConstants.DB_ACTION_SAVE_OK;
      }
    } catch (java.sql.SQLException e) {
      mnLastDbActionResult = SLibConstants.DB_ACTION_SAVE_ERROR;
      SLibUtilities.printOutException(this, e);
    } catch (java.lang.Exception e) {
      mnLastDbActionResult = SLibConstants.DB_ACTION_SAVE_ERROR;
      SLibUtilities.printOutException(this, e);
    }

    return mnLastDbActionResult;
  }
Пример #5
0
  public static int ExisteServicio(int IdServicio) throws Exception {
    int resultado = 0;

    CallableStatement ObjProcedimiento;
    Connection conector = estado();

    try {

      ObjProcedimiento = conector.prepareCall("{call ExisteServicio(?,?)}");
      ObjProcedimiento.setInt(1, IdServicio);
      ObjProcedimiento.registerOutParameter(2, Types.INTEGER);
      ObjProcedimiento.execute();
      resultado = ObjProcedimiento.getInt(2);

    } catch (Exception pp) {
      JOptionPane.showMessageDialog(
          null,
          "Error en Catalogo: ExisteServicio " + pp.getMessage(),
          "ATENCION",
          JOptionPane.WARNING_MESSAGE);
    } finally {
      conector.close();
    }

    return resultado;
  }
Пример #6
0
  public void save(Connection conn, String welfarefundId) throws SQLException {
    CallableStatement cstmt = null;
    try {
      String sql = "begin HR_WLF_WELFARE_PKG.SAVE_EMPOLYEE_TYPE(:1,:2,:3,:4); end;";
      cstmt = conn.prepareCall(sql);
      DeBug.print(sql);

      cstmt.setString(1, Decoder.convertSetString(welfarefundId));
      cstmt.setString(2, Decoder.convertSetString(this.getCurrentEmployeeType().getAttributeId()));
      cstmt.registerOutParameter(3, Types.INTEGER);
      cstmt.registerOutParameter(4, Types.VARCHAR);
      cstmt.execute();

      int returnCode = cstmt.getInt(3);
      String returnMessage = cstmt.getString(4);

      DeBug.print("in Save : the returnCode : " + returnCode);
      DeBug.print("in Save : the returnMessage : " + returnMessage);

    } finally {
      try {
        cstmt.close();
        cstmt = null;
      } catch (Exception e) {
      }
    }
  }
  /**
   * @param ds
   * @param userId
   * @param e2bExchangeId
   * @param initOrFollow
   * @throws SQLException
   */
  public void importE2bData(String userId, String e2bExchangeId) throws SQLException {
    log.info("### in importE2bData (");
    Connection con = null;

    try {

      con = ds.getConnection();
      String sql = "{ call ? := LAU_E2B_INBOUND.import_e2b_message(?,?,?,?,?,?,?,?)}";
      CallableStatement stmt = con.prepareCall(sql);

      stmt.registerOutParameter(1, OracleTypes.VARCHAR); // 1
      stmt.setString(2, e2bExchangeId); // P_CLOB_ID NUMBER , :2
      stmt.registerOutParameter(3, OracleTypes.VARCHAR); // P_ERR_MSG OUT
      // varchar2, :3
      stmt.registerOutParameter(4, OracleTypes.VARCHAR); // P_MSG OUT
      // varchar2, :4
      stmt.registerOutParameter(5, OracleTypes.VARCHAR); // P_REPORT_ID_OUT
      // out VARCHAR2,
      // :5
      stmt.registerOutParameter(6, OracleTypes.VARCHAR); // P_LAU_REPORT_ID_OUT
      // out VARCHAR2,
      // :6
      stmt.registerOutParameter(7, OracleTypes.NUMBER); // P_ACK_ID_OUT out
      // NUMBER, :7

      stmt.setString(8, userId); // P_USER_ID varchar2, :8
      stmt.setString(9, "N"); // P_MULTICASES VARCHAR2 DEFAULT 'N', :9
      // stmt.setString(10, initOrFollow);// P_PROCESSING_MODE VARCHAR2
      // DEFAULT 'AUTOMATED', :10
      // stmt.setString(11, "Y");// P_ACK VARCHAR2 DEFAULT 'Y', :11
      // stmt.setString(12, "N"); // P_DISPLAY_OUTPUT VARCHAR2 DEFAULT 'N'
      // :12
      log.info("15====");
      log.info(sql);
      stmt.execute();
      // FUNCTION output

      // int update = stmt.getInt(1);
      String retVal = stmt.getString(1); // 0 - Error, > 0 success
      String strError = stmt.getString(3); // P_ERR_MSG OUT varchar2, :3
      String strMsg = stmt.getString(4); // P_MSG OUT varchar2, :4
      String strRepId = stmt.getString(5); // P_REPORT_ID_OUT out VARCHAR2,
      // :5
      String strLauRepId = stmt.getString(6); // P_LAU_REPORT_ID_OUT out
      // VARCHAR2, :6
      String ackId = Integer.toString(stmt.getInt(7)); // P_ACK_ID_OUT out
      // NUMBER, :7

      log.info("Funtion returned ...:" + retVal + "," + strError + "," + strRepId);
      stmt.close();
      con.close();

    } finally {
      try {
        if (con != null) con.close();
      } catch (Exception e) {
        log.error(e, e);
      }
    }
  }
Пример #8
0
  @Override
  protected ArrayList vAddRow(Connection conn) throws Exception {
    RBDocTypesDPanel p = new RBDocTypesDPanel();
    AUniversalAddDialog d = new AUniversalAddDialog(p, null, true);

    d.setTitleIcon(
        new javax.swing.ImageIcon(
            getClass().getResource("/tradeterminal/icons/TT_icons/32X32/typplus.png")));
    d.setVisible(true);
    d.dispose();

    if (d.getReturnStatus() == ADialog.RET_OK) {

      CallableStatement proc = conn.prepareCall("{? = call rb_doc_types_insert(?,?)}");
      proc.registerOutParameter(1, Types.INTEGER);

      proc.setString(2, p.get_Name());
      proc.setString(3, p.getDescription());
      proc.execute();

      int id = proc.getInt(1);

      proc.close();

      ArrayList newRow = new ArrayList();
      newRow.add(id);
      newRow.add(p.get_Name());
      newRow.add(p.getDescription());

      return newRow;
    } else {
      return null;
    }
  }
Пример #9
0
  // ELIMINAR
  public String EliminarAsistenciaCurso(PublicacionesDTO escolaridaDTO) {
    try {
      try {
        ConexionBD conexionBD = new ConexionBD();
        conexionBD.abrir();
        Connection connection = conexionBD.getConexion();

        String sql = "{ ? = call eliminar_publicaciones(?)} ";
        CallableStatement callableStatement = connection.prepareCall(sql);
        callableStatement.registerOutParameter(1, Types.INTEGER);
        callableStatement.setInt(2, escolaridaDTO.getId());
        callableStatement.execute();
        Integer num = callableStatement.getInt(1);
        connection.close();
        if (num == 1) {
          return "¡Se elimino satisfactoriamente!";
        } else {
          return "";
        }

      } catch (Exception e) {
        e.printStackTrace();
      }
    } catch (Exception ex) {
      System.out.println("Error en.." + ex.getMessage());
    }

    return "";
  }
Пример #10
0
  @Override
  public boolean getForumFullScan(String forum) {
    /*      function get_forum_scan (p_forum in varchar2) return number;             */
    boolean result = true;
    String proc = "{? = call dxdy_executable.get_forum_scan (?)}";
    CallableStatement st = null;
    try {
      st = connection.prepareCall(proc);
      st.registerOutParameter(1, Types.INTEGER);
      st.setString(2, forum);
      st.execute();
      result = (st.getInt(1) == 1);
    } catch (SQLException e) {
      e.printStackTrace();
    } finally {
      if (st != null) {
        try {
          st.close();
        } catch (SQLException e) {
          e.printStackTrace();
        }
      }
    }

    return result;
  }
Пример #11
0
  @Override
  public int save(java.sql.Connection connection) {
    int i = 0;
    int nParam = 1;
    CallableStatement callableStatement = null;

    mnLastDbActionResult = SLibConstants.UNDEFINED;

    try {
      callableStatement =
          connection.prepareCall("{ CALL mfgu_line_save(" + "?, ?, ?, ?, ?, " + "?, ?, ?) }");
      callableStatement.setInt(nParam++, mnPkMfgLineId);
      callableStatement.setString(nParam++, msMfgLine);
      callableStatement.setBoolean(nParam++, mbIsDeleted);
      callableStatement.setInt(nParam++, mnFkCostCenterId);
      callableStatement.setInt(nParam++, mbIsRegistryNew ? mnFkUserNewId : mnFkUserEditId);
      callableStatement.registerOutParameter(nParam++, java.sql.Types.INTEGER);
      callableStatement.registerOutParameter(nParam++, java.sql.Types.SMALLINT);
      callableStatement.registerOutParameter(nParam++, java.sql.Types.VARCHAR);
      callableStatement.execute();

      mnPkMfgLineId = callableStatement.getInt(nParam - 3);
      mnDbmsErrorId = callableStatement.getInt(nParam - 2);
      msDbmsError = callableStatement.getString(nParam - 1);

      mbIsRegistryNew = false;
      mnLastDbActionResult = SLibConstants.DB_ACTION_SAVE_OK;
    } catch (java.lang.Exception e) {
      mnLastDbActionResult = SLibConstants.DB_ACTION_SAVE_ERROR;
      SLibUtilities.printOutException(this, e);
    }

    return mnLastDbActionResult;
  }
Пример #12
0
 @Override
 public int getLastTopicPage(int tID) {
   String proc = "{? = call dxdy_executable.get_topic_last_page(?)}";
   CallableStatement st = null;
   int res = 0;
   try {
     st = connection.prepareCall(proc);
     st.registerOutParameter(1, java.sql.Types.INTEGER);
     st.setInt(2, tID);
     st.execute();
     res = st.getInt(1);
   } catch (SQLException e) {
     System.out.println("Error while querying last page of topic ID = " + tID);
     e.printStackTrace();
   } finally {
     if (st != null) {
       try {
         st.close();
       } catch (SQLException e) {
         e.printStackTrace();
       }
     }
   }
   return res;
 }
  public int nextTSecGroupIdGen(CFSecurityAuthorization Authorization, CFSecurityTenantPKey PKey) {
    final String S_ProcName = "nextTSecGroupIdGen";
    if (!schema.isTransactionOpen()) {
      throw CFLib.getDefaultExceptionFactory()
          .newUsageException(getClass(), S_ProcName, "Not in a transaction");
    }
    Connection cnx = schema.getCnx();
    long Id = PKey.getRequiredId();

    CallableStatement stmtSelectNextTSecGroupIdGen = null;
    try {
      String sql = "{ call sp_next_tsecgroupidgen( ?" + ", " + "?" + " ) }";
      stmtSelectNextTSecGroupIdGen = cnx.prepareCall(sql);
      int argIdx = 1;
      stmtSelectNextTSecGroupIdGen.registerOutParameter(argIdx++, java.sql.Types.INTEGER);
      stmtSelectNextTSecGroupIdGen.setLong(argIdx++, Id);
      stmtSelectNextTSecGroupIdGen.execute();
      int nextId = stmtSelectNextTSecGroupIdGen.getInt(1);
      return (nextId);
    } catch (SQLException e) {
      throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
      if (stmtSelectNextTSecGroupIdGen != null) {
        try {
          stmtSelectNextTSecGroupIdGen.close();
        } catch (SQLException e) {
        }
        stmtSelectNextTSecGroupIdGen = null;
      }
    }
  }
 /**
  * Control de transacción en el procedimiento almacenado
  *
  * @param prod
  */
 @Override
 public void create2(Producto prod) {
   Connection cn = null;
   try {
     cn = AccesoDB.getConnection();
     cn.setAutoCommit(true);
     String query = "{call usp_crea_producto(?,?,?,?,?)}";
     CallableStatement cstm = cn.prepareCall(query);
     cstm.registerOutParameter(1, Types.INTEGER);
     cstm.setInt(2, prod.getIdcat());
     cstm.setString(3, prod.getNombre());
     cstm.setDouble(4, prod.getPrecio());
     cstm.setInt(5, prod.getStock());
     cstm.executeUpdate();
     prod.setIdprod(cstm.getInt(1));
     cstm.close();
   } catch (SQLException e) {
     throw new RuntimeException(e.getMessage());
   } catch (Exception e) {
     throw new RuntimeException("No se puede crear el producto.");
   } finally {
     try {
       cn.close();
     } catch (Exception e) {
     }
   }
 }
Пример #15
0
  @Override
  public int call(java.sql.Connection connection) {
    int nParam = 1;
    java.sql.CallableStatement callableStatement = null;

    mnLastDbActionResult = SLibConstants.UNDEFINED;

    try {
      callableStatement = connection.prepareCall("{ CALL mfg_ltime_cob_val(?, ?, ?) }");
      callableStatement.setInt(nParam, (Integer) mvParamsIn.get(nParam - 1));
      nParam++;
      callableStatement.setInt(nParam, (Integer) mvParamsIn.get(nParam - 1));
      nParam++;
      callableStatement.registerOutParameter(nParam, java.sql.Types.INTEGER);
      callableStatement.execute();

      mvParamsOut.clear();
      mvParamsOut.add(callableStatement.getInt(nParam));
      mnLastDbActionResult = SLibConstants.DB_PROCEDURE_OK;
    } catch (java.sql.SQLException e) {
      mnLastDbActionResult = SLibConstants.DB_PROCEDURE_ERROR;
      SLibUtilities.printOutException(this, e);
    } catch (java.lang.Exception e) {
      mnLastDbActionResult = SLibConstants.DB_PROCEDURE_ERROR;
      SLibUtilities.printOutException(this, e);
    }

    return mnLastDbActionResult;
  }
 public void testSum() throws SQLException {
   CallableStatement cs = con.prepareCall("{?= call mysum(?, ?)}");
   cs.registerOutParameter(1, Types.INTEGER);
   cs.setInt(2, 2);
   cs.setInt(3, 3);
   cs.execute();
   assertEquals("2+3 should be 5 when executed via {?= call mysum(?, ?)}", 5, cs.getInt(1));
 }
Пример #17
0
 @Override
 public int getCallableInt(int columnIndex) throws JdbcException {
   try {
     return callableStatement.getInt(columnIndex);
   } catch (SQLException ex) {
     throw newJdbcException(ex);
   }
 }
  /*
   * (non-Javadoc)
   *
   * @see
   * pe.com.viajes.negocio.dao.ServicioNoviosDao#registrarNovios(pe.com
   * .logistica.bean.negocio.ProgramaNovios)
   */
  @Override
  public Integer registrarNovios(ProgramaNovios programaNovios) throws SQLException {
    Integer codigoNovios = 0;
    Connection conn = null;
    CallableStatement cs = null;
    String sql = "{ ? = call negocio.fn_ingresarprogramanovios(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) }";
    try {
      conn = UtilConexion.obtenerConexion();
      cs = conn.prepareCall(sql);
      int i = 1;
      cs.registerOutParameter(i++, Types.INTEGER);
      cs.setInt(i++, programaNovios.getNovia().getCodigoEntero());
      cs.setInt(i++, programaNovios.getNovio().getCodigoEntero());
      cs.setInt(i++, programaNovios.getDestino().getCodigoEntero());
      cs.setDate(i++, UtilJdbc.convertirUtilDateSQLDate(programaNovios.getFechaBoda()));
      cs.setDate(i++, UtilJdbc.convertirUtilDateSQLDate(programaNovios.getFechaViaje()));
      cs.setInt(i++, programaNovios.getMoneda().getCodigoEntero());
      cs.setBigDecimal(i++, programaNovios.getCuotaInicial());
      cs.setInt(i++, programaNovios.getNroDias());
      cs.setInt(i++, programaNovios.getNroNoches());
      cs.setDate(i++, UtilJdbc.convertirUtilDateSQLDate(programaNovios.getFechaShower()));
      if (StringUtils.isNotBlank(programaNovios.getObservaciones())) {
        cs.setString(i++, programaNovios.getObservaciones());
      } else {
        cs.setNull(i++, Types.VARCHAR);
      }
      cs.setBigDecimal(i++, programaNovios.getMontoTotalServiciosPrograma());
      cs.setInt(i++, programaNovios.getIdServicio());
      cs.setString(i++, programaNovios.getUsuarioCreacion());
      cs.setString(i++, programaNovios.getIpCreacion());
      cs.execute();

      codigoNovios = cs.getInt(1);
    } catch (SQLException e) {
      codigoNovios = 0;
      throw new SQLException(e);
    } finally {
      try {
        if (cs != null) {
          cs.close();
        }
        if (conn != null) {
          conn.close();
        }
      } catch (SQLException e) {
        try {
          if (conn != null) {
            conn.close();
          }
          throw new SQLException(e);
        } catch (SQLException e1) {
          throw new SQLException(e);
        }
      }
    }

    return codigoNovios;
  }
 @Override
 public E getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
   int i = cs.getInt(columnIndex);
   if (cs.wasNull()) {
     return null;
   } else {
     return convert(i);
   }
 }
 public int getInt(String parameterName) throws SQLException {
   checkOpen();
   try {
     return _stmt.getInt(parameterName);
   } catch (SQLException e) {
     handleException(e);
     return 0;
   }
 }
Пример #21
0
  public String guardarDato(PublicacionesDTO asistenciacursosDTO) {
    try {
      try {
        ConexionBD conexionBD = new ConexionBD();
        conexionBD.abrir();
        Connection connection = conexionBD.getConexion();

        String sql = "{ ? = call insertar_publicaciones(?,?,?,?,?,?,?,?)} ";

        CallableStatement callableStatement = connection.prepareCall(sql);
        callableStatement.registerOutParameter(1, Types.INTEGER);
        callableStatement.setString(2, asistenciacursosDTO.getPeriodo());
        callableStatement.setString(3, asistenciacursosDTO.getPublicacion());
        callableStatement.setString(4, asistenciacursosDTO.getInstitucion());
        callableStatement.setBinaryStream(5, asistenciacursosDTO.getEvidencia().getInputstream());
        callableStatement.setInt(6, asistenciacursosDTO.getIdmodif());
        Calendar cal1 = Calendar.getInstance();
        String Fecha =
            (""
                + cal1.get(Calendar.DATE)
                + "/"
                + cal1.get(Calendar.MONTH)
                + "/"
                + cal1.get(Calendar.YEAR)
                + " "
                + cal1.get(Calendar.HOUR_OF_DAY)
                + ":"
                + cal1.get(Calendar.MINUTE)
                + ":"
                + cal1.get(Calendar.SECOND)
                + ":"
                + cal1.get(Calendar.MILLISECOND));
        callableStatement.setString(7, Fecha);
        callableStatement.setInt(8, asistenciacursosDTO.getIdlic());
        callableStatement.setInt(9, asistenciacursosDTO.getIdusuario());

        callableStatement.execute();
        Integer num = callableStatement.getInt(1);
        connection.close();
        if (num == 1) {

          return "¡Se guardo satisfactoriamente!";

        } else {
          return "";
        }

      } catch (Exception e) {
        e.printStackTrace();
      }
    } catch (Exception ex) {
      System.out.println("Error en.." + ex.getMessage());
    }

    return "";
  }
Пример #22
0
 @Override
 public Object getResult(CallableStatement cs, int columnIndex) throws SQLException {
   try {
     Integer result = cs.getInt(columnIndex);
     return InvoiceType.getItem(result);
   } catch (SQLException e) {
     logger.error("自定义转换获取值的时候出错。", e);
   }
   return null;
 }
Пример #23
0
  /* Business type 2 */
  public void saveQuoteItemDtl(QuotationMgr quotationMgr, Connection conn, String quoteId)
      throws SQLException {
    CallableStatement cstmt = null;
    try {
      this.mCode = 0;

      conn.setAutoCommit(false);
      String sql = "begin OM_QUOTATION_PKG.SAVE_QUOTE_ITEM_DTL(:1,:2,:3,:4,:5,:6,:7,:8,:9); end;";
      cstmt = conn.prepareCall(sql);
      DeBug.print(sql);

      if (quoteId == null || quoteId.equals("")) return;

      cstmt.setString(1, Decoder.convertSetString(quoteId));
      cstmt.setNull(2, Types.VARCHAR);
      cstmt.setString(3, Decoder.convertSetString(this.getCustomerId()));
      cstmt.setString(4, Decoder.convertSetString(this.getCurrentSite().getSiteId()));
      cstmt.setString(5, Decoder.convertSetString(this.getCurrentContact().getContactId()));
      cstmt.setString(6, Decoder.convertSetString(this.getQuotePrice()));
      cstmt.setString(7, Decoder.convertSetString("CREATE"));

      cstmt.registerOutParameter(2, Types.VARCHAR);
      cstmt.registerOutParameter(8, Types.INTEGER);
      cstmt.registerOutParameter(9, Types.INTEGER);

      cstmt.execute();

      int returnCode = cstmt.getInt(8);
      String returnMessage = cstmt.getString(9);

      DeBug.print(String.valueOf(returnCode), "(in Save : the returnCode )");
      DeBug.print(returnMessage, "(in Save : the returnMessage )");

      if (returnCode != 0) {
        // Non-manageable error.
        conn.rollback();
        this.mCode = SAVE_ERROR;
      } else {
        this.setQuoteDtlId(cstmt.getString(2));
      }
    } catch (Exception e) {
      conn.rollback();
      e.printStackTrace();
      this.mCode = SAVE_ERROR;
    } finally {
      try {
        if (cstmt != null) {
          cstmt.close();
        }
        cstmt = null;
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }
Пример #24
0
  /** * others method ** */
  public void save() throws SQLException {
    Connection conn = OracleGate.getConnection();
    CallableStatement cstmt = null;
    this.mCode = 0;
    try {
      conn.setAutoCommit(false);
      String sql = "begin BOM_PARAMETER_PKG.SAVE_PARAMETER(:1,:2,:3,:4,:5,:6,:7,:8,:9,:10); end;";
      DeBug.print(sql);
      cstmt = conn.prepareCall(sql);
      cstmt.setString(1, this.getWeightBase());
      cstmt.setString(2, this.getPacking());
      cstmt.setString(3, this.getElectrolysis());
      cstmt.setString(4, this.getManagement());
      cstmt.setString(5, this.getSaraly());
      cstmt.setString(6, this.getScript());
      cstmt.setString(7, this.getAssemblybase());
      cstmt.setString(8, this.getProfit());
      cstmt.registerOutParameter(9, Types.INTEGER);
      cstmt.registerOutParameter(10, Types.VARCHAR);
      cstmt.execute();
      int returnCode = cstmt.getInt(9);
      String returnMessage = cstmt.getString(10);
      DeBug.print(" returnCode ::" + returnCode);
      DeBug.print(" returnMessage ::" + returnMessage);

      if (returnCode == -2) {
        // Violate unique constraint in database
        conn.rollback();
        this.mCode = UNIQUE_VIOLATION;
      } else if (returnCode != 0) {
        // Non-manageable error.
        conn.rollback();
        this.mCode = SAVE_ERROR;
      } else {
        conn.commit();
      }
    } catch (Exception e) {
      conn.rollback();
      e.printStackTrace();
      this.mCode = SAVE_ERROR;
    } finally {
      conn.setAutoCommit(true);
      if (conn != null) {
        OracleGate.freeConnection(conn);
      }
      try {
        if (cstmt != null) {
          cstmt.close();
        }
        cstmt = null;
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }
Пример #25
0
  /* Business type 2 */
  public void saveStatus(QuotationMgr quotationMgr) throws SQLException {
    Connection conn = null;
    conn = OracleGate.getConnection();
    CallableStatement cstmt = null;
    System.out.println("Quotation detail id : " + this.getQuoteDtlId());

    try {
      this.mCode = 0;

      conn.setAutoCommit(false);
      String sql = "begin OM_QUOTATION_PKG.SAVE_QUOTE_ITEM_STATUS(:1,:2,:3); end;";
      cstmt = conn.prepareCall(sql);
      DeBug.print(sql);

      cstmt.setString(1, Decoder.convertSetString(this.getQuoteDtlId()));

      cstmt.registerOutParameter(2, Types.INTEGER);
      cstmt.registerOutParameter(3, Types.INTEGER);

      cstmt.execute();

      int returnCode = cstmt.getInt(2);
      String returnMessage = cstmt.getString(3);

      DeBug.print(String.valueOf(returnCode), "(in Save : the returnCode )");
      DeBug.print(returnMessage, "(in Save : the returnMessage )");

      if (returnCode != 0) {
        // Non-manageable error.
        conn.rollback();
        this.mCode = SAVE_ERROR;
      } else {
        conn.commit();
      }
    } catch (Exception e) {
      conn.rollback();
      e.printStackTrace();
      this.mCode = SAVE_ERROR;
    } finally {
      conn.setAutoCommit(true);
      if (conn != null) {
        OracleGate.freeConnection(conn);
      }
      try {
        if (cstmt != null) {
          cstmt.close();
        }
        cstmt = null;
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }
 public void testMultipleOutExecutions() throws SQLException {
   CallableStatement cs = con.prepareCall("{call myiofunc(?, ?)}");
   for (int i = 0; i < 10; i++) {
     cs.registerOutParameter(1, Types.INTEGER);
     cs.registerOutParameter(2, Types.INTEGER);
     cs.setInt(1, i);
     cs.execute();
     assertEquals(1, cs.getInt(1));
     assertEquals(i, cs.getInt(2));
     cs.clearParameters();
   }
 }
 public void testGetInt01() throws Throwable {
   try {
     Statement stmt = con.createStatement();
     stmt.execute("create temp table i_tab ( max_val int, min_val int, null_val int )");
     stmt.execute("insert into i_tab values (2147483647,-2147483648,null)");
     boolean ret =
         stmt.execute(
             "create or replace function "
                 + "int_proc( OUT IMAX int, OUT IMIN int, OUT INUL int)  as "
                 + "'begin "
                 + "select max_val into imax from i_tab;"
                 + "select min_val into imin from i_tab;"
                 + "select null_val into inul from i_tab;"
                 + " end;' "
                 + "language plpgsql;");
   } catch (Exception ex) {
     fail(ex.getMessage());
     throw ex;
   }
   try {
     CallableStatement cstmt = con.prepareCall("{ call int_proc(?,?,?) }");
     cstmt.registerOutParameter(1, java.sql.Types.INTEGER);
     cstmt.registerOutParameter(2, java.sql.Types.INTEGER);
     cstmt.registerOutParameter(3, java.sql.Types.INTEGER);
     cstmt.executeUpdate();
     assertTrue(cstmt.getInt(1) == 2147483647);
     assertTrue(cstmt.getInt(2) == -2147483648);
     cstmt.getInt(3);
     assertTrue(cstmt.wasNull());
   } catch (Exception ex) {
     fail(ex.getMessage());
   } finally {
     try {
       Statement dstmt = con.createStatement();
       dstmt.execute("drop function int_proc()");
     } catch (Exception ex) {
     }
   }
 }
Пример #28
0
  public void save(Connection conn, AccountingArMgr accMgr, int rowIndex) throws SQLException {

    CallableStatement cstmt = null;
    String verbEntryMode = accMgr.getEntryMode().split("-")[0];

    try {
      this.mCode = 0;
      String sql =
          "begin FM_AR_PAYMENT_TERM_DETAIL_PKG.SAVE(:1,:2,:3,:4,:5,:6,:7,:8,:9,:10,:11); end;";
      cstmt = conn.prepareCall(sql);
      DeBug.print(sql);

      cstmt.setLong(1, Long.parseLong(accMgr.getCurrentMiscellaneousInvoice().getInvoiceId()));
      cstmt.setLong(2, Long.parseLong(this.getPaymentTerm().getAttributeCode()));
      cstmt.setDouble(3, Double.parseDouble(this.getPercentage()));
      cstmt.setString(
          4, Decoder.convertSetString(accMgr.getCurrentMiscellaneousInvoice().getStartDate()));
      cstmt.setNull(5, Types.VARCHAR);
      cstmt.setNull(6, Types.VARCHAR);
      cstmt.setString(
          7, Decoder.convertSetString(accMgr.getCurrentMiscellaneousInvoice().getSourceType()));
      cstmt.setString(8, Decoder.convertSetString(verbEntryMode));
      cstmt.setLong(9, rowIndex);

      cstmt.registerOutParameter(10, Types.INTEGER);
      cstmt.registerOutParameter(11, Types.VARCHAR);
      cstmt.execute();

      int returnCode = cstmt.getInt(10);
      String returnMessage = cstmt.getString(11);

      if (returnCode == -2) {
        // Violate unique constraint in database
        this.mCode = UNIQUE_VIOLATION;
        throw new SQLException(returnMessage);
      } else if (returnCode != 0) {
        // Non-manageable error.
        this.mCode = SAVE_ERROR;
        throw new SQLException(returnMessage);
      }
    } catch (Exception e) {
      this.mCode = SAVE_ERROR;
      e.printStackTrace();
      throw new SQLException(e.getMessage());
    } finally {
      if (cstmt != null) {
        cstmt.close();
      }
      cstmt = null;
    }
  }
Пример #29
0
  /** The int value */
  @Override
  public int getInt(String name) throws SQLException {
    try {
      return _cstmt.getInt(name);
    } catch (SQLException e) {
      onSqlException(e);

      throw e;
    } catch (RuntimeException e) {
      onRuntimeException(e);

      throw e;
    }
  }
Пример #30
0
  public int saveMemo(Connection conn, Login login) throws SQLException {
    CallableStatement cstmt = null;

    try {
      this.mCode = 0;
      String sql = "begin FM_AR_SEND_TO_FM_PKG.SAVE_CREDIT_MEMO_TO_GL(:1,:2,:3,:4,:5); end;";
      cstmt = conn.prepareCall(sql);
      DeBug.print(sql);

      int returnCode;
      String returnMessage;

      cstmt.setString(1, this.getMemoId());
      cstmt.setString(2, Decoder.convertSetString(login.getLoginName()));

      cstmt.registerOutParameter(3, Types.VARCHAR);
      cstmt.registerOutParameter(4, Types.INTEGER);
      cstmt.registerOutParameter(5, Types.VARCHAR);

      cstmt.execute();

      returnCode = cstmt.getInt(4);
      returnMessage = cstmt.getString(5);
      DeBug.print(returnCode + ":" + returnMessage);

      if (returnCode != 0) {
        this.mCode = SAVE_ERROR;
        return this.mCode;
      } else if (returnCode == -5) {
        this.mCode = TAX_ID_NOT_FOUND;
        return this.mCode;
      } else if (returnCode != 0) {
        this.mCode = SAVE_ERROR;
        return this.mCode;
      } else {
        this.setVoucherNo(cstmt.getString(3));
        this.setIsSavedFlag("Y");
        return this.mCode;
      }
    } catch (Exception e) {
      this.mCode = SAVE_ERROR;
      e.printStackTrace();
      throw new SQLException(e.getMessage());
    } finally {
      if (cstmt != null) {
        cstmt.close();
      }
      cstmt = null;
    }
  }