Package com.knowgate.dataobjs

Examples of com.knowgate.dataobjs.DBBind$Functions


   * @throws SQLException, ClassNotFoundException
   * @since 5.0
   */
  public void abortJob(String sGuJob)
    throws SQLException, ClassNotFoundException, IllegalAccessException, InstantiationException, FileNotFoundException {
    DBBind oDb2;

  if (DebugFile.trace) {
    DebugFile.writeln("Begin SchedulerDaemon.abortJob("+sGuJob+")");
    DebugFile.incIdent();
  }
 
    if (null==oDbb)
      oDb2 = new DBBind(sProfile);
    else
      oDb2 = oDbb;
     
    JDCConnection oCon = oDb2.getConnection("SchedulerDaemon.abortJob");
  oCon.setAutoCommit(true);

  atomQueue().remove(sGuJob);

  Job.instantiate(oCon, sGuJob, oEnvProps).abort(oCon);

  oCon.close("SchedulerDaemon.abortJob");

  if (oDb2!=oDbb) oDb2.close();

  if (DebugFile.trace) {
    DebugFile.decIdent();
    DebugFile.writeln("End SchedulerDaemon.abortJob()");
  }
View Full Code Here


  }

  public static void main(String[] argv)
    throws ClassNotFoundException, SQLException, IOException {

    DBBind oGlobalDBBind = new DBBind();
    SchedulerDaemon TheDaemon;

    if (argv.length<1 || argv.length>2)
      printUsage();
View Full Code Here

  // ---------------------------------------------------------------------------

  public void doPost(HttpServletRequest request, HttpServletResponse response)
     throws IOException, ServletException {

     DBBind oBnd = null;
     JDCConnection oCon = null;

     short iAuth;
     boolean bAllowed;
     String sDbb = request.getParameter("profile");
     String sUsr = request.getParameter("user");
     String sPwd = request.getParameter("password");
     String sCmd = request.getParameter("command");
     String sCls = request.getParameter("class");
     String sTbl = request.getParameter("table");
     String sFld = request.getParameter("fields");
     String sWhr = request.getParameter("where");
     String sMax = request.getParameter("maxrows");
     String sSkp = request.getParameter("skip");
     String sCol = request.getParameter("coldelim");
     String sRow = request.getParameter("rowdelim");

     if (DebugFile.trace) {
       DebugFile.writeln("Begin HttpDataObjsServlet.doPost()");
       DebugFile.incIdent();
     }

     if (null==sDbb) {
       sDbb = "hipergate";
     }
     if (null==sUsr) {
       if (DebugFile.trace) DebugFile.decIdent();
       response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Parameter user is requiered");
       return;
     }
     if (null==sPwd) {
       if (DebugFile.trace) DebugFile.decIdent();
       response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Parameter password is requiered");
       return;
     }
     if (null==sCmd) {
       if (DebugFile.trace) DebugFile.decIdent();
       response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Parameter command is requiered");
       return;
     } else if (sCmd.equalsIgnoreCase("query")) {
       if (null==sFld) {
         if (DebugFile.trace) DebugFile.decIdent();
         response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Parameter fields is requiered");
         return;
       } else if (hasSqlSignature(sFld)) {
         if (DebugFile.trace) DebugFile.decIdent();
         response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Parameter fields has an invalid syntax");
         return;
       }
     }
     if (null==sTbl) {
       if (DebugFile.trace) DebugFile.decIdent();
       response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Parameter table is requiered");
       return;
     } else if (hasSqlSignature(sTbl)) {
       if (DebugFile.trace) DebugFile.decIdent();
       response.sendError(HttpServletResponse.SC_BAD_REQUEST, "Parameter table has an invalid syntax");
       return;
     }

     Properties oEnv = Environment.getProfile(sDbb);

     if (null==oEnv) {
       if (DebugFile.trace) DebugFile.decIdent();
       response.sendError(HttpServletResponse.SC_SERVICE_UNAVAILABLE, "Databind " + sDbb + " is not available");
       return;
     }

     if (!sCmd.equalsIgnoreCase("ping") && !sCmd.equalsIgnoreCase("query") && !sCmd.equalsIgnoreCase("update") && !sCmd.equalsIgnoreCase("nextval")) {
       if (DebugFile.trace) DebugFile.decIdent();
       response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "Command " + sCmd + " not recognized");
       return;
     }

     if (sCmd.equalsIgnoreCase("ping")) {
       response.setContentType("text/plain");
       response.getOutputStream().print("HttpDataObjsServlet ping OK");
       if (DebugFile.trace) {
         DebugFile.decIdent();
         DebugFile.writeln("End HttpDataObjsServlet.doPost()");
       }
       return;
     }

     if (oBindings.containsKey(sDbb)) {
       oBnd = (DBBind) oBindings.get(sDbb);
     } else {
       oBnd = new DBBind(sDbb);
       oBindings.put(sDbb, oBnd);
     }

     if (sCmd.equalsIgnoreCase("query")) {
       int iMax;
       if (null==sMax)
         iMax = 500;
       else
         iMax = Integer.parseInt(sMax);
       int iSkp;
       if (null==sSkp)
         iSkp = 0;
       else
         iSkp = Integer.parseInt(sSkp);
       DBSubset oDbs = new DBSubset (sTbl, sFld, sWhr, iMax);
       if (null!=sRow) oDbs.setRowDelimiter(sRow);
       if (null!=sCol) oDbs.setColumnDelimiter(sCol);
       oDbs.setMaxRows(iMax);
       try {
         oCon = oBnd.getConnection("HttpDataObjsServlet");
         if (null==oCon) {
           if (DebugFile.trace) DebugFile.decIdent();
           throw new ServletException("ERROR Unable to get database connection from pool "+sDbb);
         }
         if (oBnd.exists(oCon, DB.k_users, "U")) {
           if (Gadgets.checkEMail(sUsr)) {
             sUsr = ACLUser.getIdFromEmail(oCon, sUsr);
             if (null==sUsr)
               iAuth = ACL.USER_NOT_FOUND;
             else
               iAuth = ACL.autenticate(oCon, sUsr, sPwd, ACL.PWD_CLEAR_TEXT);
           } else {
             iAuth = ACL.autenticate(oCon, sUsr, sPwd, ACL.PWD_CLEAR_TEXT);
           }
         } else {
           iAuth = 0;
         } // fi (exists k_users)
         if (iAuth<0) {
           response.sendError(HttpServletResponse.SC_FORBIDDEN, ACL.getErrorMessage(iAuth));
         } else {
           oDbs.load(oCon, iSkp);
           response.setContentType("text/plain");
           response.setCharacterEncoding("UTF-8");
           response.getOutputStream().write(oDbs.toString().getBytes("UTF-8"));             
         }
         oCon.close("HttpDataObjsServlet");
         oCon = null;
       } catch (SQLException sqle) {
         if (null!=oCon) {
           try { oCon.close("HttpDataObjsServlet"); } catch (Exception ignore) {}
           oCon = null;
         }
         if (DebugFile.trace) DebugFile.decIdent();
         throw new ServletException("SQLException "+sqle.getMessage());
       }
     }
     else if (sCmd.equalsIgnoreCase("update")) {
       if (DebugFile.trace) DebugFile.writeln("command is update");
       Enumeration oParamNames = request.getParameterNames();
       DBPersist oDbp;
       Class oCls;

       if (null==sCls) {
         oDbp = new DBPersist(sTbl, "DBPersist");
         try {
           oCls = Class.forName("com.knowgate.dataobjs.DBPersist");
         } catch (ClassNotFoundException neverthrown) { oCls=null; }

       } else {
         try {
           oCls = Class.forName(sCls);
           oDbp = (DBPersist) oCls.newInstance();
         } catch (ClassNotFoundException nfe) {
           if (DebugFile.trace) DebugFile.decIdent();
           throw new ServletException("ClassNotFoundException "+nfe.getMessage()+" "+sCls);
         } catch (InstantiationException ine) {
           if (DebugFile.trace) DebugFile.decIdent();
           throw new ServletException("InstantiationException "+ine.getMessage()+" "+sCls);
         } catch (IllegalAccessException iae) {
           if (DebugFile.trace) DebugFile.decIdent();
           throw new ServletException("IllegalAccessException "+iae.getMessage()+" "+sCls);
         } catch (ClassCastException cce) {
           if (DebugFile.trace) DebugFile.decIdent();
           throw new ServletException("ClassCastException "+cce.getMessage()+" "+sCls);
         }

         if (sCls.equals("com.knowgate.hipergate.InvoicePayment") &&
            request.getParameter("gu_invoice")!=null & request.getParameter("pg_payment")!=null) {
           if (request.getParameter("gu_invoice").length()>0 &&
               request.getParameter("pg_payment").length()>0) {
             try {
               oCon = oBnd.getConnection("HttpDataObjsServlet.InvoicePayment", true);
               oDbp.load(oCon, new Object[]{request.getParameter("gu_invoice"), new Integer(request.getParameter("pg_payment"))});
               oCon.close("HttpDataObjsServlet.InvoicePayment");
               oCon=null;
             } catch (Exception xcpt) {
               if (DebugFile.trace) {
                  DebugFile.writeln(xcpt.getClass().getName()+" "+xcpt.getMessage());
                 DebugFile.decIdent();
               }
               throw new ServletException(xcpt.getClass().getName()+" "+xcpt.getMessage(), xcpt);
             }
             finally {
               if (oCon!=null) { try { if (!oCon.isClosed()) { oCon.close("HttpDataObjsServlet.InvoicePayment"); } } catch (Exception ignore) { } }
             } // finally
           } // fi (gu_invoice && pg_payment)
         } // fi (sCls==InvoicePayment)
       } // fi

       if (DebugFile.trace) DebugFile.writeln("class "+oDbp.getClass().getName()+" instantiated");

       while (oParamNames.hasMoreElements()) {
         String sKey = (String) oParamNames.nextElement();
         if (DebugFile.trace) DebugFile.writeln("reading parameter "+sKey);
         sKey = sKey.trim();
         int iSpc = sKey.indexOf(' ');
         if (iSpc>0) {
           String sKeyName = sKey.substring(0, iSpc);
           iSpc++;
           if (iSpc<sKey.length()-1) {
             String sSQLType = sKey.substring(iSpc);
             if (DebugFile.trace) DebugFile.writeln("sqltype is "+sSQLType);
             if (sSQLType.toUpperCase().startsWith("DATE") || sSQLType.toUpperCase().startsWith("DATETIME") || sSQLType.toUpperCase().startsWith("TIMESTAMP")) {
               iSpc = sSQLType.indexOf(' ');
               String sDtFmt = "";
               try {
                 if (iSpc > 0) {
                   sDtFmt = sSQLType.substring(++iSpc);
                   if (DebugFile.trace) DebugFile.writeln("date format is "+sDtFmt);
                   oDbp.replace(sKeyName, request.getParameter(sKey), new SimpleDateFormat(sDtFmt));
                 } else {
                   oDbp.replace(sKeyName, request.getParameter(sKey), DBColumn.getSQLType(sSQLType));
                 }
               } catch (ParseException pe) {
                 if (DebugFile.trace) DebugFile.decIdent();
                 throw new ServletException("ERROR ParseException "+sKey+"|"+sDtFmt+"|"+request.getParameter(sKey)+" "+pe.getMessage());
               } catch (IllegalArgumentException ia) {
                 if (DebugFile.trace) DebugFile.decIdent();
                 throw new ServletException("ERROR IllegalArgumentException "+sKey+"|"+sDtFmt+"|"+request.getParameter(sKey)+ia.getMessage());
               }
             } else {
               try {
                 oDbp.replace(sKeyName, request.getParameter(sKey), DBColumn.getSQLType(sSQLType));
               } catch (NumberFormatException nfe) {
                 if (DebugFile.trace) DebugFile.decIdent();
                 throw new ServletException("ERROR NumberFormatException "+sKey+" "+" "+request.getParameter(sKey)+" "+nfe.getMessage());
               }
             }
           } else {
             oDbp.replace(sKeyName, request.getParameter(sKey));
           }
         } else {
           oDbp.replace(sKey, request.getParameter(sKey));
         }
       } // wend
       try {
         oCon = oBnd.getConnection("HttpDataObjsServlet");
         if (null==oCon) {
           if (DebugFile.trace) DebugFile.decIdent();
           throw new ServletException("ERROR Unable to get database connection from pool "+sDbb);
         }
         if (oBnd.exists(oCon, DB.k_users, "U")) {
           if (Gadgets.checkEMail(sUsr)) {
             sUsr = ACLUser.getIdFromEmail(oCon, sUsr);
             if (null==sUsr)
               iAuth = ACL.USER_NOT_FOUND;
             else
               iAuth = ACL.autenticate(oCon, sUsr, sPwd, ACL.PWD_CLEAR_TEXT);
           } else {
               iAuth = ACL.autenticate(oCon, sUsr, sPwd, ACL.PWD_CLEAR_TEXT);
           } // fi (checkEMail(sUsr))
         } else {
           iAuth = 0;
         } // fi (exists(DBk_users))
         if (iAuth<0) {
           response.sendError(HttpServletResponse.SC_FORBIDDEN, ACL.getErrorMessage(iAuth));
         } else {
           if (oDbp.isNull(DB.gu_workarea))
             bAllowed = true;
           else
             bAllowed = isUserAllowed(oCon, sUsr, oDbp.getString(DB.gu_workarea));
           if (bAllowed) {
               oCon.setAutoCommit(true);
               if (null==sCls) {
                 oDbp.store(oCon);
               } else {
                 if (DebugFile.trace) DebugFile.writeln(oCls.getName()+".getMethod(\"store\", new Class[]{Class.forName(\"com.knowgate.jdc.JDCConnection\")}).invoke(...)");
                 oCls.getMethod("store", new Class[]{Class.forName("com.knowgate.jdc.JDCConnection")}).invoke(oDbp, new Object[]{oCon});
               } // fi (sCls)
               response.setContentType("text/plain");
               response.setCharacterEncoding("UTF-8");
               response.getOutputStream().print("SUCCESS");
           } else {
               response.sendError(HttpServletResponse.SC_FORBIDDEN, "User does not have write permissions on target WorkArea");
           } // fi (bAllowed)
         }
         oCon.close("HttpDataObjsServlet");
         oCon = null;
       } catch (InvocationTargetException ite) {
         if (null!=oCon) {
           try { oCon.close("HttpDataObjsServlet"); oCon = null;
           } catch (Exception ignore) {}
         } // fi
         if (DebugFile.trace) DebugFile.decIdent();
         throw new ServletException(ite.getCause().getClass().getName()+" "+ite.getCause().getMessage()+"\n"+StackTraceUtil.getStackTrace(ite));
       } catch (Exception xcpt) {
         if (null!=oCon) {
           try { oCon.close("HttpDataObjsServlet"); oCon = null;
           } catch (Exception ignore) {}
         } // fi
         if (DebugFile.trace) DebugFile.decIdent();
         throw new ServletException(xcpt.getClass().getName()+" "+xcpt.getMessage()+"\n"+StackTraceUtil.getStackTrace(xcpt));
       }
     }
     else if (sCmd.equalsIgnoreCase("nextval")) {

       try {
         oCon = oBnd.getConnection("HttpDataObjsServlet");
         if (null==oCon) {
           if (DebugFile.trace) DebugFile.decIdent();
           throw new ServletException("ERROR Unable to get database connection from pool "+sDbb);
         }
         if (oBnd.exists(oCon, DB.k_users, "U")) {
           if (Gadgets.checkEMail(sUsr)) {
             sUsr = ACLUser.getIdFromEmail(oCon, sUsr);
             if (null==sUsr)
               iAuth = ACL.USER_NOT_FOUND;
             else
               iAuth = ACL.autenticate(oCon, sUsr, sPwd, ACL.PWD_CLEAR_TEXT);
           } else {
             iAuth = ACL.autenticate(oCon, sUsr, sPwd, ACL.PWD_CLEAR_TEXT);
           }
         } else {
           iAuth = 0;
         } // fi (exists k_users)
         switch (iAuth) {
             case ACL.ACCOUNT_CANCELLED:
               response.sendError(HttpServletResponse.SC_FORBIDDEN, "Account cancelled");
               break;
             case ACL.ACCOUNT_DEACTIVATED:
               response.sendError(HttpServletResponse.SC_FORBIDDEN, "Account deactivated");
               break;
             case ACL.INVALID_PASSWORD:
               response.sendError(HttpServletResponse.SC_FORBIDDEN, "Invalid password");
               break;
             case ACL.PASSWORD_EXPIRED:
               response.sendError(HttpServletResponse.SC_FORBIDDEN, "Password expired");
               break;
             case ACL.USER_NOT_FOUND:
               response.sendError(HttpServletResponse.SC_FORBIDDEN, "User not found");
               break;
             default:
               String sNextVal = String.valueOf(oBnd.nextVal(oCon, sTbl));
               response.setContentType("text/plain");
               response.setCharacterEncoding("ISO-8859-1");
               response.getOutputStream().write(sNextVal.getBytes("ISO8859_1"));
         } // end switch
         oCon.close("HttpDataObjsServlet");
View Full Code Here

   * @throws ServletException
   */
  public void doGet(HttpServletRequest request, HttpServletResponse response)
     throws ServletException {

   DBBind oDbj;
   boolean bError = false;
  
   String sAction = request.getParameter("action");
   if (null==sAction) sAction = "";

   String sId = request.getParameter("id");

    if (DebugFile.trace) {
      DebugFile.writeln("Begin HttpSchedulerServlet.doGet("+sAction+")");
      DebugFile.incIdent();
    }

    if ((null!=oDaemon) && sAction.equals("restart")) {
      try {
        oDaemon.stopAll();
        oDaemon = null;
      } catch (Exception xcpt) {
        writeXML(response, "<scheduler><error><![CDATA["+xcpt.getClass().getName()+" "+xcpt.getMessage()+"]]></error></scheduler>");
      }
      if (null!=oDaemon) {
        if (DebugFile.trace) {
          DebugFile.writeln("HttpSchedulerServlet.doGet("+sAction+") : No scheduler instance found. Re-start failed");
          DebugFile.decIdent();
        }
        return;
      }
    } // fi (restart)

    String sStatus = "", sSize = "", sLive = "", sQueue = "", sStartDate = "", sStopDate = "", sRunning = "";

    if (sAction.equals("start") || sAction.equals("restart")) {
      if (null==oDaemon) {
        try {
          oDaemon = new SchedulerDaemon(sProfile);
          if (DebugFile.trace) {
            DebugFile.writeln("SchedulerDaemon.start()");
          }
          oDaemon.start();
          sStatus = "start";
        }
        catch (Exception xcpt) {
          if (DebugFile.trace) {
            DebugFile.writeln("HttpSchedulerServlet.doGet("+sAction+") : "+xcpt.getClass().getName()+" "+xcpt.getMessage());
          }
          if (oDaemon!=null) {
            try { oDaemon.stopAll(); }
            catch (Exception ignore) {
              DebugFile.writeln("HttpSchedulerServlet.doGet("+sAction+") : " + ignore.getClass().getName() + " " + ignore.getMessage());
            }
            oDaemon=null;
          }
          bError = true;
          writeXML(response, "<scheduler><error><![CDATA["+xcpt.getClass().getName()+" "+xcpt.getMessage()+"]]></error></scheduler>");
        } // catch
        if (sStatus.length()==0) {
          if (DebugFile.trace) {
            DebugFile.writeln("Scheduler status is unknown");
            DebugFile.decIdent();
          }
          return;
        }
      }
      else {
        sStatus = "running";
      }
    }
    else if (sAction.equals("stop")) {
      if (null!=oDaemon) {
        try {
          oDaemon.stopAll();
          if (null!=oDaemon.stopDate()) sStopDate = oDaemon.stopDate().toString();
          oDaemon=null;
          sStatus = "stop";
        } catch (Exception xcpt) {
            bError = true;
            DebugFile.writeln("HttpSchedulerServlet.doGet(stop) : "+xcpt.getClass().getName()+" " + xcpt.getMessage());
            try { DebugFile.writeln(StackTraceUtil.getStackTrace(xcpt)); } catch (Exception ignore) {}
            writeXML(response, "<scheduler><error><![CDATA["+xcpt.getMessage()+"]]></error></scheduler>");
        }
        if (null!=oDaemon) {
          if (oDaemon.isAlive()) { try { oDaemon.stop(); } catch (Exception ignore) {} }
          oDaemon=null;
        }
        if (sStatus.length()==0) {
          if (DebugFile.trace) {
            DebugFile.writeln("Scheduler status is unknown");
            DebugFile.decIdent();
          }
          return;
        }
      }
      else {
        sStatus = "stopped";
      }
    }
    else if (sAction.equals("info")) {
      if (null==oDaemon) {
        sStatus = "stopped";
      } else {
        if (oDaemon.isAlive())
          sStatus = "running";
        else
          sStatus = "death";
        if (null!=oDaemon.threadPool()) {
          sSize = String.valueOf(oDaemon.threadPool().size());
          sLive = String.valueOf(oDaemon.threadPool().livethreads());
        }
        if (null!=oDaemon.atomQueue())
          sQueue = String.valueOf(oDaemon.atomQueue().size());
      }
    }
    else if (sAction.equals("abort")) {
      if (DebugFile.trace) DebugFile.writeln("aborting job "+sId);
      if (null!=sId) {
        if (null!=oDaemon) {
          try {
            oDaemon.abortJob(sId);
          } catch (Exception xcpt) {
              bError = true;
              DebugFile.writeln("HttpSchedulerServlet.doGet(abort) : " + xcpt.getClass().getName() + " " + xcpt.getMessage());
              writeXML(response, "<scheduler><error><![CDATA["+xcpt.getClass().getName()+" "+xcpt.getMessage()+"]]></error></scheduler>");
          }
        } else {
          oDbj = new DBBind(Gadgets.substrUpTo(sProfile.substring(sProfile.lastIndexOf(File.separator)+1),0,'.'));
      JDCConnection oCon = null;
      try {
        oCon = oDbj.getConnection("SchedulerDaemon");
            Job.instantiate(oCon, sId, oDbj.getProperties()).abort(oCon);
            oCon.close("SchedulerDaemon");
            oCon=null;
      } catch (Exception xcpt) {
              DebugFile.writeln("HttpSchedulerServlet.doGet(abort) : " + xcpt.getClass().getName() + " " + xcpt.getMessage());
              writeXML(response, "<scheduler><error><![CDATA["+xcpt.getClass().getName()+" "+xcpt.getMessage()+"]]></error></scheduler>");
      } finally {
        try {
              if (null!=oCon) if (!oCon.isClosed()) oCon.close("SchedulerDaemon");
              oDbj.close();
        } catch (SQLException ignore) { }
      }                   
        } // fi
      } // fi
    }
View Full Code Here

        bDeleteFiles = true;

      try {
        File[] aDirs = oBase.listFiles();
        if (aDirs!=null) {
          DBBind oDbbd = new DBBind(argv[0]);
          Contact oCont = new Contact();
          JDCConnection oConn = oDbbd.getConnection("AttachmentUploader");
          PreparedStatement oStmt = oConn.prepareStatement("SELECT "+DB.gu_contact+","+DB.gu_workarea+" FROM "+DB.k_contacts+" WHERE "+DB.gu_contact+"=? OR "+DB.id_ref+"=? OR "+DB.sn_passport+"=?",
                                                           ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
          oConn.setAutoCommit(false);
          int nDirs = aDirs.length;
          for (int d=0; d<nDirs; d++) {
            if (aDirs[d].isDirectory()) {
              String sDirName = aDirs[d].getName();
              oStmt.setString(1, sDirName);
              oStmt.setString(2, sDirName);
              oStmt.setString(3, sDirName);
              ResultSet oRSet = oStmt.executeQuery();
              if (oRSet.next()) {
                oCont.replace(DB.gu_contact , oRSet.getString(1));
                oCont.replace(DB.gu_workarea, oRSet.getString(2));
                oRSet.close();
                oCont.addAttachments(oConn, argv[2], aDirs[d].getAbsolutePath(), true);
                oConn.commit();
                aDirs[d].delete();
              } else {
                DebugFile.writeln("AttachmentUploader.main() SQLException: No data found for Contact "+sDirName);
                oRSet.close();
              } // fi (next)
            } // fi (isDirectory)
          } // next
          oStmt.close();
          oConn.close("AttachmentUploader");
          oDbbd.close();
        } // fi (aDirs)
      } catch (Exception xcpt) {
        if (DebugFile.trace) {
          DebugFile.writeln(xcpt.getClass().getName()+" "+xcpt.getMessage());
          try { DebugFile.writeln(StackTraceUtil.getStackTrace(xcpt)); } catch (IOException ignore) {}
View Full Code Here

  }

  protected RuleEngine(String sPropertiesPath, String sProfile)
    throws FileNotFoundException, IOException {
    loadDefaultProperties(sProfile, sPropertiesPath);
    setDefaultDataBaseBind(new DBBind(sProfile));
  }
View Full Code Here

        DebugFile.writeln(sKey+"="+oProperties.getProperty(sKey));
      } // wend
    }

    setDefaultProperties(oProperties, sProfile);
    setDefaultDataBaseBind(new DBBind(sProfile));

    if (DebugFile.trace) DebugFile.decIdent();
  }
View Full Code Here

    }
    else if (!argv[1].equalsIgnoreCase("list") || !argv[1].equalsIgnoreCase("emails")) {
      printUsage();
    }
    else {
      DBBind oDBB = new DBBind();
      JDCConnection oCon = oDBB.getConnection("ACLDomain_main");
      Statement oStm = oCon.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
      ResultSet oRst = oStm.executeQuery("SELECT " + DB.tx_main_email + " FROM " + DB.k_users + " WHERE " + DB.id_domain + "=" + argv[2] + " AND " + DB.bo_active + "<>0");

      while (oRst.next()) {
        System.out.println(oRst.getString(1));
      } // wend

      oRst.close();
      oStm.close();
      oCon.close("ACLDomain_main");

      oDBB.connectionPool().close();
      oDBB = null;
    }
  } // main
View Full Code Here

   */
  public static void main(String[] argv)
    throws NumberFormatException, InstantiationException, InterruptedException,
           FileNotFoundException, IOException {

    DBBind oDBB = new DBBind();

    Image oImg;

    if (argv.length<6 || argv.length>7) {
      System.out.println("");
      System.out.println("Invalid number of parameters");
      printUsage();
    }
    else if (!argv[0].equalsIgnoreCase("jai") && !argv[0].equalsIgnoreCase("awt")
          && !argv[0].equalsIgnoreCase("thumbnail")) {
      System.out.println("");
      System.out.println("Parameter 1 must be jai,awt or thumbnail");
      printUsage();
    }
    else if ((argv[0].equalsIgnoreCase("jai") || argv[0].equalsIgnoreCase("awt"))
         && !argv[1].equalsIgnoreCase("thumbnail")) {
      System.out.println("");
      System.out.println("Parameter 2 must be thumbnail");
      printUsage();
    }
    else {
      if (argv[0].equalsIgnoreCase("jai")) {
        oImg = new Image(USE_JAI);
        oImg.put(DB.path_image, argv[2]);
        oImg.createThumbFile(argv[3], Integer.parseInt(argv[4]), Integer.parseInt(argv[5]), Float.parseFloat(argv[6]));
        oImg = null;
      }
      else if (argv[0].equalsIgnoreCase("awt")) {
        oImg = new Image(USE_AWT);
        oImg.put(DB.path_image, argv[2]);
        oImg.createThumbFile(argv[3], Integer.parseInt(argv[4]), Integer.parseInt(argv[5]), Float.parseFloat(argv[6]));
        oImg = null;
      }
      else {
        oImg = new Image(USE_AWT);
        oImg.put(DB.path_image, argv[1]);
        oImg.createThumbFile(argv[2], Integer.parseInt(argv[3]), Integer.parseInt(argv[4]), Float.parseFloat(argv[5]));
        oImg = null;
      }
    }
    oDBB.close();

    if (argv.length==6)
      System.out.println("Thumbnail " + argv[2] + " successfully created");
    else
      System.out.println("Thumbnail " + argv[3] + " successfully created");
View Full Code Here

   public static void main(String[] argv)
     throws SQLException, org.xml.sax.SAXException, java.io.IOException,
     ClassNotFoundException, IllegalAccessException, InstantiationException {

     DBPersist oJob;
     DBBind oDBB;
     JDCConnection oCon;

     if (argv.length!=4 && argv.length!=5)
       printUsage();
     else
       if (!argv[0].equals("create"))
         printUsage();

      else if (!argv[1].equalsIgnoreCase("MAIL") && !argv[1].equalsIgnoreCase("FAX") &&
                !argv[1].equalsIgnoreCase("SAVE") && !argv[1].equalsIgnoreCase("FTP") &&
                !argv[1].equalsIgnoreCase("SEND") )
        printUsage();

      else {
         oDBB = new DBBind(argv[2]);

         oCon = oDBB.getConnection("job_main");
         oCon.setAutoCommit(true);

         oJob = new DBPersist(DB.k_jobs, argv[1]);

         oJob.parseXML(argv[3]);

         if (argv.length==5)
           oJob.replace (DB.gu_job, argv[4]);

         else if (!oJob.getItemMap().containsKey(DB.gu_job))
           oJob.put (DB.gu_job, com.knowgate.misc.Gadgets.generateUUID());

         oJob.store(oCon);

         oCon.close();

         oDBB.close();

         System.out.println("gu_job:"+oJob.getString(DB.gu_job));
      } // fi

   } // main
View Full Code Here

TOP

Related Classes of com.knowgate.dataobjs.DBBind$Functions

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.