public void updateServiceType(
     CFSecurityAuthorization Authorization, CFSecurityServiceTypeBuff Buff) {
   final String S_ProcName = "updateServiceType";
   ResultSet resultSet = null;
   try {
     int ServiceTypeId = Buff.getRequiredServiceTypeId();
     String Description = Buff.getRequiredDescription();
     int Revision = Buff.getRequiredRevision();
     Connection cnx = schema.getCnx();
     String sql = "exec sp_update_svctype ?, ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?";
     if (stmtUpdateByPKey == null) {
       stmtUpdateByPKey = cnx.prepareStatement(sql);
     }
     int argIdx = 1;
     stmtUpdateByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtUpdateByPKey.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
     stmtUpdateByPKey.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
     stmtUpdateByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtUpdateByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     stmtUpdateByPKey.setString(argIdx++, "SVCT");
     stmtUpdateByPKey.setInt(argIdx++, ServiceTypeId);
     stmtUpdateByPKey.setString(argIdx++, Description);
     stmtUpdateByPKey.setInt(argIdx++, Revision);
     resultSet = stmtUpdateByPKey.executeQuery();
     if (resultSet.next()) {
       CFSecurityServiceTypeBuff updatedBuff = unpackServiceTypeResultSetToBuff(resultSet);
       if (resultSet.next()) {
         resultSet.last();
         throw CFLib.getDefaultExceptionFactory()
             .newRuntimeException(
                 getClass(),
                 S_ProcName,
                 "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
       }
       Buff.setRequiredDescription(updatedBuff.getRequiredDescription());
       Buff.setRequiredRevision(updatedBuff.getRequiredRevision());
     } else {
       throw CFLib.getDefaultExceptionFactory()
           .newRuntimeException(
               getClass(),
               S_ProcName,
               "Expected a single-record response, " + resultSet.getRow() + " rows selected");
     }
   } catch (SQLException e) {
     throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
   } finally {
     if (resultSet != null) {
       try {
         resultSet.close();
       } catch (SQLException e) {
       }
       resultSet = null;
     }
   }
 }
 public CFSecurityTSecGroupBuff lockBuff(
     CFSecurityAuthorization Authorization, CFSecurityTSecGroupPKey PKey) {
   final String S_ProcName = "lockBuff";
   if (!schema.isTransactionOpen()) {
     throw CFLib.getDefaultExceptionFactory()
         .newUsageException(getClass(), S_ProcName, "Transaction not open");
   }
   ResultSet resultSet = null;
   try {
     Connection cnx = schema.getCnx();
     long TenantId = PKey.getRequiredTenantId();
     int TSecGroupId = PKey.getRequiredTSecGroupId();
     String sql =
         "SELECT * FROM "
             + schema.getLowerDbSchemaName()
             + ".sp_lock_tsecgrp( ?, ?, ?, ?, ?"
             + ", "
             + "?"
             + ", "
             + "?"
             + " )";
     if (stmtLockBuffByPKey == null) {
       stmtLockBuffByPKey = cnx.prepareStatement(sql);
     }
     int argIdx = 1;
     stmtLockBuffByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtLockBuffByPKey.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
     stmtLockBuffByPKey.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
     stmtLockBuffByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtLockBuffByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     stmtLockBuffByPKey.setLong(argIdx++, TenantId);
     stmtLockBuffByPKey.setInt(argIdx++, TSecGroupId);
     resultSet = stmtLockBuffByPKey.executeQuery();
     if (resultSet.next()) {
       CFSecurityTSecGroupBuff buff = unpackTSecGroupResultSetToBuff(resultSet);
       if (resultSet.next()) {
         throw CFLib.getDefaultExceptionFactory()
             .newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response");
       }
       return (buff);
     } else {
       return (null);
     }
   } catch (SQLException e) {
     throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
   } finally {
     if (resultSet != null) {
       try {
         resultSet.close();
       } catch (SQLException e) {
       }
       resultSet = null;
     }
   }
 }
  /**
   * Get organisation's nomination rater status
   *
   * @param iOrgID
   * @return
   * @throws SQLException
   * @throws Exception
   * @author Desmond
   */
  public boolean getNomRater(int iOrgID) throws SQLException, Exception {
    String query = "SELECT NominationModule FROM tblOrganization WHERE PKOrganization =" + iOrgID;
    boolean iNomRater = true;

    Connection con = null;
    Statement st = null;
    ResultSet rs = null;

    try {
      con = ConnectionBean.getConnection();
      st = con.createStatement();
      rs = st.executeQuery(query);

      if (rs.next()) {
        iNomRater = rs.getBoolean(1);
      }

    } catch (Exception E) {
      System.err.println("Organization.java - getNomRater - " + E);
    } finally {
      ConnectionBean.closeRset(rs); // Close ResultSet
      ConnectionBean.closeStmt(st); // Close statement
      ConnectionBean.close(con); // Close connection
    }

    return iNomRater;
  } // End getNomRater()
  public int delete(ValueObject obj) throws SQLException {

    if ((obj instanceof PT_KICA_ERR_LOGEntity) == false) {
      throw new SQLException("DAO 에러(1): PT_KICA_ERR_LOG : delete() ");
    }
    PT_KICA_ERR_LOGEntity entity = (PT_KICA_ERR_LOGEntity) obj;

    Connection conn = null;
    PreparedStatement ps = null;
    int result = 0;

    StringBuffer sb = new StringBuffer();
    sb.append("delete from PT_KICA_ERR_LOG  where  1=1")
        .append(" and SEQ = ")
        .append(toDB(entity.getSEQ()));

    KJFLog.sql(sb.toString());

    try {

      conn = this.getConnection();
      ps = conn.prepareStatement(sb.toString());

      result = ps.executeUpdate();

    } catch (SQLException e) {
      throw e;
    } finally {
      if (ps != null) ps.close();
      this.release(conn);
    }

    return result;
  }
  public void deleteISOTimezone(
      CFSecurityAuthorization Authorization, CFSecurityISOTimezoneBuff Buff) {
    final String S_ProcName = "deleteISOTimezone";
    ResultSet resultSet = null;
    try {
      Connection cnx = schema.getCnx();
      short ISOTimezoneId = Buff.getRequiredISOTimezoneId();

      String sql =
          "SELECT "
              + schema.getLowerDbSchemaName()
              + ".sp_delete_isotz( ?, ?, ?, ?, ?"
              + ", "
              + "?"
              + ", "
              + "?"
              + " ) as DeletedFlag";
      if (stmtDeleteByPKey == null) {
        stmtDeleteByPKey = cnx.prepareStatement(sql);
      }
      int argIdx = 1;
      stmtDeleteByPKey.setLong(
          argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
      stmtDeleteByPKey.setString(
          argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
      stmtDeleteByPKey.setString(
          argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
      stmtDeleteByPKey.setLong(
          argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
      stmtDeleteByPKey.setLong(
          argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
      stmtDeleteByPKey.setShort(argIdx++, ISOTimezoneId);
      stmtDeleteByPKey.setInt(argIdx++, Buff.getRequiredRevision());
      ;
      resultSet = stmtDeleteByPKey.executeQuery();
      if (resultSet.next()) {
        boolean deleteFlag = resultSet.getBoolean(1);
        if (resultSet.next()) {
          throw CFLib.getDefaultExceptionFactory()
              .newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response");
        }
      } else {
        throw CFLib.getDefaultExceptionFactory()
            .newRuntimeException(
                getClass(),
                S_ProcName,
                "Expected 1 record result set to be returned by delete, not 0 rows");
      }
    } catch (SQLException e) {
      throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
      if (resultSet != null) {
        try {
          resultSet.close();
        } catch (SQLException e) {
        }
        resultSet = null;
      }
    }
  }
 public CFSecuritySecDeviceBuff[] readBuffByUserIdx(
     CFSecurityAuthorization Authorization, UUID SecUserId) {
   final String S_ProcName = "readBuffByUserIdx";
   ResultSet resultSet = null;
   try {
     Connection cnx = schema.getCnx();
     String sql =
         "call "
             + schema.getLowerDbSchemaName()
             + ".sp_read_secdev_by_useridx( ?, ?, ?, ?, ?"
             + ", "
             + "?"
             + " )";
     if (stmtReadBuffByUserIdx == null) {
       stmtReadBuffByUserIdx = cnx.prepareStatement(sql);
     }
     int argIdx = 1;
     stmtReadBuffByUserIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtReadBuffByUserIdx.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
     stmtReadBuffByUserIdx.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
     stmtReadBuffByUserIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtReadBuffByUserIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     stmtReadBuffByUserIdx.setString(argIdx++, SecUserId.toString());
     try {
       resultSet = stmtReadBuffByUserIdx.executeQuery();
     } catch (SQLException e) {
       if (e.getErrorCode() != 1329) {
         throw e;
       }
       resultSet = null;
     }
     List<CFSecuritySecDeviceBuff> buffList = new LinkedList<CFSecuritySecDeviceBuff>();
     while ((resultSet != null) && resultSet.next()) {
       CFSecuritySecDeviceBuff buff = unpackSecDeviceResultSetToBuff(resultSet);
       buffList.add(buff);
     }
     int idx = 0;
     CFSecuritySecDeviceBuff[] retBuff = new CFSecuritySecDeviceBuff[buffList.size()];
     Iterator<CFSecuritySecDeviceBuff> iter = buffList.iterator();
     while (iter.hasNext()) {
       retBuff[idx++] = iter.next();
     }
     return (retBuff);
   } catch (SQLException e) {
     throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
   } finally {
     if (resultSet != null) {
       try {
         resultSet.close();
       } catch (SQLException e) {
       }
       resultSet = null;
     }
   }
 }
  public String getOrganisationName(int iFKOrg) {
    String sOrgName = "";
    String querySql = "SELECT * FROM tblOrganization WHERE PKOrganization = " + iFKOrg;

    Connection con = null;
    Statement st = null;
    ResultSet rs = null;

    try {
      con = ConnectionBean.getConnection();
      st = con.createStatement();
      rs = st.executeQuery(querySql);

      if (rs.next()) sOrgName = rs.getString("OrganizationName");

    } catch (Exception E) {
      System.err.println("Organization.java - getOrganizationName - " + E);
    } finally {

      ConnectionBean.closeRset(rs); // Close ResultSet
      ConnectionBean.closeStmt(st); // Close statement
      ConnectionBean.close(con); // Close connection
    }

    return sOrgName;
  }
 private void ListValueChanged(
     javax.swing.event.ListSelectionEvent evt) { // GEN-FIRST:event_ListValueChanged
   // TODO add your handling code here:
   // String part=partno.getText();
   try {
     String sql =
         "SELECT  TYPE,ITEM_NAME,QUANTITY,MRP FROM MOTORS WHERE ITEM_NAME='"
             + List.getSelectedValue()
             + "'";
     Class.forName("com.mysql.jdbc.Driver");
     Connection con =
         (Connection)
             DriverManager.getConnection("jdbc:mysql://localhost:3306/bharatmotors", "root", "");
     Statement stmt = con.createStatement();
     ResultSet rs = stmt.executeQuery(sql);
     while (rs.next()) {
       partno.setText(rs.getString("TYPE"));
       name.setText(rs.getString("ITEM_NAME"));
       qty.setText(rs.getString("QUANTITY"));
       rate.setText(rs.getString("MRP"));
     }
   } catch (Exception e) {
     JOptionPane.showMessageDialog(null, e.toString());
   }
 } // GEN-LAST:event_ListValueChanged
  /* Method Name : isConsulting
   * Checks whether login organisation is a Consulting Company
   * @param sOrgName
   * @param orgCode
   * @author Mark Oei
   * @since v.1.3.12.63 (09 Mar 2010)
   */
  public boolean isConsulting(String orgName) {
    String sOrgName = "";
    orgName = "\'" + orgName + "\'";
    String querySql = "SELECT * FROM tblConsultingCompany WHERE CompanyName = " + orgName;
    // Change to disable print statement. Used for debugging only
    // Mark Oei 19 Mar 2010
    // System.out.println("testing " + orgName);
    Connection con = null;
    Statement st = null;
    ResultSet rs = null;

    try {
      con = ConnectionBean.getConnection();
      st = con.createStatement();
      rs = st.executeQuery(querySql);

      if (rs.next()) sOrgName = rs.getString("CompanyName");
    } catch (Exception E) {
      System.err.println("Organization.java - isConsulting - " + E);
    } finally {

      ConnectionBean.closeRset(rs); // Close ResultSet
      ConnectionBean.closeStmt(st); // Close statement
      ConnectionBean.close(con); // Close connection
    }
    // Change to disable print statement. Used for debugging only
    // Mark Oei 19 Mar 2010
    // System.out.println("testing " + sOrgName);
    if ((sOrgName == null) || (sOrgName == "")) return false;
    else return true;
  } // End of isConsulting
  /**
   * Get Company ID by OrganisationID
   *
   * @param OrgID
   * @return PKCompany
   * @throws SQLException
   * @throws Exception
   */
  public int getCompanyID(int OrgID) throws SQLException, Exception {
    String query = "Select FKCompanyID from tblOrganization WHERE PKOrganization = " + OrgID;

    /*db.openDB();
    Statement stmt = db.con.createStatement();
    ResultSet rs = stmt.executeQuery(query);

    if(rs.next())
    	return rs.getInt(1);*/
    int iCompanyID = 0;
    Connection con = null;
    Statement st = null;
    ResultSet rs = null;

    try {

      con = ConnectionBean.getConnection();
      st = con.createStatement();
      rs = st.executeQuery(query);

      if (rs.next()) {
        iCompanyID = rs.getInt(1);
      }

    } catch (Exception E) {
      System.err.println("Organization.java - getCompanyID - " + E);
    } finally {

      ConnectionBean.closeRset(rs); // Close ResultSet
      ConnectionBean.closeStmt(st); // Close statement
      ConnectionBean.close(con); // Close connection
    }

    return iCompanyID;
  }
  /** Get Organisation ID by User email */
  public int getOrgIDbyEmail(String UserEmail) throws SQLException, Exception {
    String query = "Select COUNT(*) as TotRecord from tblEmail";
    int count = 0;
    Connection con = null;
    Statement st = null;
    ResultSet rs = null;

    try {
      con = ConnectionBean.getConnection();
      st = con.createStatement();
      rs = st.executeQuery(query);

      if (rs.next()) {
        count = rs.getInt(1);
      }

    } catch (Exception E) {
      System.err.println("Organization.java - editRecord - " + E);
    } finally {
      ConnectionBean.closeRset(rs); // Close ResultSet
      ConnectionBean.closeStmt(st); // Close statement
      ConnectionBean.close(con); // Close connection
    }

    return count;
  }
 public void deleteTSecGroupByTenantVisIdx(
     CFSecurityAuthorization Authorization, long TenantId, boolean IsVisible) {
   final String S_ProcName = "deleteTSecGroupByTenantVisIdx";
   if (!schema.isTransactionOpen()) {
     throw CFLib.getDefaultExceptionFactory()
         .newUsageException(getClass(), S_ProcName, "Transaction not open");
   }
   ResultSet resultSet = null;
   try {
     Connection cnx = schema.getCnx();
     String sql = "exec sp_delete_tsecgrp_by_tenantvisidx ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?";
     if (stmtDeleteByTenantVisIdx == null) {
       stmtDeleteByTenantVisIdx = cnx.prepareStatement(sql);
     }
     int argIdx = 1;
     stmtDeleteByTenantVisIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtDeleteByTenantVisIdx.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
     stmtDeleteByTenantVisIdx.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
     stmtDeleteByTenantVisIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtDeleteByTenantVisIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     stmtDeleteByTenantVisIdx.setLong(argIdx++, TenantId);
     if (IsVisible) {
       stmtDeleteByTenantVisIdx.setString(argIdx++, "Y");
     } else {
       stmtDeleteByTenantVisIdx.setString(argIdx++, "N");
     }
     Object stuff = null;
     boolean moreResults = stmtDeleteByTenantVisIdx.execute();
     while (stuff == null) {
       try {
         moreResults = stmtDeleteByTenantVisIdx.getMoreResults();
       } catch (SQLException e) {
         throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
       }
       if (moreResults) {
         try {
           stuff = stmtDeleteByTenantVisIdx.getResultSet();
         } catch (SQLException e) {
         }
       } else if (-1 == stmtDeleteByTenantVisIdx.getUpdateCount()) {
         break;
       }
     }
   } catch (SQLException e) {
     throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
   } finally {
     if (resultSet != null) {
       try {
         resultSet.close();
       } catch (SQLException e) {
       }
       resultSet = null;
     }
   }
 }
  public long nextTSecGroupMemberIdGen(
      CFSecurityAuthorization Authorization, CFSecurityTenantPKey PKey) {
    final String S_ProcName = "nextTSecGroupMemberIdGen";
    if (!schema.isTransactionOpen()) {
      throw CFLib.getDefaultExceptionFactory()
          .newUsageException(getClass(), S_ProcName, "Not in a transaction");
    }
    Connection cnx = schema.getCnx();
    long Id = PKey.getRequiredId();

    CallableStatement stmtSelectNextTSecGroupMemberIdGen = null;
    try {
      String sql = "{ call sp_next_tsecgroupmemberidgen( ?" + ", " + "?" + " ) }";
      stmtSelectNextTSecGroupMemberIdGen = cnx.prepareCall(sql);
      int argIdx = 1;
      stmtSelectNextTSecGroupMemberIdGen.registerOutParameter(argIdx++, java.sql.Types.BIGINT);
      stmtSelectNextTSecGroupMemberIdGen.setLong(argIdx++, Id);
      stmtSelectNextTSecGroupMemberIdGen.execute();
      long nextId = stmtSelectNextTSecGroupMemberIdGen.getLong(1);
      return (nextId);
    } catch (SQLException e) {
      throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
      if (stmtSelectNextTSecGroupMemberIdGen != null) {
        try {
          stmtSelectNextTSecGroupMemberIdGen.close();
        } catch (SQLException e) {
        }
        stmtSelectNextTSecGroupMemberIdGen = null;
      }
    }
  }
  public int update(ValueObject obj) throws SQLException {

    if ((obj instanceof PT_KICA_ERR_LOGEntity) == false) {
      throw new SQLException("DAO 에러(1): PT_KICA_ERR_LOG : update() ");
    }
    PT_KICA_ERR_LOGEntity entity = (PT_KICA_ERR_LOGEntity) obj;

    Connection conn = null;
    PreparedStatement ps = null;
    int result = 0;

    StringBuffer sb = new StringBuffer();
    sb.append("update PT_KICA_ERR_LOG  set ")
        .append("U_D_FLAG = ")
        .append(toDB(entity.getU_D_FLAG()))
        .append(",")
        .append("YYYYMMDD = ")
        .append(toDB(entity.getYYYYMMDD()))
        .append(",")
        .append("TRANSHOUR = ")
        .append(toDB(entity.getTRANSHOUR()))
        .append(",")
        .append("FILENAME = ")
        .append(toDB(entity.getFILENAME()))
        .append(",")
        .append("ERRLOG = ")
        .append(toDB(entity.getERRLOG()))
        .append(",")
        .append("RESULT_FLAG = ")
        .append(toDB(entity.getRESULT_FLAG()))
        .append(",")
        .append("UPD_DT = ")
        .append(toDB(entity.getUPD_DT()))
        .append(",")
        .append("INS_DT = ")
        .append(toDB(entity.getINS_DT()))
        .append(" where  1=1 ");

    sb.append(" and SEQ = ").append(toDB(entity.getSEQ()));

    KJFLog.sql(sb.toString());

    try {

      conn = this.getConnection();
      ps = conn.prepareStatement(sb.toString());

      int i = 1;

      result = ps.executeUpdate();

    } catch (SQLException e) {
      throw e;
    } finally {
      if (ps != null) ps.close();
      this.release(conn);
    }

    return result;
  }
  /**
   * Get organisation's name sequence
   *
   * @param iOrgID
   * @return
   * @throws SQLException
   * @throws Exception
   * @author Maruli
   */
  public int getNameSeq(int iOrgID) throws SQLException, Exception {
    String query = "SELECT NameSequence FROM tblOrganization WHERE PKOrganization =" + iOrgID;
    int iNameSeqe = 0;

    Connection con = null;
    Statement st = null;
    ResultSet rs = null;

    try {
      con = ConnectionBean.getConnection();
      st = con.createStatement();
      rs = st.executeQuery(query);

      if (rs.next()) {
        iNameSeqe = rs.getInt(1);
      }

    } catch (Exception E) {
      System.err.println("Organization.java - getNameSeq - " + E);
    } finally {
      ConnectionBean.closeRset(rs); // Close ResultSet
      ConnectionBean.closeStmt(st); // Close statement
      ConnectionBean.close(con); // Close connection
    }

    return iNameSeqe;
  }
 public CFInternetTopDomainBuff readBuffByNameIdx(
     CFSecurityAuthorization Authorization, long TenantId, long TldId, String Name) {
   final String S_ProcName = "readBuffByNameIdx";
   ResultSet resultSet = null;
   try {
     Connection cnx = schema.getCnx();
     final String sql =
         "CALL sp_read_tdomdef_by_nameidx( ?, ?, ?, ?, ?"
             + ", "
             + "?"
             + ", "
             + "?"
             + ", "
             + "?"
             + " )";
     if (stmtReadBuffByNameIdx == null) {
       stmtReadBuffByNameIdx = cnx.prepareStatement(sql);
     }
     int argIdx = 1;
     stmtReadBuffByNameIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtReadBuffByNameIdx.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
     stmtReadBuffByNameIdx.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
     stmtReadBuffByNameIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtReadBuffByNameIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     stmtReadBuffByNameIdx.setLong(argIdx++, TenantId);
     stmtReadBuffByNameIdx.setLong(argIdx++, TldId);
     stmtReadBuffByNameIdx.setString(argIdx++, Name);
     resultSet = stmtReadBuffByNameIdx.executeQuery();
     if (resultSet.next()) {
       CFInternetTopDomainBuff buff = unpackTopDomainResultSetToBuff(resultSet);
       if (resultSet.next()) {
         resultSet.last();
         throw CFLib.getDefaultExceptionFactory()
             .newRuntimeException(
                 getClass(),
                 S_ProcName,
                 "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
       }
       return (buff);
     } else {
       return (null);
     }
   } catch (SQLException e) {
     throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
   } finally {
     if (resultSet != null) {
       try {
         resultSet.close();
       } catch (SQLException e) {
       }
       resultSet = null;
     }
   }
 }
 public CFCrmContactTagBuff readBuff(
     CFSecurityAuthorization Authorization, CFCrmContactTagPKey PKey) {
   final String S_ProcName = "readBuff";
   if (!schema.isTransactionOpen()) {
     throw CFLib.getDefaultExceptionFactory()
         .newUsageException(getClass(), S_ProcName, "Transaction not open");
   }
   ResultSet resultSet = null;
   try {
     Connection cnx = schema.getCnx();
     long TenantId = PKey.getRequiredTenantId();
     long ContactId = PKey.getRequiredContactId();
     long TagId = PKey.getRequiredTagId();
     String sql =
         "{ call sp_read_ctc_tag( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + " ) }";
     if (stmtReadBuffByPKey == null) {
       stmtReadBuffByPKey = cnx.prepareStatement(sql);
     }
     int argIdx = 1;
     stmtReadBuffByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtReadBuffByPKey.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
     stmtReadBuffByPKey.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
     stmtReadBuffByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtReadBuffByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     stmtReadBuffByPKey.setLong(argIdx++, TenantId);
     stmtReadBuffByPKey.setLong(argIdx++, ContactId);
     stmtReadBuffByPKey.setLong(argIdx++, TagId);
     resultSet = stmtReadBuffByPKey.executeQuery();
     if ((resultSet != null) && resultSet.next()) {
       CFCrmContactTagBuff buff = unpackContactTagResultSetToBuff(resultSet);
       if (resultSet.next()) {
         resultSet.last();
         throw CFLib.getDefaultExceptionFactory()
             .newRuntimeException(
                 getClass(),
                 S_ProcName,
                 "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
       }
       return (buff);
     } else {
       return (null);
     }
   } catch (SQLException e) {
     throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
   } finally {
     if (resultSet != null) {
       try {
         resultSet.close();
       } catch (SQLException e) {
       }
       resultSet = null;
     }
   }
 }
 public CFSecurityISOCountryLanguageBuff[] readAllBuff(CFSecurityAuthorization Authorization) {
   final String S_ProcName = "readAllBuff";
   if (!schema.isTransactionOpen()) {
     throw CFLib.getDefaultExceptionFactory()
         .newUsageException(getClass(), S_ProcName, "Transaction not open");
   }
   ResultSet resultSet = null;
   try {
     Connection cnx = schema.getCnx();
     String sql =
         "call " + schema.getLowerDbSchemaName() + ".sp_read_iso_cntrylng_all( ?, ?, ?, ?, ? )";
     if (stmtReadAllBuff == null) {
       stmtReadAllBuff = cnx.prepareStatement(sql);
     }
     int argIdx = 1;
     stmtReadAllBuff.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtReadAllBuff.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
     stmtReadAllBuff.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
     stmtReadAllBuff.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtReadAllBuff.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     try {
       resultSet = stmtReadAllBuff.executeQuery();
     } catch (SQLException e) {
       if (e.getErrorCode() != 1329) {
         throw e;
       }
       resultSet = null;
     }
     List<CFSecurityISOCountryLanguageBuff> buffList =
         new LinkedList<CFSecurityISOCountryLanguageBuff>();
     while ((resultSet != null) && resultSet.next()) {
       CFSecurityISOCountryLanguageBuff buff = unpackISOCountryLanguageResultSetToBuff(resultSet);
       buffList.add(buff);
     }
     int idx = 0;
     CFSecurityISOCountryLanguageBuff[] retBuff =
         new CFSecurityISOCountryLanguageBuff[buffList.size()];
     Iterator<CFSecurityISOCountryLanguageBuff> iter = buffList.iterator();
     while (iter.hasNext()) {
       retBuff[idx++] = iter.next();
     }
     return (retBuff);
   } catch (SQLException e) {
     throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
   } finally {
     if (resultSet != null) {
       try {
         resultSet.close();
       } catch (SQLException e) {
       }
       resultSet = null;
     }
   }
 }
  public void deleteContactTag(CFSecurityAuthorization Authorization, CFCrmContactTagBuff Buff) {
    final String S_ProcName = "deleteContactTag";
    try {
      Connection cnx = schema.getCnx();
      long TenantId = Buff.getRequiredTenantId();
      long ContactId = Buff.getRequiredContactId();
      long TagId = Buff.getRequiredTagId();

      String sql =
          "exec sp_delete_ctc_tag ?, ?, ?, ?, ?"
              + ", "
              + "?"
              + ", "
              + "?"
              + ", "
              + "?"
              + ", "
              + "?";
      if (stmtDeleteByPKey == null) {
        stmtDeleteByPKey = cnx.prepareStatement(sql);
      }
      int argIdx = 1;
      stmtDeleteByPKey.setLong(
          argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
      stmtDeleteByPKey.setString(
          argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
      stmtDeleteByPKey.setString(
          argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
      stmtDeleteByPKey.setLong(
          argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
      stmtDeleteByPKey.setLong(
          argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
      stmtDeleteByPKey.setLong(argIdx++, TenantId);
      stmtDeleteByPKey.setLong(argIdx++, ContactId);
      stmtDeleteByPKey.setLong(argIdx++, TagId);
      stmtDeleteByPKey.setInt(argIdx++, Buff.getRequiredRevision());
      ;
      Object stuff = null;
      boolean moreResults = stmtDeleteByPKey.execute();
      while (stuff == null) {
        try {
          moreResults = stmtDeleteByPKey.getMoreResults();
        } catch (SQLException e) {
          throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
        }
        if (moreResults) {
          try {
            stuff = stmtDeleteByPKey.getResultSet();
          } catch (SQLException e) {
          }
        } else if (-1 == stmtDeleteByPKey.getUpdateCount()) {
          break;
        }
      }
    } catch (SQLException e) {
      throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    }
  }
  private void jButton3ActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_jButton3ActionPerformed
    try {
      Connection con =
          (Connection)
              DriverManager.getConnection("jdbc:mysql://localhost:3306/bharatmotors", "root", "");
      Statement stmt = con.createStatement();

      ResultSet resultSet = stmt.executeQuery("select Bill_No from bill;");

      String productCode = null;

      while (resultSet.next()) {
        productCode = resultSet.getString("Bill_No");
      }
      int pc = Integer.parseInt(productCode);
      System.out.println(pc);
      no.setText((String.valueOf(++pc)));
      // TODO add your handling code here:

      String part = partno.getText();
      String itemname = name.getText();
      String qty1 = qty.getText();
      String rate1 = rate.getText();
      // String amo=amount.getText();
      String noo = no.getText();
      no1 = Integer.parseInt(noo);
      cname = custname.getText();
      bill1 = bill.getText();
      addr1 = addr.getText();

      String ta = tax.getText();
      int a = Integer.parseInt(qty1);
      int b = Integer.parseInt(rate1);
      int c = a * b;
      String str = Integer.toString(c);
      amount.setText(str);
      String str1 = amount.getText();
      /* String sql1="select Quantity from lubricants";
      String sql2="UPDATE LUBRICANTS SET QUANTITY=QUANTITY-qty1 WHERE PART_NO='"+partno+"'";
      Statement stmt1=con.createStatement();
      ResultSet rs1= stmt1.executeQuery(sql1);

      String ch=rs1.getString("QUANTITY");
      int q=Integer.parseInt(qty1);
      int r=Integer.parseInt(ch);
      if(q >r)
      {
          JOptionPane.showMessageDialog(this,"STOCK UNAVAILABLE");
      }
      else
      {
          stmt1.executeUpdate(sql2);
      }*/
    } catch (SQLException ex) {
      Logger.getLogger(Billspare.class.getName()).log(Level.SEVERE, null, ex);
    }
  } // GEN-LAST:event_jButton3ActionPerformed
  public void deleteTopDomain(CFSecurityAuthorization Authorization, CFInternetTopDomainBuff Buff) {
    final String S_ProcName = "deleteTopDomain";
    ResultSet resultSet = null;
    try {
      Connection cnx = schema.getCnx();
      long TenantId = Buff.getRequiredTenantId();
      long Id = Buff.getRequiredId();

      final String sql =
          "CALL sp_delete_tdomdef( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + ", " + "?" + " )";
      if (stmtDeleteByPKey == null) {
        stmtDeleteByPKey = cnx.prepareStatement(sql);
      }
      int argIdx = 1;
      stmtDeleteByPKey.setLong(
          argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
      stmtDeleteByPKey.setString(
          argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
      stmtDeleteByPKey.setString(
          argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
      stmtDeleteByPKey.setLong(
          argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
      stmtDeleteByPKey.setLong(
          argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
      stmtDeleteByPKey.setLong(argIdx++, TenantId);
      stmtDeleteByPKey.setLong(argIdx++, Id);
      stmtDeleteByPKey.setInt(argIdx++, Buff.getRequiredRevision());
      ;
      resultSet = stmtDeleteByPKey.executeQuery();
      if (resultSet.next()) {
        int deleteFlag = resultSet.getInt(1);
        if (resultSet.next()) {
          resultSet.last();
          throw CFLib.getDefaultExceptionFactory()
              .newRuntimeException(
                  getClass(),
                  S_ProcName,
                  "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
        }
      } else {
        throw CFLib.getDefaultExceptionFactory()
            .newRuntimeException(
                getClass(),
                S_ProcName,
                "Expected 1 record result set to be returned by delete, not 0 rows");
      }
    } catch (SQLException e) {
      throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
    } finally {
      if (resultSet != null) {
        try {
          resultSet.close();
        } catch (SQLException e) {
        }
        resultSet = null;
      }
    }
  }
 public void deleteTSecGroupByUNameIdx(
     CFSecurityAuthorization Authorization, long argTenantId, String argName) {
   final String S_ProcName = "deleteTSecGroupByUNameIdx";
   ResultSet resultSet = null;
   try {
     Connection cnx = schema.getCnx();
     String sql =
         "SELECT "
             + schema.getLowerDbSchemaName()
             + ".sp_delete_tsecgrp_by_unameidx( ?, ?, ?, ?, ?"
             + ", "
             + "?"
             + ", "
             + "?"
             + " ) as DeletedFlag";
     if (stmtDeleteByUNameIdx == null) {
       stmtDeleteByUNameIdx = cnx.prepareStatement(sql);
     }
     int argIdx = 1;
     stmtDeleteByUNameIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtDeleteByUNameIdx.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
     stmtDeleteByUNameIdx.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
     stmtDeleteByUNameIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtDeleteByUNameIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     stmtDeleteByUNameIdx.setLong(argIdx++, argTenantId);
     stmtDeleteByUNameIdx.setString(argIdx++, argName);
     resultSet = stmtDeleteByUNameIdx.executeQuery();
     if (resultSet.next()) {
       boolean deleteFlag = resultSet.getBoolean(1);
       if (resultSet.next()) {
         throw CFLib.getDefaultExceptionFactory()
             .newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response");
       }
     } else {
       throw CFLib.getDefaultExceptionFactory()
           .newRuntimeException(
               getClass(),
               S_ProcName,
               "Expected 1 record result set to be returned by delete, not 0 rows");
     }
   } catch (SQLException e) {
     throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
   } finally {
     if (resultSet != null) {
       try {
         resultSet.close();
       } catch (SQLException e) {
       }
       resultSet = null;
     }
   }
 }
 public CFSecurityISOCountryCurrencyBuff lockBuff(
     CFSecurityAuthorization Authorization, CFSecurityISOCountryCurrencyPKey PKey) {
   final String S_ProcName = "lockBuff";
   if (!schema.isTransactionOpen()) {
     throw CFLib.getDefaultExceptionFactory()
         .newUsageException(getClass(), S_ProcName, "Transaction not open");
   }
   ResultSet resultSet = null;
   try {
     Connection cnx = schema.getCnx();
     short ISOCountryId = PKey.getRequiredISOCountryId();
     short ISOCurrencyId = PKey.getRequiredISOCurrencyId();
     final String sql =
         "CALL sp_lock_iso_cntryccy( ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?" + " )";
     if (stmtLockBuffByPKey == null) {
       stmtLockBuffByPKey = cnx.prepareStatement(sql);
     }
     int argIdx = 1;
     stmtLockBuffByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtLockBuffByPKey.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
     stmtLockBuffByPKey.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
     stmtLockBuffByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtLockBuffByPKey.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     stmtLockBuffByPKey.setShort(argIdx++, ISOCountryId);
     stmtLockBuffByPKey.setShort(argIdx++, ISOCurrencyId);
     resultSet = stmtLockBuffByPKey.executeQuery();
     if (resultSet.next()) {
       CFSecurityISOCountryCurrencyBuff buff = unpackISOCountryCurrencyResultSetToBuff(resultSet);
       if (resultSet.next()) {
         resultSet.last();
         throw CFLib.getDefaultExceptionFactory()
             .newRuntimeException(
                 getClass(),
                 S_ProcName,
                 "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
       }
       return (buff);
     } else {
       return (null);
     }
   } catch (SQLException e) {
     throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
   } finally {
     if (resultSet != null) {
       try {
         resultSet.close();
       } catch (SQLException e) {
       }
       resultSet = null;
     }
   }
 }
 public void deleteURLProtocolByIsSecureIdx(
     CFSecurityAuthorization Authorization, boolean argIsSecure) {
   final String S_ProcName = "deleteURLProtocolByIsSecureIdx";
   ResultSet resultSet = null;
   try {
     Connection cnx = schema.getCnx();
     final String sql =
         "CALL sp_delete_urlproto_by_issecureidx( ?, ?, ?, ?, ?" + ", " + "?" + " )";
     if (stmtDeleteByIsSecureIdx == null) {
       stmtDeleteByIsSecureIdx = cnx.prepareStatement(sql);
     }
     int argIdx = 1;
     stmtDeleteByIsSecureIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtDeleteByIsSecureIdx.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
     stmtDeleteByIsSecureIdx.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
     stmtDeleteByIsSecureIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtDeleteByIsSecureIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     if (argIsSecure) {
       stmtDeleteByIsSecureIdx.setString(argIdx++, "Y");
     } else {
       stmtDeleteByIsSecureIdx.setString(argIdx++, "N");
     }
     resultSet = stmtDeleteByIsSecureIdx.executeQuery();
     if (resultSet.next()) {
       int deleteFlag = resultSet.getInt(1);
       if (resultSet.next()) {
         resultSet.last();
         throw CFLib.getDefaultExceptionFactory()
             .newRuntimeException(
                 getClass(),
                 S_ProcName,
                 "Did not expect multi-record response, " + resultSet.getRow() + " rows selected");
       }
     } else {
       throw CFLib.getDefaultExceptionFactory()
           .newRuntimeException(
               getClass(),
               S_ProcName,
               "Expected 1 record result set to be returned by delete, not 0 rows");
     }
   } catch (SQLException e) {
     throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
   } finally {
     if (resultSet != null) {
       try {
         resultSet.close();
       } catch (SQLException e) {
       }
       resultSet = null;
     }
   }
 }
 public CFCrmMemoDataBuff[] readBuffByMemoDataCtcIdx(
     CFSecurityAuthorization Authorization, long TenantId, long ContactId) {
   final String S_ProcName = "readBuffByMemoDataCtcIdx";
   ResultSet resultSet = null;
   try {
     Connection cnx = schema.getCnx();
     String sql =
         "{ call sp_read_memodata_by_memodatactcidx( ?, ?, ?, ?, ?"
             + ", "
             + "?"
             + ", "
             + "?"
             + " ) }";
     if (stmtReadBuffByMemoDataCtcIdx == null) {
       stmtReadBuffByMemoDataCtcIdx = cnx.prepareStatement(sql);
     }
     int argIdx = 1;
     stmtReadBuffByMemoDataCtcIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtReadBuffByMemoDataCtcIdx.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
     stmtReadBuffByMemoDataCtcIdx.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
     stmtReadBuffByMemoDataCtcIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtReadBuffByMemoDataCtcIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     stmtReadBuffByMemoDataCtcIdx.setLong(argIdx++, TenantId);
     stmtReadBuffByMemoDataCtcIdx.setLong(argIdx++, ContactId);
     resultSet = stmtReadBuffByMemoDataCtcIdx.executeQuery();
     List<CFCrmMemoDataBuff> buffList = new LinkedList<CFCrmMemoDataBuff>();
     if (resultSet != null) {
       while (resultSet.next()) {
         CFCrmMemoDataBuff buff = unpackMemoDataResultSetToBuff(resultSet);
         buffList.add(buff);
       }
     }
     int idx = 0;
     CFCrmMemoDataBuff[] retBuff = new CFCrmMemoDataBuff[buffList.size()];
     Iterator<CFCrmMemoDataBuff> iter = buffList.iterator();
     while (iter.hasNext()) {
       retBuff[idx++] = iter.next();
     }
     return (retBuff);
   } catch (SQLException e) {
     throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
   } finally {
     if (resultSet != null) {
       try {
         resultSet.close();
       } catch (SQLException e) {
       }
       resultSet = null;
     }
   }
 }
 public void deleteISOTimezoneByOffsetIdx(
     CFSecurityAuthorization Authorization, short argTZHourOffset, short argTZMinOffset) {
   final String S_ProcName = "deleteISOTimezoneByOffsetIdx";
   if (!schema.isTransactionOpen()) {
     throw CFLib.getDefaultExceptionFactory()
         .newUsageException(getClass(), S_ProcName, "Transaction not open");
   }
   ResultSet resultSet = null;
   try {
     Connection cnx = schema.getCnx();
     String sql = "exec sp_delete_isotz_by_offsetidx ?, ?, ?, ?, ?" + ", " + "?" + ", " + "?";
     if (stmtDeleteByOffsetIdx == null) {
       stmtDeleteByOffsetIdx = cnx.prepareStatement(sql);
     }
     int argIdx = 1;
     stmtDeleteByOffsetIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtDeleteByOffsetIdx.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
     stmtDeleteByOffsetIdx.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
     stmtDeleteByOffsetIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtDeleteByOffsetIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     stmtDeleteByOffsetIdx.setShort(argIdx++, argTZHourOffset);
     stmtDeleteByOffsetIdx.setShort(argIdx++, argTZMinOffset);
     Object stuff = null;
     boolean moreResults = stmtDeleteByOffsetIdx.execute();
     while (stuff == null) {
       try {
         moreResults = stmtDeleteByOffsetIdx.getMoreResults();
       } catch (SQLException e) {
         throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
       }
       if (moreResults) {
         try {
           stuff = stmtDeleteByOffsetIdx.getResultSet();
         } catch (SQLException e) {
         }
       } else if (-1 == stmtDeleteByOffsetIdx.getUpdateCount()) {
         break;
       }
     }
   } catch (SQLException e) {
     throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
   } finally {
     if (resultSet != null) {
       try {
         resultSet.close();
       } catch (SQLException e) {
       }
       resultSet = null;
     }
   }
 }
Example #27
0
  public NeuralNetwork(int input, int hidden, int output) {
    this.layers = new int[] {input, hidden, output};
    df = new DecimalFormat("#0.000#");
    ef = new DecimalFormat("#");

    /** Create all neurons and connections Connections are created in the neuron class */
    for (int i = 0; i < layers.length; i++) {
      if (i == 0) { // input layer
        for (int j = 0; j < layers[i]; j++) {
          Neuron neuron = new Neuron();
          inputLayer.add(neuron);
        }
      } else if (i == 1) { // hidden layer
        for (int j = 0; j < layers[i]; j++) {
          Neuron neuron = new Neuron();
          neuron.addInConnectionsS(inputLayer);
          neuron.addBiasConnection(bias);
          hiddenLayer.add(neuron);
        }
      } else if (i == 2) { // output layer
        for (int j = 0; j < layers[i]; j++) {
          Neuron neuron = new Neuron();
          neuron.addInConnectionsS(hiddenLayer);
          neuron.addBiasConnection(bias);
          outputLayer.add(neuron);
        }
      } else {
        System.out.println("!Error NeuralNetwork init");
      }
    }

    // initialize random weights
    for (Neuron neuron : hiddenLayer) {
      ArrayList<Connection> connections = neuron.getAllInConnections();
      for (Connection conn : connections) {
        double newWeight = getRandom();
        conn.setWeight(newWeight);
      }
    }
    for (Neuron neuron : outputLayer) {
      ArrayList<Connection> connections = neuron.getAllInConnections();
      for (Connection conn : connections) {
        double newWeight = getRandom();
        conn.setWeight(newWeight);
      }
    }

    // reset id counters
    Neuron.counter = 0;
    Connection.counter = 0;

    if (isTrained) {
      trainedWeights();
      updateAllWeights();
    }
  }
 public CFSecurityISOTimezoneBuff[] readBuffByOffsetIdx(
     CFSecurityAuthorization Authorization, short TZHourOffset, short TZMinOffset) {
   final String S_ProcName = "readBuffByOffsetIdx";
   ResultSet resultSet = null;
   try {
     Connection cnx = schema.getCnx();
     String sql =
         "SELECT * FROM "
             + schema.getLowerDbSchemaName()
             + ".sp_read_isotz_by_offsetidx( ?, ?, ?, ?, ?"
             + ", "
             + "?"
             + ", "
             + "?"
             + " )";
     if (stmtReadBuffByOffsetIdx == null) {
       stmtReadBuffByOffsetIdx = cnx.prepareStatement(sql);
     }
     int argIdx = 1;
     stmtReadBuffByOffsetIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtReadBuffByOffsetIdx.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
     stmtReadBuffByOffsetIdx.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
     stmtReadBuffByOffsetIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtReadBuffByOffsetIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     stmtReadBuffByOffsetIdx.setShort(argIdx++, TZHourOffset);
     stmtReadBuffByOffsetIdx.setShort(argIdx++, TZMinOffset);
     resultSet = stmtReadBuffByOffsetIdx.executeQuery();
     List<CFSecurityISOTimezoneBuff> buffList = new LinkedList<CFSecurityISOTimezoneBuff>();
     while (resultSet.next()) {
       CFSecurityISOTimezoneBuff buff = unpackISOTimezoneResultSetToBuff(resultSet);
       buffList.add(buff);
     }
     int idx = 0;
     CFSecurityISOTimezoneBuff[] retBuff = new CFSecurityISOTimezoneBuff[buffList.size()];
     Iterator<CFSecurityISOTimezoneBuff> iter = buffList.iterator();
     while (iter.hasNext()) {
       retBuff[idx++] = iter.next();
     }
     return (retBuff);
   } catch (SQLException e) {
     throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
   } finally {
     if (resultSet != null) {
       try {
         resultSet.close();
       } catch (SQLException e) {
       }
       resultSet = null;
     }
   }
 }
  public votblOrganization getAllOrganizations(int iFKCompanyID, int iOrganisationID) {
    Vector v = new Vector();
    Connection con = null;
    Statement st = null;
    ResultSet rs = null;
    votblOrganization vo = new votblOrganization();

    String sql = "";
    if (iOrganisationID != 0) {
      sql = "SELECT * FROM tblConsultingCompany a, tblOrganization b";
      sql =
          sql
              + " WHERE a.CompanyID = b.FKCompanyID AND a.CompanyID = "
              + iFKCompanyID
              + " AND b.PKOrganization ="
              + iOrganisationID;
    } else {
      sql = "SELECT * FROM tblConsultingCompany WHERE CompanyID = " + iFKCompanyID;
    }

    try {

      con = ConnectionBean.getConnection();
      st = con.createStatement();
      rs = st.executeQuery(sql);

      if (rs.next()) {
        // 27 May 2008 by Hemilda - cause iOrganisationID == 0 the query only retrieve
        // tblConsultingCompany column
        if (iOrganisationID != 0) {
          vo.setEmailNom(rs.getString("EmailNom"));
          vo.setEmailNomRemind(rs.getString("EmailNomRemind"));
          vo.setEmailPart(rs.getString("EmailPart"));
          vo.setEmailPartRemind(rs.getString("EmailPartRemind"));
          vo.setExtraModule(rs.getInt("ExtraModule"));
          vo.setFKCompanyID(rs.getInt("FKCompanyID"));
          vo.setNameSequence(rs.getInt("NameSequence"));
          vo.setOrganizationCode(rs.getString("OrganizationCode"));
          vo.setOrganizationLogo(rs.getString("OrganizationLogo"));
          vo.setOrganizationName(rs.getString("OrganizationName"));
          vo.setPKOrganization(rs.getInt("PKOrganization"));
        }
        vo.setCompanyName(rs.getString("CompanyName"));
      }

    } catch (SQLException SE) {
      System.err.println("Organization.java - getAllOrganizations - " + SE.getMessage());
    } finally {

      ConnectionBean.closeRset(rs); // Close ResultSet
      ConnectionBean.closeStmt(st); // Close statement
      ConnectionBean.close(con); // Close connection
    }
    return vo;
  }
 public CFSecurityTSecGroupBuff readBuffByUNameIdx(
     CFSecurityAuthorization Authorization, long TenantId, String Name) {
   final String S_ProcName = "readBuffByUNameIdx";
   ResultSet resultSet = null;
   try {
     Connection cnx = schema.getCnx();
     String sql =
         "SELECT * FROM "
             + schema.getLowerDbSchemaName()
             + ".sp_read_tsecgrp_by_unameidx( ?, ?, ?, ?, ?"
             + ", "
             + "?"
             + ", "
             + "?"
             + " )";
     if (stmtReadBuffByUNameIdx == null) {
       stmtReadBuffByUNameIdx = cnx.prepareStatement(sql);
     }
     int argIdx = 1;
     stmtReadBuffByUNameIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtReadBuffByUNameIdx.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecUserId().toString());
     stmtReadBuffByUNameIdx.setString(
         argIdx++, (Authorization == null) ? "" : Authorization.getSecSessionId().toString());
     stmtReadBuffByUNameIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecClusterId());
     stmtReadBuffByUNameIdx.setLong(
         argIdx++, (Authorization == null) ? 0 : Authorization.getSecTenantId());
     stmtReadBuffByUNameIdx.setLong(argIdx++, TenantId);
     stmtReadBuffByUNameIdx.setString(argIdx++, Name);
     resultSet = stmtReadBuffByUNameIdx.executeQuery();
     if (resultSet.next()) {
       CFSecurityTSecGroupBuff buff = unpackTSecGroupResultSetToBuff(resultSet);
       if (resultSet.next()) {
         throw CFLib.getDefaultExceptionFactory()
             .newRuntimeException(getClass(), S_ProcName, "Did not expect multi-record response");
       }
       return (buff);
     } else {
       return (null);
     }
   } catch (SQLException e) {
     throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e);
   } finally {
     if (resultSet != null) {
       try {
         resultSet.close();
       } catch (SQLException e) {
       }
       resultSet = null;
     }
   }
 }