Package com.knowgate.jdc

Examples of com.knowgate.jdc.JDCConnection


    if (!sSite.equals("linkedin") && !sSite.equals("facebook") && !sSite.equals("twitter") && !sSite.equals("xing")) {
      throw new IllegalArgumentException("Crawled sites may be only linkedin, facebook, twitter or xing");
    }

    int nFound = 0;
  JDCConnection oCon = null;
    String sYahooBossKey = oDbb.getProperty("yahoobosskey","");

  if (sYahooBossKey.length()==0){
      throw new IllegalArgumentException("Could not find yahoobosskey property at "+oDbb.getProfileName()+".cnf");
  }   

    if (DebugFile.trace) {
      DebugFile.writeln("Begin SocialNetworks.crawl("+sWorkArea+","+sWhere+","+sSite+")");
      DebugFile.incIdent();
    }
   
    try {
   
    Boss oBss = new Boss();
    oCon = oDbb.getConnection("SocialNetworksCrawler");
    oCon.setAutoCommit(true);
    DBSubset oDbs = new DBSubset(DB.k_contacts, DB.gu_contact+","+DB.tx_name+","+DB.tx_surname,
                   DB.gu_workarea+"=? AND "+DB.tx_name+" IS NOT NULL AND "+
                   DB.tx_surname+" IS NOT NULL "+
                  (sWhere==null ? "" : " AND "+sWhere), iLimit);
    oDbs.setMaxRows(iLimit);
    final int nContacts = oDbs.load(oCon, new Object[]{sWorkArea});
    if (DebugFile.trace) DebugFile.writeln("Crawling "+String.valueOf(nContacts)+" contacts");
    for (int c=0; c<nContacts; c++) {
      String sFullName = oDbs.getStringNull(1,c,"")+" "+oDbs.getStringNull(2,c,"");
      String sASCIIName = Gadgets.ASCIIEncode(sFullName);
     
      if (DebugFile.trace) DebugFile.writeln("Searching "+sFullName+"...");
      YSearchResponse oYsr = oBss.search(sYahooBossKey,
                                         Gadgets.ASCIIEncode(oDbs.getStringNull(1,c,""))+" "+
                                         Gadgets.ASCIIEncode(oDbs.getStringNull(2,c,"")),
                                         sSite+".com");
      if (oYsr.count()>0) {
        if (DebugFile.trace) DebugFile.writeln("Found "+oYsr.results(0).title);
        if (Gadgets.ASCIIEncode(oYsr.results(0).title).startsWith(sASCIIName)) {
          nFound++;
          DBCommand.executeUpdate(oCon, "UPDATE "+DB.k_contacts+" SET url_"+sSite+"='"+oYsr.results(0).url+"' WHERE "+DB.gu_contact+"='"+oDbs.getString(0,c)+"'");
        } // fi
      } else {
        if (DebugFile.trace) DebugFile.writeln("No results found for "+sFullName);
      }
    } // next
    oCon.close("SocialNetworksCrawler");

    } catch (Exception oXct) {
      if (null!=oCon) {
        try { if (!oCon.isClosed()) oCon.close(); } catch (SQLException ignore) {}
      }
    }
   
    if (DebugFile.trace) {
      DebugFile.decIdent();
View Full Code Here


      sColunm = DB.bo_seen;
    else
      sColunm = null;

    if (null!=sColunm && oFolder instanceof DBFolder) {
      JDCConnection oConn = null;
      PreparedStatement oUpdt = null;
      try {
        if (getMessageGuid()!=null) {
          oConn = ((DBFolder)oFolder).getConnection();
          String sSQL = "UPDATE " + DB.k_mime_msgs + " SET " + sColunm + "=" + (bFlg ? "1" : "0") + " WHERE " + DB.gu_mimemsg + "=?";
          if (DebugFile.trace) DebugFile.writeln("Connection.prepareStatement("+sSQL+")");
          oUpdt = oConn.prepareStatement(sSQL);
          oUpdt.setString(1, getMessageGuid());
          oUpdt.executeUpdate();
          oUpdt.close();
          oUpdt=null;
          oConn.commit();
          oConn=null;
        }
      }
      catch (SQLException e) {
        if (null!=oConn) { try { oConn.rollback(); } catch (Exception ignore) {} }
        if (null!=oUpdt) { try { oUpdt.close(); } catch (Exception ignore) {} }
        if (DebugFile.trace) DebugFile.decIdent();
        throw new MessagingException(e.getMessage(), e);
      }
    }
View Full Code Here

    }

    Flags oFlgs = getFlags();

    if (oFolder instanceof DBFolder) {
      JDCConnection oConn = null;
      try {
        oConn.commit();
        oConn=null;
      }
      catch (SQLException e) {
        if (null!=oConn) { try { oConn.rollback(); } catch (Exception ignore) {} }
        if (DebugFile.trace) DebugFile.decIdent();
        throw new MessagingException(e.getMessage(), e);
      }
    }
    else {
View Full Code Here

      try {
        if (DebugFile.trace) {
          DebugFile.writeln("Connection.prepareStatement(SELECT id_part,id_content,id_disposition,len_part,de_part,tx_md5,id_encoding,file_name,id_type FROM "+ DB.k_mime_parts + " WHERE " + DB.gu_mimemsg + "='"+sGuid+"')");
        }

    JDCConnection oJdcc = ((DBFolder)oFolder).getConnection();
        oStmt = oJdcc.prepareStatement("SELECT id_part,id_content,id_disposition,len_part,de_part,tx_md5,id_encoding,file_name,id_type FROM " + DB.k_mime_parts + " WHERE " + DB.gu_mimemsg + "=?",
                                        ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
        oStmt.setString(1, sGuid);

        oRSet = oStmt.executeQuery();
View Full Code Here

    o.setDocument(d);
    o.delete(oSes, oDms);
  }

  public static int deleteVersion(long lDocId, int iVersion) throws DmsException {
    JDCConnection oCon = null;
    int nDeletedAttributes = 0;
    try {
      oCon = DAO.getConnection("BaseModelObject.deleteVersion");
      oCon.setAutoCommit(false);
      PreparedStatement oStm = oCon.prepareStatement("DELETE FROM ValorCadenaTraza where fkIdDoc=? AND Version=?");
      oStm.setLong(1, lDocId);
      oStm.setInt(2, iVersion);
      nDeletedAttributes = oStm.executeUpdate();
      oStm.close();
      oStm = oCon.prepareStatement("DELETE FROM ValorEnteroTraza where fkIdDoc=? AND Version=?");
      oStm.setLong(1, lDocId);
      oStm.setInt(2, iVersion);
      nDeletedAttributes += oStm.executeUpdate();
      oStm.close();
      oCon.commit();
      oCon.close("BaseModelObject.deleteVersion");
    } catch (SQLException sqle) {
      if (oCon!=null) {
        try {
          if (!oCon.isClosed()) oCon.close();
        } catch (SQLException e) { }
      }
      throw new DmsException(sqle.getMessage(), sqle);
    }
    return nDeletedAttributes;
View Full Code Here

public class Cache {

  public Cache() { }

  public static void clear() throws SQLException {
    JDCConnection oCon = DAO.getConnection("Cache");
    Statement oStm = oCon.createStatement();
    oStm.execute("TRUNCATE TABLE Cache");
    oCon.close("Cache");
  }
View Full Code Here

  }

  public static CacheEntry getEntry(String sKey)
    throws SQLException, ClassNotFoundException, IOException {
    CacheEntry oRetVal;
    JDCConnection oCon = DAO.getConnection("Cache");
    oRetVal = new CacheEntry(oCon, sKey);
    if (!oRetVal.found()) oRetVal = null;
    oCon.close("Cache");
    return oRetVal;
  }
View Full Code Here

  }

  public static void putEntry(String sKey, Object oVal)
    throws SQLException, IOException  {
    CacheEntry oEntry = new CacheEntry();
    JDCConnection oCon = DAO.getConnection("Cache");
    oCon.setAutoCommit(true);
    oEntry.setKey(sKey);
    oEntry.setValue(oVal);
    oEntry.store(oCon);
    oCon.close("Cache");
  }
View Full Code Here

    oCon.close("Cache");
  }
 
  public static void deleteEntry(String sKey) throws SQLException {
    CacheEntry oEntry = new CacheEntry();
    JDCConnection oCon = DAO.getConnection("Cache");
    oCon.setAutoCommit(true);
    oEntry.setKey(sKey);
    oEntry.delete(oCon);
    oCon.close("Cache");
  }
View Full Code Here

      aStatements = split(oBuffer, ';', null);
    }

    iStatements = aStatements.length;

    JDCConnection oConn = DAO.getConnection(getClass().getName()+".executeSQLBulk");
   
      switch (iBatchType) {
        case BULK_PROCEDURES:
          for (int s = 0; s < iStatements; s++) {
            sSQL = aStatements[s];
            if (sSQL.length() > 0) {
              if (null!=oStrLog) oStrLog.append(sSQL + "\n");
              try {
                oCall = oConn.prepareCall(sSQL);
                oCall.execute();
                oCall.close();
                oCall = null;
              }
              catch (SQLException sqle) {
                iErrors++;
                if (null!=oStrLog) oStrLog.append("SQLException: " + sqle.getMessage() + "\n");
                try { if (null!=oCall) oCall.close(); } catch (SQLException ignore) { }
                if (bStopOnError) throw new java.lang.InterruptedException();
              }
            } // fi (sSQL)
          } // next
          break;

        case BULK_STATEMENTS:
        case FILE_STATEMENTS:
        case BULK_BATCH:

          oStmt = oConn.createStatement();
          for (int s = 0; s < iStatements; s++) {

            try {
              sSQL = aStatements[s];
            }
            catch (NullPointerException npe) {
              if (null!=oStrLog) oStrLog.append (" NullPointerException: at " + sResourcePath + " statement " + String.valueOf(s) + "\n");
              sSQL = "";
            }

            if (sSQL.length() > 0) {
              if (null!=oStrLog) oStrLog.append(sSQL + "\n\\\n");
              try {
              if (!sSQL.startsWith("--")) {
                  oStmt.executeUpdate(sSQL);
                }
              }
              catch (SQLException sqle) {
                iErrors++;
                if (null!=oStrLog) oStrLog.append ("SQLException: " + sqle.getMessage() + "\n");

                if (bStopOnError) {
                  try { if (null!=oStmt) oStmt.close(); } catch (SQLException ignore) { }
                  throw new java.lang.InterruptedException();
                }
              }
            } // fi (sSQL)
          } // next
          oStmt.close();
          oStmt = null;
          break;

        case BULK_PLSQL:
          oStmt = oConn.createStatement();
          for (int s = 0; s < iStatements; s++) {
            sSQL = aStatements[s];
            if (sSQL.length() > 0) {
              if (null!=oStrLog) oStrLog.append(sSQL + "\n\\\n");
              try {
                oStmt.execute(sSQL);
              }
              catch (SQLException sqle) {
                iErrors++;
                if (null!=oStrLog) oStrLog.append("SQLException: " + sqle.getMessage() + "\n");

                if (bStopOnError) {
                  try { if (null!=oStmt) oStmt.close(); } catch (SQLException ignore) { }
                  throw new java.lang.InterruptedException();
                }
              }
            } // fi (sSQL)
          } // next
          oStmt.close();
          oStmt = null;
          break;
      } // end switch()

    if (!oConn.getAutoCommit()) oConn.commit();
    oConn.close(getClass().getName()+".executeSQLBulk");
     
    return iErrors;
  } // executeBulk
View Full Code Here

TOP

Related Classes of com.knowgate.jdc.JDCConnection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.