Example #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;
	}
 public String getKnownShipperDetails(String locationCode, String shipperId) {
   Connection connection = null;
   CallableStatement cStmt = null;
   ResultSet rs = null;
   String Code = null;
   try {
     connection = getConnection();
     cStmt = connection.prepareCall("{? = call ETRANS_UTIL.GETKNOWNSHIPPERSTATUS(?,?,?) }");
     cStmt.setString(2, locationCode);
     cStmt.setString(3, shipperId);
     cStmt.setString(4, "OPR");
     cStmt.registerOutParameter(1, java.sql.Types.VARCHAR);
     cStmt.execute();
     Code = cStmt.getString(1);
   } catch (SQLException e) {
     e.printStackTrace();
   } catch (Exception e) {
     e.printStackTrace();
   } finally {
     try {
       ConnectionUtil.closeConnection(connection, cStmt, rs);
     } catch (Exception ex) {
       ex.printStackTrace();
     }
   }
   return Code;
 }
  /**
   * @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);
      }
    }
  }
Example #4
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();
      }
    }
  }
  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;
    }
  }
 public String verificaCargue() {
   String rta = "";
   Connection con = null;
   ResultSet rs = null;
   ConexionBD objetoConexion = null;
   CallableStatement cs = null;
   String sql = "";
   try {
     objetoConexion = new ConexionBD();
     con =
         objetoConexion.generarConexionOracle(
             GeneralDao.USUARIO_BD,
             GeneralDao.PASSWORD_BD,
             GeneralDao.NAME_SERVER,
             GeneralDao.NET_SERVICE,
             GeneralDao.ROOT_CONNECT);
     sql = "{ ? = call FX_VER_CARGUE_INFCADE }\n";
     cs = con.prepareCall(sql);
     cs.registerOutParameter(1, Types.VARCHAR);
     cs.execute();
     rta = cs.getString(1);
     cs.close();
   } catch (Exception e) {
     System.out.println("Error Sia_InformeCadeDao.verificaCargue " + e);
   } finally {
     objetoConexion.eliminacionOracle(con);
   }
   return rta;
 }
Example #7
0
  @Override
  public String getLastTopicDate(int tID) {
    /*    function get_topic_last_update (p_topic_id  in dxdy_topic.id%type) return varchar2;        */
    String proc = "{? = call dxdy_executable.get_topic_last_update(?)}";
    CallableStatement st = null;
    String res = "";
    try {
      // System.out.println("Request date for topic ID = " + tID);
      st = connection.prepareCall(proc);
      st.registerOutParameter(1, Types.VARCHAR);
      st.setInt(2, tID);
      st.execute();
      res = st.getString(1);
      // System.out.println("Requested date = " + res);

    } catch (SQLException e) {
      System.out.println("Error while querying last message date of topic ID = " + tID);
      e.printStackTrace();
    } finally {
      if (st != null) {
        try {
          st.close();
        } catch (SQLException e) {
          e.printStackTrace();
        }
      }
    }
    return res;
  }
Example #8
0
  // test: do we get an appropriate update count when using ?=call?
  private static void testUpdate(Connection conn) throws Throwable {
    System.out.println("==============================================");
    System.out.println("TESTING UPDATE COUNT");
    System.out.println("==============================================\n");

    Statement scp = conn.createStatement();

    scp.execute(
        "CREATE FUNCTION returnsIntegerP(P1 INT) RETURNS INTEGER "
            + "EXTERNAL NAME '"
            + CLASS_NAME
            + "returnsIntegerP'"
            + " NO SQL LANGUAGE JAVA PARAMETER STYLE JAVA");

    CallableStatement cs = conn.prepareCall("? = call returnsIntegerP(0)");
    cs.registerOutParameter(1, Types.INTEGER);
    try {
      int updCount = cs.executeUpdate();
      System.out.println("executeUpdate on ? = call returnsIntegerP returned " + updCount);
      System.out.println("getString(1) returned " + cs.getString(1));
    } catch (SQLException se) {
      System.out.println("cs.execute() got unexpected exception: " + se);
    }

    cs.close();
    scp.execute("DROP FUNCTION returnsIntegerP");
    scp.close();
  }
Example #9
0
 @Override
 protected String getParam(String name) {
   /*		function get_setting (
        				p_key in dxdy_spider_setting.key%type) return varchar2;
   */
   String proc = "{? = call dxdy_executable.get_setting (?)}";
   CallableStatement st = null;
   String result = null;
   try {
     st = connection.prepareCall(proc);
     st.registerOutParameter(1, java.sql.Types.VARCHAR);
     st.setString(2, name);
     st.execute();
     result = st.getString(1);
   } catch (SQLException e) {
     e.printStackTrace();
   } finally {
     if (st != null) {
       try {
         st.close();
       } catch (SQLException e) {
         e.printStackTrace();
       }
     }
   }
   return result;
 }
  public static void main(String[] args) {
    // Realiza una función en MySql que dado un curso, devuelva el nombre del tutor. Haz un programa
    // en java que llame a dicha función y muestre por consola el resultado.
    String codOe, codCur;
    Connection conexion = BddConexion.newConexion("horario");
    String sql = "{ ? = call dameTutor(?, ?)}";
    CallableStatement llamada;
    System.out.print("Indique oferta educativa: ");
    codOe = Teclado.leerPalabra();
    System.out.print("Indique curso: ");
    codCur = Teclado.leerPalabra();

    try {
      llamada = conexion.prepareCall(sql);
      llamada.registerOutParameter(1, Types.VARCHAR);
      llamada.setString(2, codOe);
      llamada.setString(3, codCur);
      llamada.executeUpdate();
      System.out.println(llamada.getString(1));
      llamada.close();
    } catch (SQLException e) {
      e.printStackTrace();
    }

    BddConexion.closeConexion(conexion);
  }
 public String getGarageFromResp(
     String profile, Integer userId, Integer respId, Integer respApplId) {
   String garage = null;
   CallableStatement cs = null;
   String statement = "BEGIN ? := FND_PROFILE.VALUE_SPECIFIC(?, ?, ?, ?); END;";
   try {
     cs = getDBTransaction().createCallableStatement(statement, 0);
     cs.registerOutParameter(1, Types.VARCHAR);
     cs.setString(2, profile);
     cs.setInt(3, userId.intValue());
     cs.setInt(4, respId.intValue());
     cs.setInt(5, respApplId.intValue());
     cs.executeUpdate();
     garage = cs.getString(1);
   } catch (SQLException e) {
     _logger.severe("SQL Exception setGarageFromResp", e);
   } finally {
     try {
       if (cs != null) {
         cs.close();
       }
     } catch (SQLException e) {
       _logger.severe("SQL Exception setGarageFromResp", e);
     }
   }
   return garage;
 }
  @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;
  }
  public List<UserBean> fetchRecommendedArtistforArtist(String artistId)
      throws ConnectionFailureException, SQLException, IOException {
    List<UserBean> recommdArtistForArtistList = new ArrayList<UserBean>();
    Connection conn = DBManager.getConnection();
    CallableStatement callableStatement = conn.prepareCall("call FETCH_ARTIST_LIST_PROC(?,?,?)");
    callableStatement.registerOutParameter(2, OracleTypes.CURSOR);
    callableStatement.registerOutParameter(3, java.sql.Types.VARCHAR);
    callableStatement.setString(1, artistId);
    callableStatement.execute();

    String errMsg = callableStatement.getString(3);
    ResultSet rs = ((OracleCallableStatement) callableStatement).getCursor(2);
    if (!callableStatement.wasNull()) {
      while (rs.next()) {
        UserBean userBean = new UserBean();
        userBean.setUserid(rs.getString(1));
        userBean.setFirstName(rs.getString(2));
        userBean.setLastName(rs.getString(3));
        userBean.setPhoneNo(rs.getDouble(4));
        userBean.setDob(rs.getDate(5));
        userBean.setCity(rs.getString(6));
        userBean.setState(rs.getString(7));
        recommdArtistForArtistList.add(userBean);
      }
    }
    if (null != errMsg && !errMsg.isEmpty()) {
      ErrorLog.logError(errMsg);
    }

    if (null != rs) rs.close();
    if (null != callableStatement) callableStatement.close();
    if (null != conn) conn.close();
    return recommdArtistForArtistList;
  }
  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) {
      }
    }
  }
  @Override
  public String lecturas(int periodo, int borrar) {
    try {
      Connection con = dao.getConnection();

      String sql = "{call P_INT_LECTURAS(?,?,?)}";
      CallableStatement statement = con.prepareCall(sql);

      statement.setInt(1, periodo);

      statement.setInt(2, borrar); // preguntar a javier

      statement.registerOutParameter(3, Types.VARCHAR);

      statement.executeQuery();

      String error = statement.getString(3);
      con.close();
      return error;

    } catch (SQLException ex) {
      ex.printStackTrace();
      Logger.getLogger(InterfazManagerImpl.class.getName()).log(Level.SEVERE, null, ex);
      return "Error al ejecutar en la BD";
    }
  }
Example #16
0
  // Method
  public void saveListSendFmDataDetail(Connection conn, Login login) throws SQLException {
    CallableStatement cstmt = null;

    try {
      String sql = "begin FM_AP_SEND_TO_FM_PKG.SAVE_SEND_TO_FM(:1,:2,:3,:4,:5); end;";
      cstmt = conn.prepareCall(sql);
      DeBug.print(sql);

      int returnCode;
      String returnMessage;
      cstmt.setString(1, this.getInvoiceId());
      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  :" + returnCode);
      DeBug.print("returnMessage :" + returnMessage);

      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);
      } else {
        this.setVoucherNo(cstmt.getString(3));
      }

    } catch (Exception e) {
      this.mCode = SAVE_ERROR;
      e.printStackTrace();
      throw new SQLException(e.getMessage());
    } finally {
      if (cstmt != null) {
        cstmt.close();
      }
      cstmt = null;
    }
  }
 public Map<String, String> updateTask(String taskStatus) {
   Map<String, String> resultMap = new HashMap<String, String>();
   String status = "E";
   String message = null;
   XxntcCsCalendarActivitiesEOVOImpl vo = getXxntcCsCalendarActivitiesEOVO2Update();
   Row row = vo.getCurrentRow();
   Date startTime = (Date) row.getAttribute("StartTime");
   Date endTime = (Date) row.getAttribute("EndTime");
   Number incidentId = (Number) row.getAttribute("IncidentId");
   Number resourceId = (Number) row.getAttribute("ResourceId");
   _logger.warning("Before Calling API");
   _logger.warning("taskStatus:" + taskStatus.toString());
   _logger.warning("startTime:" + startTime.toString());
   _logger.warning("endTime:" + endTime.toString());
   _logger.warning("incidentId:" + incidentId.toString());
   _logger.warning("resourceId:" + resourceId.toString());
   CallableStatement cs = null;
   String statement = "BEGIN XXNTC_CALENDAR_PKG.SCHEDULE_SR_PRC(?, ?, ?, ?, ?, ?, ?); END;";
   try {
     cs = getDBTransaction().createCallableStatement(statement, 0);
     cs.registerOutParameter(6, Types.VARCHAR);
     cs.registerOutParameter(7, Types.VARCHAR);
     cs.setString(1, taskStatus);
     cs.setDate(2, startTime.dateValue());
     cs.setDate(3, endTime.dateValue());
     cs.setInt(4, incidentId.intValue());
     cs.setLong(5, resourceId.longValue());
     cs.executeUpdate();
     status = cs.getString(6);
     message = cs.getString(7);
   } catch (SQLException e) {
     _logger.severe("Sql Exception during statement call", e);
   } finally {
     try {
       if (cs != null) cs.close();
     } catch (SQLException e) {
       _logger.severe("Sql Exception While Closing Callable Statement", e);
     }
   }
   resultMap.put("x_status", status);
   resultMap.put("x_error_message", message);
   _logger.warning("After API is called");
   _logger.warning("x_status:" + status);
   _logger.warning("x_error_message:" + message);
   return resultMap;
 }
 @Override
 public void bind(CallableStatement statement, int position, Scope queryScope) {
   RuntimeSQLException.execute(
       () -> {
         statement.registerOutParameter(position, Types.LONGVARCHAR);
         queryScope.add(() -> this.value = statement.getString(position));
       });
 }
 @Override
 public Boolean getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
   String value = cs.getString(columnIndex);
   if (null == value) {
     return false;
   }
   return value.equals("Y") ? true : false;
 }
 public String getString(String parameterName) throws SQLException {
   checkOpen();
   try {
     return _stmt.getString(parameterName);
   } catch (SQLException e) {
     handleException(e);
     return null;
   }
 }
Example #21
0
  public String[] callplBtnprocess(
      String processId, String programId, String username, int org, String preD, String sentD) {

    String[] results = null;
    Connection dbConnection = null;
    CallableStatement callableStatement = null;
    _log.info("##into PL");

    String MR_SP_ZZZZ_RESTORE_PROCESS_Sql = "{call MR_STP_PREPARE_AND_SEND_DATA(?,?,?,?,?,?,?,?)}";
    try {
      dbConnection = DBManager.getNoJtaDataSource();
      callableStatement = dbConnection.prepareCall(MR_SP_ZZZZ_RESTORE_PROCESS_Sql);
      /*
              p_status        OUT  VARCHAR2,
              p_result        OUT  VARCHAR2,
              p_user_name     IN   VARCHAR2,
              p_org_id        IN   NUMBER,
              p_process_id    IN   VARCHAR2,
              p_program_id    IN   VARCHAR2,
              p_prepare_data  IN   VARCHAR2,  7
              p_send_data     IN   VARCHAR2   8
      */
      callableStatement.registerOutParameter(1, java.sql.Types.VARCHAR);
      callableStatement.registerOutParameter(2, java.sql.Types.VARCHAR);
      callableStatement.setString(3, username);
      callableStatement.setInt(4, 1);
      callableStatement.setString(5, processId);
      callableStatement.setString(6, programId);

      callableStatement.setString(7, preD);
      callableStatement.setString(8, sentD);
      callableStatement.executeUpdate();
      String status = callableStatement.getString(1);
      String result = callableStatement.getString(2);
      results = new String[] {status, result};
      _log.info("status 2: " + status);
      _log.info("result 2: " + result);
    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      if (callableStatement != null) {
        try {
          callableStatement.close();
        } catch (SQLException e) {
          e.printStackTrace();
        }
      }
      if (dbConnection != null) {
        try {
          dbConnection.close();
        } catch (SQLException e) {
          e.printStackTrace();
        }
      }
    }
    return results;
  }
 @Override
 public Character getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
   String columnValue = cs.getString(columnIndex);
   if (columnValue != null) {
     return columnValue.charAt(0);
   } else {
     return null;
   }
 }
 @Override
 public Object getResult(CallableStatement cs, int columnIndex) throws SQLException {
   String s = cs.getString(columnIndex);
   if (cs.wasNull()) {
     return null;
   } else {
     Character c = s.charAt(0);
     return new Character(c);
   }
 }
Example #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();
      }
    }
  }
Example #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();
      }
    }
  }
Example #26
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;
    }
  }
  /**
   *
   *
   * <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;
  }
Example #28
0
  /** The string value */
  @Override
  public String getString(String name) throws SQLException {
    try {
      return _cstmt.getString(name);
    } catch (SQLException e) {
      onSqlException(e);

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

      throw e;
    }
  }
Example #29
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;
  }
Example #30
0
  private static void executeOutput(CallableStatement cs) throws SQLException {

    for (int p = 1; p <= 5; p++) cs.registerOutParameter(p, Types.INTEGER);

    for (int p = 6; p <= 10; p++) cs.registerOutParameter(p, Types.VARCHAR);

    cs.execute();

    for (int p = 1; p <= 5; p++) {
      System.out.println("  " + p + " = " + cs.getInt(p) + " was null " + cs.wasNull());
    }
    for (int p = 6; p <= 10; p++) {
      System.out.println("  " + p + " = " + cs.getString(p) + " was null " + cs.wasNull());
    }
  }