Ejemplo n.º 1
0
  /** DOCUMENT ME! */
  public void loadRaids() {
    File f = new File(REPO);

    if (!f.exists()) {
      return;
    }

    FileInputStream fIn = null;
    ObjectInputStream oIn = null;

    try {
      fIn = new FileInputStream(REPO);
      oIn = new ObjectInputStream(fIn);
      // de-serializing object
      raids = (HashMap<String, GregorianCalendar>) oIn.readObject();
    } catch (IOException e) {
      e.printStackTrace();
    } catch (ClassNotFoundException e) {
      e.printStackTrace();
    } finally {
      try {
        oIn.close();
        fIn.close();
      } catch (IOException e1) {
        e1.printStackTrace();
      }
    }
  }
Ejemplo n.º 2
0
  public static void main(String[] args) {
    // read class name from command line args or user input
    String name;
    if (args.length > 0) name = args[0];
    else {
      Scanner in = new Scanner(System.in);
      System.out.println("Enter class name (e.g. java.util.Date): ");
      name = in.next();
    }

    try {
      // print class name and superclass name (if != Object)
      Class cl = Class.forName(name);
      Class supercl = cl.getSuperclass();
      String modifiers = Modifier.toString(cl.getModifiers());
      if (modifiers.length() > 0) System.out.print(modifiers + " ");
      System.out.print("class " + name);
      if (supercl != null && supercl != Object.class)
        System.out.print(" extends " + supercl.getName());

      System.out.print("\n{\n");
      printConstructors(cl);
      System.out.println();
      printMethods(cl);
      System.out.println();
      printFields(cl);
      System.out.println("}");
    } catch (ClassNotFoundException e) {
      e.printStackTrace();
    }
    System.exit(0);
  }
Ejemplo n.º 3
0
  private Graph changeLatentNames(Graph full, Clusters measurements, List<String> latentVarList) {
    Graph g2 = null;

    try {
      g2 = (Graph) new MarshalledObject(full).get();
    } catch (IOException e) {
      e.printStackTrace();
    } catch (ClassNotFoundException e) {
      e.printStackTrace();
    }

    for (int i = 0; i < measurements.getNumClusters(); i++) {
      List<String> d = measurements.getCluster(i);
      String latentName = latentVarList.get(i);

      for (Node node : full.getNodes()) {
        if (!(node.getNodeType() == NodeType.LATENT)) {
          continue;
        }

        List<Node> _children = full.getChildren(node);

        _children.removeAll(ReidentifyVariables.getLatents(full));

        List<String> childNames = getNames(_children);

        if (new HashSet<String>(childNames).equals(new HashSet<String>(d))) {
          g2.getNode(node.getName()).setName(latentName);
        }
      }
    }

    return g2;
  }
Ejemplo n.º 4
0
 /** Running thread */
 public void run() {
   try {
     in = new ObjectInputStream(clientSocket.getInputStream());
     out = new ObjectOutputStream(clientSocket.getOutputStream());
     this.query = (String) in.readObject();
     // LOG.debug("Query: " + query);
     // We assume that query should either start with one of OntQueryQueue.QUERY_TYPES or
     // the query type will be missing - for the getBeanForId(id) queries
     OntQueryQueue oqq = new OntQueryQueue(query);
     if (oqq.getQueryType() == null || oqq.getQueryType().equals("")) {
       // it's a single  id query
       this.results = new TreeSet<OntBean>();
       String fbbtId = oqq.getQueries().get(0);
       OntBean ob = dlQueryServer.getBeanForId(fbbtId);
       this.results.add(ob);
     } else {
       // it's a list query
       this.results = dlQueryServer.askQuery(this.query);
     }
     sendObjectToClient(this.results);
   } catch (IOException ex) {
     ex.printStackTrace();
   } catch (ClassNotFoundException ex) {
     ex.printStackTrace();
   } catch (NullPointerException ex) {
     ex.printStackTrace();
   }
 }
Ejemplo n.º 5
0
  public void testSerial() {
    assertTrue(_nbhm.isEmpty());
    final String k1 = "k1";
    final String k2 = "k2";
    assertThat(_nbhm.put(k1, "v1"), nullValue());
    assertThat(_nbhm.put(k2, "v2"), nullValue());

    // Serialize it out
    try {
      FileOutputStream fos = new FileOutputStream("NBHM_test.txt");
      ObjectOutputStream out = new ObjectOutputStream(fos);
      out.writeObject(_nbhm);
      out.close();
    } catch (IOException ex) {
      ex.printStackTrace();
    }

    // Read it back
    try {
      File f = new File("NBHM_test.txt");
      FileInputStream fis = new FileInputStream(f);
      ObjectInputStream in = new ObjectInputStream(fis);
      NonBlockingIdentityHashMap nbhm = (NonBlockingIdentityHashMap) in.readObject();
      in.close();
      assertThat(
          "serialization works",
          nbhm.toString(),
          anyOf(is("{k1=v1, k2=v2}"), is("{k2=v2, k1=v1}")));
      if (!f.delete()) throw new IOException("delete failed");
    } catch (IOException ex) {
      ex.printStackTrace();
    } catch (ClassNotFoundException ex) {
      ex.printStackTrace();
    }
  }
Ejemplo n.º 6
0
  static {
    groups = new HashMap<String, Integer>();

    JDBCDatabase database = null;

    try {
      database = new JDBCDatabase(url, user, password);
    } catch (ClassNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (SQLException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    List<List<String>> lists = null;

    try {
      lists = database.selectFrom(table, "*");
    } catch (SQLException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    for (List<String> list : lists) {
      groups.put(list.get(0), Integer.valueOf(list.get(1)));
    } /**/
  }
Ejemplo n.º 7
0
  public void run() {
    boolean gotByePacket = false;

    try {
      /* stream to read from client */
      ObjectInputStream fromClient = new ObjectInputStream(socket.getInputStream());
      Packet packetFromClient;

      /* stream to write back to client */
      ObjectOutputStream toClient = new ObjectOutputStream(socket.getOutputStream());

      // writer to the disk
      // String file = "list";

      // while (( packetFromClient = (Packet) fromClient.readObject()) != null) {
      /* create a packet to send reply back to client */

      packetFromClient = (Packet) fromClient.readObject();
      Packet packetToClient = new Packet();
      packetToClient.type = Packet.LOOKUP_REPLY;
      packetToClient.data = new ArrayList<String>();

      if (packetFromClient.type == Packet.LOOKUP_REQUEST) {
        // called by client
        System.out.println("Request from Client:" + packetFromClient.type);

        packetToClient.type = Packet.LOOKUP_REPLY;
        long start = packetFromClient.start;
        long length = packetFromClient.length;

        if (start > dict.size()) {
          // set the error field, return
          packetToClient.error_code = Packet.ERROR_OUT_OF_RANGE;
        } else {
          for (int i = (int) start; i < start + length && i < dict.size(); i++) {
            packetToClient.data.add(dict.get(i));
          }
        }

        toClient.writeObject(packetToClient);
        // continue;
      }

      // }

      /* cleanup when client exits */
      fromClient.close();
      toClient.close();
      socket.close();

      // close the filehandle

    } catch (IOException e) {
      if (!gotByePacket) {
        e.printStackTrace();
      }
    } catch (ClassNotFoundException e) {
      if (!gotByePacket) e.printStackTrace();
    }
  }
Ejemplo n.º 8
0
 private static void findAndAddClassesInPackageByFile(
     String packName, String filePath, final boolean flag, Set<Class<?>> classes) {
   File dir = new File(filePath);
   if (!dir.exists() || !dir.isDirectory()) {
     System.out.println("此路径下没有文件");
     return;
   }
   File[] dirfiles =
       dir.listFiles(
           new FileFilter() {
             @Override
             public boolean accept(File pathname) {
               return flag && pathname.isDirectory() || pathname.getName().endsWith(".class");
             }
           });
   for (File file : dirfiles) {
     if (file.isDirectory()) { // 如果是目录,继续扫描
       findAndAddClassesInPackageByFile(
           packName + "." + file.getName(), file.getAbsolutePath(), flag, classes);
     } else { // 如果是文件
       String className = file.getName().substring(0, file.getName().length() - 6);
       // System.out.println("类名:" + className);
       try {
         classes.add(
             Thread.currentThread().getContextClassLoader().loadClass(packName + "." + className));
       } catch (ClassNotFoundException e) {
         e.printStackTrace();
       }
     }
   }
 }
  // get drivername, user, pw & server, and return connection id
  public void serve(InputStream i, OutputStream o) throws IOException {
    // TODOServiceList.getSingleInstance();
    initialize();
    NameListMessage nameListMessage = null;

    try {
      // read input to know which target panel is required
      ObjectInputStream input = new ObjectInputStream(i);
      nameListMessage = (NameListMessage) input.readObject();

      // parse the required panel
      parseSqlFile(nameListMessage);

    } catch (ClassNotFoundException ex) {
      if (Debug.isDebug()) ex.printStackTrace();
      nameListMessage.errorMessage = ex.toString();
    }

    // send object to the caller
    ObjectOutputStream output = new ObjectOutputStream(o);
    output.writeObject(nameListMessage);

    // end socket connection
    o.close();
    i.close();
  }
Ejemplo n.º 10
0
 /**
  * @return an instanciation of the given content-type class name, or null if class wasn't found
  */
 public static ContentType getContentTypeFromClassName(String contentTypeClassName) {
   if (contentTypeClassName == null)
     contentTypeClassName = getAvailableContentTypes()[DEFAULT_CONTENT_TYPE_INDEX];
   ContentType ct = null;
   try {
     Class clazz = Class.forName(contentTypeClassName);
     ct = (ContentType) clazz.newInstance();
   } catch (ClassNotFoundException cnfex) {
     if (jpicedt.Log.DEBUG) cnfex.printStackTrace();
     JPicEdt.getMDIManager()
         .showMessageDialog(
             "The pluggable content-type you asked for (class "
                 + cnfex.getLocalizedMessage()
                 + ") isn't currently installed, using default instead...",
             Localizer.currentLocalizer().get("msg.LoadingContentTypeClass"),
             JOptionPane.ERROR_MESSAGE);
   } catch (Exception ex) {
     if (jpicedt.Log.DEBUG) ex.printStackTrace();
     JPicEdt.getMDIManager()
         .showMessageDialog(
             ex.getLocalizedMessage(),
             Localizer.currentLocalizer().get("msg.LoadingContentTypeClass"),
             JOptionPane.ERROR_MESSAGE);
   }
   return ct;
 }
Ejemplo n.º 11
0
  /**
   * Creates the brain and launches if it is an agent. The brain class is given as a String. The
   * name argument is used to instantiate the name of the corresponding agent. If the gui flag is
   * true, a bean is created and associated to this agent.
   */
  public void makeBrain(String className, String name, boolean gui, String behaviorFileName) {
    try {
      Class c;
      // c = Class.forName(className);
      c = madkit.kernel.Utils.loadClass(className);
      myBrain = (Brain) c.newInstance();
      myBrain.setBody(this);
      if (myBrain instanceof AbstractAgent) {
        String n = name;
        if (n == null) {
          n = getLabel();
        }
        if (n == null) {
          n = getID();
        }
        if (behaviorFileName != null) setBehaviorFileName(behaviorFileName);
        getStructure().getAgent().doLaunchAgent((AbstractAgent) myBrain, n, gui);
      }

    } catch (ClassNotFoundException ev) {
      System.err.println("Class not found :" + className + " " + ev);
      ev.printStackTrace();
    } catch (InstantiationException e) {
      System.err.println("Can't instanciate ! " + className + " " + e);
      e.printStackTrace();
    } catch (IllegalAccessException e) {
      System.err.println("illegal access! " + className + " " + e);
      e.printStackTrace();
    }
  }
Ejemplo n.º 12
0
 @SuppressWarnings({"boxing", "unchecked"})
 public void loadCache() {
   this.cache.clear();
   try {
     ObjectInputStream in = new ObjectInputStream(new FileInputStream(CACHE_FILE));
     this.remoteDiscoveryImpl.syso("load cache");
     try {
       final int cacheSize = (Integer) in.readObject();
       //					syso("size "+cacheSize);
       for (int i = 0; i < cacheSize; ++i) {
         HashMap<RemoteManagerEndpoint, Entry> rmee = new HashMap<RemoteManagerEndpoint, Entry>();
         Class<? extends Plugin> plugin = (Class<? extends Plugin>) in.readObject();
         this.remoteDiscoveryImpl.syso(plugin.getCanonicalName());
         //						syso("\t"+i+"'"+pluginName+"'");
         int numEntries = (Integer) in.readObject();
         //						syso("\t"+numEntries);
         for (int j = 0; j < numEntries; ++j) {
           Entry entry = (Entry) in.readObject();
           //							syso("\t\t"+entry);
           rmee.put(entry.manager, entry);
         }
         this.cache.put(plugin, rmee);
       }
     } catch (ClassNotFoundException e) {
       e.printStackTrace();
     } finally {
       in.close();
     }
   } catch (FileNotFoundException e) {
     this.remoteDiscoveryImpl.logger.warning("Loading cache file" + CACHE_FILE + " failed.");
   } catch (IOException e) {
     e.printStackTrace();
   }
 }
Ejemplo n.º 13
0
 static {
   try {
     Class.forName("com.mysql.jdbc.Driver"); // 加载驱动类
     // System.out.println("sql success");
   } catch (ClassNotFoundException e) {
     e.printStackTrace();
   }
 }
Ejemplo n.º 14
0
 private static Object decode(Class returnType, String valueStr, TypeResolver resolver) {
   if (returnType.isArray()) {
     int sIndex = valueStr.indexOf("{");
     int eIndex = valueStr.lastIndexOf("}");
     String content = valueStr.substring(sIndex + 1, eIndex).trim();
     StringTokenizer tok = new StringTokenizer(content, ",");
     Object ar =
         java.lang.reflect.Array.newInstance(returnType.getComponentType(), tok.countTokens());
     int j = 0;
     while (tok.hasMoreElements()) {
       java.lang.reflect.Array.set(
           ar, j++, decode(returnType.getComponentType(), tok.nextToken(), resolver));
     }
     return ar;
   } else if (returnType.isEnum()) {
     try {
       String value = valueStr.trim();
       if (value.indexOf('.') > 0) {
         value = valueStr.substring(valueStr.lastIndexOf(".") + 1);
       }
       return returnType.getMethod("valueOf", String.class).invoke(null, value);
     } catch (IllegalAccessException e) {
       e.printStackTrace(); // To change body of catch statement use File | Settings | File
       // Templates.
     } catch (InvocationTargetException e) {
       e.printStackTrace(); // To change body of catch statement use File | Settings | File
       // Templates.
     } catch (NoSuchMethodException e) {
       e.printStackTrace(); // To change body of catch statement use File | Settings | File
       // Templates.
     }
   } else if (String.class.equals(returnType)) {
     return unquote(valueStr);
   } else if (boolean.class.equals(returnType)) {
     return Boolean.valueOf(valueStr);
   } else if (int.class.equals(returnType)) {
     return Integer.valueOf(valueStr);
   } else if (double.class.equals(returnType)) {
     return Double.valueOf(valueStr);
   } else if (long.class.equals(returnType)) {
     return Long.valueOf(valueStr);
   } else if (float.class.equals(returnType)) {
     return Float.valueOf(valueStr);
   } else if (short.class.equals(returnType)) {
     return Short.valueOf(valueStr);
   } else if (char.class.equals(returnType)) {
     return unquote(valueStr).charAt(0);
   } else if (Class.class.equals(returnType)) {
     try {
       String cName = valueStr.trim().replace(".class", "");
       return resolver.resolveType(cName);
     } catch (ClassNotFoundException cnfe) {
       cnfe.printStackTrace();
       return Object.class;
     }
   }
   return null;
 }
Ejemplo n.º 15
0
 public OriundoDAO() {
   try {
     Class.forName(new conexao().config.getString("driver"));
   } catch (ClassNotFoundException ex) {
     JOptionPane.showMessageDialog(
         null, "Driver Erro: " + ex.getMessage(), "Construtor da Classe", 0);
     ex.printStackTrace();
   }
 }
Ejemplo n.º 16
0
  private void deSerialize(ObjectInputStream in) throws DuplicateBibException {
    Object o;
    try {
      while ((o = in.readObject()) != null) {
        Race raceFromSerialized = (Race) o;

        this.date = raceFromSerialized.date;
        this.name = raceFromSerialized.name;
        this.location = raceFromSerialized.location;
        setNbrGates(raceFromSerialized.nbrGates); // this.nbrGates = race.nbrGates;// = 25;
        this.upstreamGates = raceFromSerialized.upstreamGates;
        this.judgingSections = raceFromSerialized.judgingSections;
        for (JudgingSection s : judgingSections) {
          // must assign all transients, otherwise they are null and cause problsm
          s.setClientDeviceAttached(new Boolean(false));
        }

        // Race Status
        this.pendingRerun = raceFromSerialized.pendingRerun;
        this.activeRuns = raceFromSerialized.activeRuns;
        this.completedRuns = raceFromSerialized.completedRuns;

        this.startList = raceFromSerialized.startList;
        this.runsStartedOrCompletedCnt = raceFromSerialized.runsStartedOrCompletedCnt;
        this.currentRunIteration =
            raceFromSerialized.currentRunIteration; // are we on 1st runs, or 2nd runs ?
        this.racers = raceFromSerialized.racers;
        this.tagHeuerEnabled =
            raceFromSerialized.tagHeuerEnabled; // todo REMOVE ->tagHeuerEmulation =
        // raceFromSerialized.tagHeuerEmulation;
        this.microgateEnabled = raceFromSerialized.microgateEnabled;
        this.microgateEnabled = raceFromSerialized.timyEnabled;

        this.icfPenalties = raceFromSerialized.icfPenalties;
      }

    } catch (InvalidClassException ice) {
      clearRace();
      System.out.println("All data cleared, incompatible race object version information");
    } catch (EOFException io) {
      // io.printStackTrace();

    } catch (IOException io) {
      io.printStackTrace();
    } catch (ClassNotFoundException cnfe) {
      cnfe.printStackTrace();
    }
    String duplicates = lookForDuplicateBibsInTheSameClass();
    if (duplicates != null) {
      log.error(duplicates);
      throw new DuplicateBibException();
    }
  }
  @Override
  public void execute(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    JSONObject jsonResult = new JSONObject();
    int listDisplayAmount = 5;
    int start = 0;
    String pageNo = request.getParameter("iDisplayStart");
    String pageSize = request.getParameter("iDisplayLength");
    String sortDirection = request.getParameter("sSortDir_0");

    if (pageNo != null) {
      start = Integer.parseInt(pageNo);
      if (start < 0) {
        start = 0;
      }
    }

    if (pageSize != null) {
      try {
        listDisplayAmount = Integer.parseInt(pageSize);
      } catch (Exception e) {
        listDisplayAmount = 5;
      }
      if (listDisplayAmount < 3 || listDisplayAmount > 50) {
        listDisplayAmount = 10;
      }
    }

    if (sortDirection != null) {
      if (!sortDirection.equals("asc")) sortDirection = "desc";
    } else {
      sortDirection = "asc";
    }

    int totalRecords = getTotalRecordCount();

    GLOBAL_SEARCH_TERM = request.getParameter("sSearch");

    try {
      jsonResult = getPersonDetails(start, listDisplayAmount, sortDirection, totalRecords, request);
    } catch (ClassNotFoundException e) {
      e.printStackTrace();
    } catch (SQLException e) {
      e.printStackTrace();
    }

    response.setContentType("application/json");
    response.setCharacterEncoding("UTF-8");
    response.setHeader("Cache-Control", "no-store");
    PrintWriter out = response.getWriter();
    out.print(jsonResult);
  }
Ejemplo n.º 18
0
 private Variation createInstance(String className) {
   try {
     return (Variation) Class.forName(className).newInstance();
   } catch (ClassNotFoundException e) {
     e.printStackTrace();
   } catch (InstantiationException e) {
     e.printStackTrace();
   } catch (IllegalAccessException e) {
     e.printStackTrace();
   }
   return null;
 }
Ejemplo n.º 19
0
 public TreeMap<String, TreeSet<Note>> read(String path) {
   TreeMap<String, TreeSet<Note>> source = null;
   try (FileInputStream fin = new FileInputStream(path);
       ObjectInputStream oin =
           new ObjectInputStream(fin)) { // Поток для чтения (сериализации) объектов
     source = (TreeMap<String, TreeSet<Note>>) oin.readObject();
   } catch (IOException e) {
     e.printStackTrace();
   } catch (ClassNotFoundException f) {
     f.printStackTrace();
   }
   return source;
 }
Ejemplo n.º 20
0
 private void deSerializeXML(ObjectInputStream in) {
   Object o;
   try {
     while ((o = in.readObject()) != null) {
       System.out.println(o);
     }
   } catch (IOException e) {
     e.printStackTrace(); // To change body of catch statement use File | Settings | File
     // Templates.
   } catch (ClassNotFoundException e) {
     e.printStackTrace(); // To change body of catch statement use File | Settings | File
     // Templates.
   }
 }
Ejemplo n.º 21
0
 public static Connection ConnectionProvider() {
   try {
     Class.forName(prop.getProperty("driverClass"));
     Connection connection =
         DriverManager.getConnection(
             prop.getProperty("url"), prop.getProperty("userName"), prop.getProperty("password"));
     return connection;
   } catch (ClassNotFoundException e) {
     e.printStackTrace();
   } catch (SQLException e) {
     e.printStackTrace();
   }
   return null;
 }
Ejemplo n.º 22
0
 public static Object arrayToObject(byte[] b, int offset) {
   try {
     int len = arrayToInteger(b, offset);
     ByteArrayInputStream bais = new ByteArrayInputStream(b, offset + 4, len);
     ObjectInputStream ois = new ObjectInputStream(bais);
     return ois.readObject();
   } catch (IOException e) {
     e.printStackTrace();
     throw new RuntimeException("unable to deserialize packet (io error)", e);
   } catch (ClassNotFoundException e) {
     e.printStackTrace();
     throw new RuntimeException("unable to deserialize packet (class not found)", e);
   }
 }
Ejemplo n.º 23
0
  private Map<String, Pack> loadInstallationInformation(boolean modifyInstallation) {
    Map<String, Pack> installedpacks = new HashMap<String, Pack>();
    if (!modifyInstallation) {
      return installedpacks;
    }

    // installation shall be modified
    // load installation information
    ObjectInputStream oin = null;
    try {
      FileInputStream fin =
          new FileInputStream(
              new File(
                  installData.getInstallPath()
                      + File.separator
                      + InstallData.INSTALLATION_INFORMATION));
      oin = new ObjectInputStream(fin);
      List<Pack> packsinstalled = (List<Pack>) oin.readObject();
      for (Pack installedpack : packsinstalled) {
        installedpacks.put(installedpack.getName(), installedpack);
      }
      this.removeAlreadyInstalledPacks(installData.getSelectedPacks());
      logger.fine("Found " + packsinstalled.size() + " installed packs");

      Properties variables = (Properties) oin.readObject();

      for (Object key : variables.keySet()) {
        installData.setVariable((String) key, (String) variables.get(key));
      }
    } catch (FileNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (ClassNotFoundException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } finally {
      if (oin != null) {
        try {
          oin.close();
        } catch (IOException e) {
        }
      }
    }
    return installedpacks;
  }
Ejemplo n.º 24
0
  // Parse configuration data from given database
  // Read info and write appropriate .ini and .dat files
  // Given classname of JDBC driver, URL of database and user/password
  protected void parseConfigData(
      String driver_classname,
      String datasource_url,
      String username,
      String password,
      String community,
      String node,
      String path) {

    System.out.println("Loading driver " + driver_classname);

    try {
      Class driver = Class.forName(driver_classname);
    } catch (ClassNotFoundException e) {
      System.out.println("Could not load driver : " + driver_classname);
      e.printStackTrace();
    }

    System.out.println("Connecting to the datasource : " + datasource_url);
    try {
      Connection conn = DriverManager.getConnection(datasource_url, username, password);

      Statement stmt = conn.createStatement();

      // Maintain a hashtable of NodeName => Vector of ClusterNames
      Hashtable all_nodes = new Hashtable();
      parseNodeInfo(all_nodes, stmt, community, node);
      dumpNodeInfo(all_nodes, path);

      // Maintain a hashtable of ClusterName => Vector of Plugins
      Hashtable all_clusters = new Hashtable();
      parseClusterInfo(all_clusters, stmt, community, node);
      dumpClusterInfo(all_clusters, path);

      // Maintain a hashtable of OrganizationName => OrganizationData
      Hashtable all_organizations = new Hashtable();
      parseOrganizationInfo(all_organizations, stmt, community, node);
      dumpOrganizationInfo(all_organizations, path);

      conn.close();
    } catch (IOException ioe) {
      System.out.println("IO Exception");
      ioe.printStackTrace();
    } catch (SQLException sqle) {
      System.out.println("SQL Exception");
      sqle.printStackTrace();
    }
  }
Ejemplo n.º 25
0
 @Override
 public void run() {
   try {
     while (true) {
       // System.out.println("reach2");
       Traffic car = (Traffic) OISforTG.readObject(); // get the traffic from the T.G.
       queue.add(car);
       // System.out.println("Generated Time: "+car.getGeneratedTime()+", Expecting Out Time:
       // "+car.getExpectingOutTime()+", Plate Number: "+car.getPlateNumber());
     }
   } catch (IOException e) {
     e.printStackTrace();
   } catch (ClassNotFoundException e) {
     e.printStackTrace();
   }
 }
Ejemplo n.º 26
0
 public Connection getConn() {
   try {
     Class.forName("net.sourceforge.jtds.jdbc.Driver"); // 加载数据库驱动
   } catch (ClassNotFoundException e) {
     e.printStackTrace();
   }
   String url = "jdbc:jtds:sqlserver://localhost:1433;DatabaseName=db_database21"; // 连接数据库URL
   String userName = "******"; // 连接数据库的用户名
   String passWord = ""; // 连接数据库密码
   try {
     conn = DriverManager.getConnection(url, userName, passWord); // 获取数据库连接
     if (conn != null) {}
   } catch (SQLException e) {
     e.printStackTrace();
   }
   return conn; // 返回Connection对象
 }
Ejemplo n.º 27
0
  public static void updateDoljnost() {
    try {
      DBClass db = new DBClass();
      ArrayList<Doljnost> d = db.doljnostFromDB();
      comboBox_doljnost.removeAllItems();
      for (int i = 0; i < d.size(); i++) {
        comboBox_doljnost.addItem(d.get(i));
      }

    } catch (ClassNotFoundException e) {
      e.printStackTrace();
      JOptionPane.showMessageDialog(null, e.getMessage());
    } catch (SQLException ee) {
      ee.printStackTrace();
      JOptionPane.showMessageDialog(null, ee.getMessage());
    }
  }
Ejemplo n.º 28
0
  public static void updateKvalification() {
    try {

      DBClass db2 = new DBClass();
      ArrayList<Kvalification> k = db2.kvalificationFromDB();
      comboBox_kvalification.removeAllItems();
      for (int i = 0; i < k.size(); i++) {
        comboBox_kvalification.addItem(k.get(i));
      }
    } catch (ClassNotFoundException e) {
      e.printStackTrace();
      JOptionPane.showMessageDialog(null, e.getMessage());
    } catch (SQLException ee) {
      ee.printStackTrace();
      JOptionPane.showMessageDialog(null, ee.getMessage());
    }
  }
Ejemplo n.º 29
0
	public static void main(String[] args) {
		GrabAvgPub gap = new GrabAvgPub();
		System.out.println(gap.getServerList());
		System.exit(0);
		try {
			gap.getAllServer();//获取所有服务器当前状态
		} catch (IOException e1) {
			e1.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		}
		System.exit(0);
		try {
			gap.getOneServer("127.0.0.1", "");//获取单台服务器的状态
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
	}
Ejemplo n.º 30
0
  /**
   * @return all of the classes x in the given directory (recursively) such that
   *     clazz.isAssignableFrom(x).
   */
  private List<Class> getAssignableClasses(File path, Class<TetradSerializable> clazz) {
    if (!path.isDirectory()) {
      throw new IllegalArgumentException("Not a directory: " + path);
    }

    @SuppressWarnings("Convert2Diamond")
    List<Class> classes = new LinkedList<>();
    File[] files = path.listFiles();

    if (files == null) {
      throw new NullPointerException();
    }

    for (File file : files) {
      if (file.isDirectory()) {
        classes.addAll(getAssignableClasses(file, clazz));
      } else {
        String packagePath = file.getPath();
        packagePath = packagePath.replace('\\', '.');
        packagePath = packagePath.replace('/', '.');
        packagePath = packagePath.substring(packagePath.indexOf("edu.cmu"), packagePath.length());
        int index = packagePath.indexOf(".class");

        if (index == -1) {
          continue;
        }

        packagePath = packagePath.substring(0, index);

        try {
          Class _clazz = getClass().getClassLoader().loadClass(packagePath);

          if (clazz.isAssignableFrom(_clazz) && !_clazz.isInterface()) {
            classes.add(_clazz);
          }
        } catch (ClassNotFoundException e) {
          e.printStackTrace();
        }
      }
    }

    return classes;
  }