@Test
  public void testEquals_WithoutWrapper() {
    Connection wrapped = wrap(connection, closeHandler);

    assertFalse(wrapped.equals(connection));
    assertTrue(wrapped.equals(wrapped));
  }
  @Test
  public void testEquals_WithWrapper() {
    final Runnable runnable = mock(Runnable.class);
    Connection wrapped = wrap(connection, Runnable.class, runnable, closeHandler);

    assertFalse(wrapped.equals(connection));
    assertTrue(wrapped.equals(wrapped));
  }
Exemplo n.º 3
0
 private boolean areConnectionsEquals(Object object) {
   // Special case if what we're being passed is one of our proxies (specifically a connection
   // proxy)
   // This way the equals call is truely transparent for our proxies (cf issue 78)
   if (Proxy.isProxyClass(object.getClass())) {
     final InvocationHandler invocationHandler = Proxy.getInvocationHandler(object);
     if (invocationHandler instanceof DelegatingInvocationHandler) {
       final DelegatingInvocationHandler d = (DelegatingInvocationHandler) invocationHandler;
       if (d.getDelegate() instanceof ConnectionInvocationHandler) {
         final ConnectionInvocationHandler c = (ConnectionInvocationHandler) d.getDelegate();
         return connection.equals(c.connection);
       }
     }
   }
   return connection.equals(object);
 }
Exemplo n.º 4
0
 /**
  * Determine whether the given two Connections are equal, asking the target Connection in case of
  * a proxy. Used to detect equality even if the user passed in a raw target Connection while the
  * held one is a proxy.
  *
  * @param conHolder the ConnectionHolder for the held Connection (potentially a proxy)
  * @param passedInCon the Connection passed-in by the user (potentially a target Connection
  *     without proxy)
  * @return whether the given Connections are equal
  * @see #getTargetConnection
  */
 private static boolean connectionEquals(ConnectionHolder conHolder, Connection passedInCon) {
   if (!conHolder.hasConnection()) {
     return false;
   }
   Connection heldCon = conHolder.getConnection();
   // Explicitly check for identity too: for Connection handles that do not implement
   // "equals" properly, such as the ones Commons DBCP exposes).
   return (heldCon == passedInCon
       || heldCon.equals(passedInCon)
       || getTargetConnection(heldCon).equals(passedInCon));
 }
Exemplo n.º 5
0
  public String verifyLogin(String latin) {
    String EXECUTION_RESULT = new String();
    String username = null;
    String userpwd = null;
    Connection con;
    String success = null;

    try {
      String host = "jdbc:mysql://localhost:3306/";
      String db = "pig_gwt_3";
      String driver = "com.mysql.jdbc.Driver";
      String user = "******";
      String pass = "******";

      Class.forName(driver).newInstance();
      con = DriverManager.getConnection(host + db, user, pass);

      if (con != null || !con.equals(null)) {
        success =
            updateRegistration(con, fname, lname, password, emailid, Licence, country, evalid);
      }
      if (success.equalsIgnoreCase("SuccessFul")) {
        return success;
      }

    } catch (Exception pigException) {
      // pigException.printStackTrace();
      EXECUTION_RESULT = EXECUTION_RESULT + "Exception  ";
      EXECUTION_RESULT = EXECUTION_RESULT + pigException.getMessage();
      pigException.printStackTrace();
    }
    if (EXECUTION_RESULT.toString().trim().equals("")
        || EXECUTION_RESULT.toString().trim().isEmpty()
        || EXECUTION_RESULT.toString().length() == 0) {
      EXECUTION_RESULT = EXECUTION_RESULT + "EXECUTION SUCCESSFUL!";
    }
    return EXECUTION_RESULT;
  }
Exemplo n.º 6
0
  public void logOn2System() {

    userName = this.jTextField1.getText();

    char passsWord[] = this.jPasswordField1.getPassword();

    java.lang.String passWord = java.lang.String.copyValueOf(passsWord);

    pwdInfo = new org.netbeans.lib.sql.PasswordInfo(passWord);

    System.out.println(pwdInfo.getPassword());

    System.out.println(passWord);

    sysProp = System.getProperties();

    sysProp.setProperty("password", passWord);

    System.setProperty("currentuser", userName);

    // java.lang.String dbServerIpAdd = this.getdbServerIpAdd();

    javax.swing.MenuElement[] menuItems = null;

    java.sql.Statement resStatement = null;

    //    javax.swing.JMenuItem menuItem = new javax.swing.JMenuItem;

    if (!userName.equals("") && !passWord.equals("")) {

      try {

        connDB = this.getDbConnection(userName, passWord);

        pconnDB = this.getPooledConnectionSource();

        if (!connDB.equals(null)) {

          System.out.println("Conneted to database successfully");

          resStatement = connDB.createStatement();
        }
        System.out.println("Created statement");

        java.sql.ResultSet reSet =
            resStatement.executeQuery(
                "select menu_item from secure_password where access_priv ='t' AND login_name ='"
                    + userName
                    + "'");

        System.out.println("selected");

        while (reSet.next()) {

          java.lang.reflect.Field[] field;

          try {

            java.lang.Class cl = Class.forName("com.afrisoftech.hr.HRMain");

            field = cl.getDeclaredFields();

            System.out.println("Class loaded");

            for (int j = 0; j < field.length; j++) {

              if (field[j].getName().endsWith("mnit")) {}
            }

          } catch (java.lang.Exception Exc) {

            System.out.println("Error");
          }

          hospitalHRMInst =
              new com.afrisoftech.hr.HRMain(
                  connDB, pconnDB, null, null); // , this.path2Acrobat, this.pwdInfo.getPassword());

          // sysProp.put("hospmain", hospitalInst);

          java.lang.Object[] menuList2enable =
              this.getSystemMenuItems2Enable(this.getMenuItems2Enable(userName));

          hospitalHRMInst.menuItemsDisabler(menuList2enable);

          //   hospitalInst.setSize(java.awt.Toolkit.getDefaultToolkit().getScreenSize());

          hospitalHRMInst.setExtendedState(javax.swing.JFrame.MAXIMIZED_BOTH);
          //                     inventoryInst.setVisible(true);
          hospitalHRMInst.getPath2Acrobat();

          System.out.println(reSet.getString(1));
        }

        // if (mainApp) {

        hospitalHRMInst.setVisible(true);
        this.setVisible(false);

        this.dispose();

        //  }

      } catch (java.sql.SQLException sqlExec) {

        java.awt.Toolkit.getDefaultToolkit().beep();

        sqlExec.printStackTrace();

        javax.swing.JOptionPane.showMessageDialog(this, sqlExec.getMessage());
      }

    } else {

      if (userName.equals("") && passWord.equals("")) {

        java.awt.Toolkit.getDefaultToolkit().beep();

        javax.swing.JOptionPane.showMessageDialog(
            this,
            "Can't have null username" + " and password!",
            "Warning!",
            javax.swing.JOptionPane.WARNING_MESSAGE);
      } else {

        if (userName.equals("") && !passWord.equals("")) {

          java.awt.Toolkit.getDefaultToolkit().beep();

          javax.swing.JOptionPane.showMessageDialog(
              this,
              "Can't have null " + "username!",
              "Warning!",
              javax.swing.JOptionPane.WARNING_MESSAGE);
        } else {
          if (!userName.equals("") && passWord.equals("")) {

            java.awt.Toolkit.getDefaultToolkit().beep();

            javax.swing.JOptionPane.showMessageDialog(
                this,
                "Can't have null " + "password!",
                "Warning!",
                javax.swing.JOptionPane.WARNING_MESSAGE);
          }
        }
      }
    }
  }
 public boolean status() {
   return !mconCon.equals(null);
 }