Exemplo n.º 1
0
 private Connection getSYBASEConnection() {
   try {
     Class.forName("com.sybase.jdbc2.jdbc.SybDriver");
     return DriverManager.getConnection("jdbc:sybase:Tds:fe-test:2048/feDB", "sa", null);
   } catch (Exception e) {
     e.printStackTrace();
     return null;
   }
 }
Exemplo n.º 2
0
 private Connection getSOLIDConnection() {
   try {
     Class.forName("solid.jdbc.SolidDriver");
     return DriverManager.getConnection("jdbc:solid://nms-clienttest1:1313/dba/dba", "dba", "dba");
   } catch (Exception e) {
     e.printStackTrace();
     return null;
   }
 }
Exemplo n.º 3
0
 private Connection getTIMESTENConnection() {
   try {
     Class.forName("com.timesten.jdbc.TimesTenDriver");
     return DriverManager.getConnection("jdbc:timesten:direct:WebNmsDB", "root", null);
   } catch (Exception e) {
     e.printStackTrace();
     return null;
   }
 }
Exemplo n.º 4
0
 private Connection getMYSQLConnection() {
   try {
     Class.forName("org.gjt.mm.mysql.Driver");
     return DriverManager.getConnection("jdbc:mysql://localhost/WebNmsDB", "root", null);
   } catch (Exception e) {
     e.printStackTrace();
     return null;
   }
 }
 public Connection createConnection() throws Exception {
   Connection con;
   try {
     Class.forName(dbClass);
     con = DriverManager.getConnection(dbUrl, dbUser, dbPassword);
   } catch (Exception e) {
     e.printStackTrace();
     throw e;
   }
   return con;
 }
Exemplo n.º 6
0
  private Connection getORACLEConnection() {
    try {

      Class.forName("oracle.jdbc.driver.OracleDriver");
      return DriverManager.getConnection(
          "jdbc:oracle:thin:@kernel-win:1521:oracle", "BFW3", "BFW3");
    } catch (Exception e) {
      e.printStackTrace();
      return null;
    }
  }
Exemplo n.º 7
0
 static {
   // FIXME: RMIServerImpl_Stub is generated at build time
   // after jconsole is built.  We need to investigate if
   // the Makefile can be fixed to build jconsole in the
   // right order.  As a workaround for now, we dynamically
   // load RMIServerImpl_Stub class instead of statically
   // referencing it.
   Class<? extends Remote> serverStubClass = null;
   try {
     serverStubClass = Class.forName(rmiServerImplStubClassName).asSubclass(Remote.class);
   } catch (ClassNotFoundException e) {
     // should never reach here
     throw (InternalError) new InternalError(e.getMessage()).initCause(e);
   }
   rmiServerImplStubClass = serverStubClass;
 }
Exemplo n.º 8
0
  /**
   * This method returns a <tt>Class</tt> for a helper which can handle the list of distributions
   * specified by <tt>seq1</tt>. We maintain a cache of recently-loaded helpers, so check the cache
   * before going to the trouble of searching for a helper. The cache is blown away every
   * <tt>HELPER_CACHE_REFRESH</tt> seconds.
   *
   * <p>If we can't find a helper in the cache, we must search through the list of available helpers
   * to find an appropriate one. First try to find helper using class sequence as specified by
   * <tt>seq</tt>. Whether or not that succeeds, promote any <tt>Gaussian</tt> in the sequence to
   * <tt>MixGaussians</tt>, and try again. If we get a better match on the second try, return the
   * helper thus found.
   */
  public static Class find_helper_class(Vector seq1, String helper_type)
      throws ClassNotFoundException {
    // Let's see if an appropriate helper is in the cache.
    // If the cache is too old, empty it and search for the helper anew.

    if (System.currentTimeMillis() - cache_timestamp > HELPER_CACHE_REFRESH) {
      helper_cache = new Hashtable();
      cache_timestamp = System.currentTimeMillis();
      // Go on and search for appropriate helper.
    } else {
      HelperCacheKey key = new HelperCacheKey(helper_type, seq1);
      Class helper_class = (Class) helper_cache.get(key);
      if (helper_class != null) {
        if (Global.debug > -1)
          System.err.println(
              "PiHelperLoader.find_helper_class: found helper class: "
                  + helper_class
                  + "; no need to search.");
        return helper_class;
      }
      // else no luck; we have to search for helper.
    }

    // Well, we didn't find a helper in the cache, so let's go to work.
    if (Global.debug > -1)
      System.err.println(
          "PiHelperLoader.find_helper_class: DID NOT FIND HELPER CLASS; NOW SEARCH.");

    Class c1 = null, c2 = null;
    ClassNotFoundException cnfe1 = null, cnfe2 = null;
    int[] class_score1 = new int[1], count_score1 = new int[1];
    int[] class_score2 = new int[1], count_score2 = new int[1];

    try {
      c1 = find_helper_class1(seq1, helper_type, class_score1, count_score1);
    } catch (ClassNotFoundException e) {
      cnfe1 = e;
    } // hang on, we may need to re-throw later.

    Class gaussian_class = Class.forName("riso.distributions.Gaussian");
    MixGaussians mog = new MixGaussians(1, 1);

    Vector seq2 = new Vector(seq1.size());
    for (int i = 0; i < seq1.size(); i++)
      if (gaussian_class.isAssignableFrom((Class) seq1.elementAt(i)))
        seq2.addElement(mog.getClass());
      else seq2.addElement(seq1.elementAt(i));

    try {
      c2 = find_helper_class1(seq2, helper_type, class_score2, count_score2);
    } catch (ClassNotFoundException e) {
      cnfe2 = e;
    }

    if (cnfe1 == null && cnfe2 == null) {
      // Both matched; see which one fits better.
      // Break ties in favor of the helper for non-promoted messages.

      if (class_score1[0] >= class_score2[0]
          || (class_score1[0] == class_score2[0] && count_score1[0] >= count_score2[0])) {
        if (Global.debug > 1)
          System.err.println(
              "\taccept helper " + c1 + " for non-promoted classes instead of " + c2);
        if (Global.debug > 1)
          System.err.println(
              "\t\t"
                  + class_score1[0]
                  + ", "
                  + class_score2[0]
                  + "; "
                  + count_score1[0]
                  + ", "
                  + count_score2[0]);
        helper_cache.put(new HelperCacheKey(helper_type, seq1), c1);
        return c1;
      } else {
        if (Global.debug > 1)
          System.err.println("\taccept helper " + c2 + " for promoted classes instead of " + c1);
        if (Global.debug > 1)
          System.err.println(
              "\t\t"
                  + class_score1[0]
                  + ", "
                  + class_score2[0]
                  + "; "
                  + count_score1[0]
                  + ", "
                  + count_score2[0]);
        helper_cache.put(new HelperCacheKey(helper_type, seq1), c2);
        return c2;
      }
    } else if (cnfe1 == null && cnfe2 != null) {
      // Only the first try matched, return it.
      helper_cache.put(new HelperCacheKey(helper_type, seq1), c1);
      return c1;
    } else if (cnfe1 != null && cnfe2 == null) {
      // Only the second try matched, return it.
      helper_cache.put(new HelperCacheKey(helper_type, seq1), c2);
      return c2;
    } else {
      // Neither try matched. Re-throw the exception generated by the first try.
      throw cnfe1;
    }
  }