private void initializePluginAPI(TiWebView webView) {
    try {
      synchronized (this.getClass()) {
        // Initialize
        if (enumPluginStateOff == null) {
          Class<?> webSettings = Class.forName("android.webkit.WebSettings");
          Class<?> pluginState = Class.forName("android.webkit.WebSettings$PluginState");

          Field f = pluginState.getDeclaredField("OFF");
          enumPluginStateOff = (Enum<?>) f.get(null);
          f = pluginState.getDeclaredField("ON");
          enumPluginStateOn = (Enum<?>) f.get(null);
          f = pluginState.getDeclaredField("ON_DEMAND");
          enumPluginStateOnDemand = (Enum<?>) f.get(null);
          internalSetPluginState = webSettings.getMethod("setPluginState", pluginState);
          // Hidden APIs
          // http://android.git.kernel.org/?p=platform/frameworks/base.git;a=blob;f=core/java/android/webkit/WebView.java;h=bbd8b95c7bea66b7060b5782fae4b3b2c4f04966;hb=4db1f432b853152075923499768639e14403b73a#l2558
          internalWebViewPause = webView.getClass().getMethod("onPause");
          internalWebViewResume = webView.getClass().getMethod("onResume");
        }
      }
    } catch (ClassNotFoundException e) {
      Log.e(TAG, "ClassNotFound: " + e.getMessage(), e);
    } catch (NoSuchMethodException e) {
      Log.e(TAG, "NoSuchMethod: " + e.getMessage(), e);
    } catch (NoSuchFieldException e) {
      Log.e(TAG, "NoSuchField: " + e.getMessage(), e);
    } catch (IllegalAccessException e) {
      Log.e(TAG, "IllegalAccess: " + e.getMessage(), e);
    }
  }
  @Override
  public Set<EmpVO> getEmpsByDeptno(Integer deptno) {
    Set<EmpVO> set = new LinkedHashSet<EmpVO>();
    EmpVO empVO = null;

    Connection con = null;
    PreparedStatement pstmt = null;
    ResultSet rs = null;

    try {

      Class.forName(driver);
      con = DriverManager.getConnection(url, userid, passwd);
      pstmt = con.prepareStatement(GET_Emps_ByDeptno_STMT);
      pstmt.setInt(1, deptno);
      rs = pstmt.executeQuery();

      while (rs.next()) {
        empVO = new EmpVO();
        empVO.setEmpno(rs.getInt("empno"));
        empVO.setEname(rs.getString("ename"));
        empVO.setJob(rs.getString("job"));
        empVO.setHiredate(rs.getDate("hiredate"));
        empVO.setSal(rs.getDouble("sal"));
        empVO.setComm(rs.getDouble("comm"));
        empVO.setDeptno(rs.getInt("deptno"));
        set.add(empVO); // Store the row in the vector
      }

      // Handle any driver errors
    } catch (ClassNotFoundException e) {
      throw new RuntimeException("Couldn't load database driver. " + e.getMessage());
      // Handle any SQL errors
    } catch (SQLException se) {
      throw new RuntimeException("A database error occured. " + se.getMessage());
    } finally {
      if (rs != null) {
        try {
          rs.close();
        } catch (SQLException se) {
          se.printStackTrace(System.err);
        }
      }
      if (pstmt != null) {
        try {
          pstmt.close();
        } catch (SQLException se) {
          se.printStackTrace(System.err);
        }
      }
      if (con != null) {
        try {
          con.close();
        } catch (Exception e) {
          e.printStackTrace(System.err);
        }
      }
    }
    return set;
  }
 /** @see org.ow2.proactive.scheduler.common.task.TaskResult#value() */
 public Serializable value() throws Throwable {
   if (hadException()) {
     Throwable thrown = null;
     try {
       thrown = this.instanciateException(this.getTaskClassLoader());
     } catch (IOException e) {
       throw new InternalSchedulerException(
           "Cannot instanciate exception thrown by the task " + this.id + " : " + e.getMessage(),
           e);
     } catch (ClassNotFoundException e) {
       throw new InternalSchedulerException(
           "Cannot instanciate exception thrown by the task " + this.id + " : " + e.getMessage(),
           e);
     }
     throw thrown;
   } else {
     try {
       return this.instanciateValue(this.getTaskClassLoader());
     } catch (IOException e) {
       logger.error("", e);
       throw new InternalSchedulerException(
           "Cannot instanciate result of the task " + this.id + " : " + e.getMessage(), e);
     } catch (ClassNotFoundException e) {
       logger.error("", e);
       throw new InternalSchedulerException(
           "Cannot instanciate result of the task " + this.id + " : " + e.getMessage(), e);
     }
   }
 }
  public static Driver createDriver(ClassLoader classLoader, String driverClassName)
      throws SQLException {
    if (classLoader != null) {
      try {
        return (Driver) classLoader.loadClass(driverClassName).newInstance();
      } catch (IllegalAccessException e) {
        throw new SQLException(e.getMessage(), e);
      } catch (InstantiationException e) {
        throw new SQLException(e.getMessage(), e);
      } catch (ClassNotFoundException e) {
        throw new SQLException(e.getMessage(), e);
      }
    }

    try {
      return (Driver) Class.forName(driverClassName).newInstance();
    } catch (IllegalAccessException e) {
      throw new SQLException(e.getMessage(), e);
    } catch (InstantiationException e) {
      throw new SQLException(e.getMessage(), e);
    } catch (ClassNotFoundException e) {
      // skip
    }

    try {
      return (Driver)
          Thread.currentThread().getContextClassLoader().loadClass(driverClassName).newInstance();
    } catch (IllegalAccessException e) {
      throw new SQLException(e.getMessage(), e);
    } catch (InstantiationException e) {
      throw new SQLException(e.getMessage(), e);
    } catch (ClassNotFoundException e) {
      throw new SQLException(e.getMessage(), e);
    }
  }
Exemple #5
0
 public static Class<?> forName(String className, ClassLoader loader) {
   try {
     return Class.forName(className, true, loader);
   } catch (ClassNotFoundException e) {
     LuiLogger.error(e.getMessage(), e);
     throw new LuiRuntimeException("构造类出错," + e.getMessage());
   }
 }
 public Object retrieve(String sourceObjectName, Serializable id) throws DAOException {
   try {
     return session.load(Class.forName(sourceObjectName), id);
   } catch (ClassNotFoundException cnFoundExp) {
     Logger.out.error(cnFoundExp.getMessage(), cnFoundExp);
     throw new DAOException("Error in retrieve " + cnFoundExp.getMessage(), cnFoundExp);
   } catch (HibernateException hibExp) {
     Logger.out.error(hibExp.getMessage(), hibExp);
     throw new DAOException("Error in retrieve " + hibExp.getMessage(), hibExp);
   }
 }
  static {
    // API Level 11 is Build.VERSION_CODES.HONEYCOMB.
    // When right/left adjustment mode, outInsets uses touchableRegion to cut out IME rectangle.
    // Because only after API.11(HONEYCOMB) supports touchableRegion, filter it.
    InsetsCalculator tmpCalculator = null;
    if (Build.VERSION.SDK_INT >= 11) {
      // Try to create RegsionInsetsCalculator if the API level is high enough.
      try {
        Class<?> clazz =
            Class.forName(
                new StringBuilder(MozcView.class.getCanonicalName())
                    .append('$')
                    .append("RegionInsetsCalculator")
                    .toString());
        tmpCalculator = InsetsCalculator.class.cast(clazz.newInstance());
      } catch (ClassNotFoundException e) {
        MozcLog.e(e.getMessage(), e);
      } catch (IllegalArgumentException e) {
        MozcLog.e(e.getMessage(), e);
      } catch (IllegalAccessException e) {
        MozcLog.e(e.getMessage(), e);
      } catch (InstantiationException e) {
        MozcLog.e(e.getMessage(), e);
      }
    }

    if (tmpCalculator == null) {
      tmpCalculator = new DefaultInsetsCalculator();
    }
    insetsCalculator = tmpCalculator;
  }
  @Override
  public boolean connect() {

    try {

      Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver").newInstance();
      String url =
          "jdbc:sqlserver://"
              + Config.DATABASE_IP
              + ":"
              + Config.DATABASE_PORT
              + ";databaseName=Narda";

      conn = DriverManager.getConnection(url, Config.DATABASE_USERNAME, Config.DATABASE_PASSWORD);
      OrbitStamps.log(OrbitStamps.LOG_NOTICE, "HuddingeDataMapper: connection success!");
      return true;
    } catch (ClassNotFoundException ex) {
      System.err.println(ex.getMessage());
    } catch (IllegalAccessException ex) {
      System.err.println(ex.getMessage());
    } catch (InstantiationException ex) {
      System.err.println(ex.getMessage());
    } catch (SQLException ex) {
      System.err.println(ex.getMessage());
    }

    OrbitStamps.log(OrbitStamps.LOG_NOTICE, "HuddingeDataMapper: connection failed!");
    return false;
  }
Exemple #9
0
 @SuppressWarnings({"unchecked", "rawtypes"})
 private Spell getSpellClass(int id, String name) {
   try {
     Object[] instanceArguments = new Object[] {id};
     Class[] constructorArguments = new Class[] {int.class};
     Class spellClass = Class.forName("com.ignoreourgirth.gary.oakmagic.spells." + name);
     Constructor spellConstructor = spellClass.getConstructor(constructorArguments);
     Object instancedClass = spellConstructor.newInstance(instanceArguments);
     Spell returnValue = (Spell) instancedClass;
     // OakMagic.log.info("Loaded: " + spellClass.getSimpleName());
     return returnValue;
   } catch (ClassNotFoundException ex) {
     OakMagic.log.log(Level.SEVERE, ex.getMessage());
   } catch (InstantiationException ex) {
     OakMagic.log.log(Level.SEVERE, ex.getMessage());
   } catch (IllegalAccessException ex) {
     OakMagic.log.log(Level.SEVERE, ex.getMessage());
   } catch (SecurityException ex) {
     OakMagic.log.log(Level.SEVERE, ex.getMessage());
   } catch (NoSuchMethodException ex) {
     OakMagic.log.log(Level.SEVERE, ex.getMessage());
   } catch (IllegalArgumentException ex) {
     OakMagic.log.log(Level.SEVERE, ex.getMessage());
   } catch (InvocationTargetException ex) {
     OakMagic.log.log(Level.SEVERE, ex.getMessage());
   }
   return null;
 }
 // AQUI VOYA  OBTENER EL SERVDUIOR QUEMADO EN UN ARCHIVO DE TEXTO
 public void conectarBaseDeDatos2() {
   try {
     final String CONTROLADOR = "org.postgresql.Driver";
     Class.forName(CONTROLADOR);
     // System.getProperty( "user.dir" )+"/CarpetaBD/NombredelaBasedeDatos.mdb";
     conexion = DriverManager.getConnection(url2, user, pass);
     sentencia = conexion.createStatement();
     /*JOptionPane.showMessageDialog(null, "si conecta");*/
   } catch (ClassNotFoundException ex1) {
     // ex1.printStackTrace();
     javax.swing.JOptionPane.showMessageDialog(null, "Error Carga Driver." + ex1.getMessage());
     System.exit(1);
   } catch (SQLException ex) {
     // ex.printStackTrace();
     javax.swing.JOptionPane.showMessageDialog(
         null,
         "Error Creacion Statement."
             + ex.getMessage()
             + " / "
             + url2
             + " / "
             + user
             + " / "
             + pass);
     System.exit(1);
   }
 }
  private static void applyGroupMatching(TestNG testng, Map options) throws TestSetFailedException {
    String groups = (String) options.get(ProviderParameterNames.TESTNG_GROUPS_PROP);
    String excludedGroups = (String) options.get(ProviderParameterNames.TESTNG_EXCLUDEDGROUPS_PROP);

    if (groups == null && excludedGroups == null) {
      return;
    }

    // the class is available in the testClassPath
    String clazzName = "org.apache.maven.surefire.testng.utils.GroupMatcherMethodSelector";
    // looks to need a high value
    testng.addMethodSelector(clazzName, 9999);
    try {
      Class clazz = Class.forName(clazzName);

      // HORRIBLE hack, but TNG doesn't allow us to setup a method selector instance directly.
      Method method = clazz.getMethod("setGroups", new Class[] {String.class, String.class});
      method.invoke(null, new Object[] {groups, excludedGroups});
    } catch (ClassNotFoundException e) {
      throw new TestSetFailedException(e.getMessage(), e);
    } catch (SecurityException e) {
      throw new TestSetFailedException(e.getMessage(), e);
    } catch (NoSuchMethodException e) {
      throw new TestSetFailedException(e.getMessage(), e);
    } catch (IllegalArgumentException e) {
      throw new TestSetFailedException(e.getMessage(), e);
    } catch (IllegalAccessException e) {
      throw new TestSetFailedException(e.getMessage(), e);
    } catch (InvocationTargetException e) {
      throw new TestSetFailedException(e.getMessage(), e);
    }
  }
 public static Connection GetConnection() {
   try {
     Class.forName("com.mysql.jdbc.Driver");
     String servidor = "jdbc:mysql://localhost/sugarcrm";
     String usuarioDB = "root";
     String passwordDB = "";
     conexion = DriverManager.getConnection(servidor, usuarioDB, passwordDB);
   } catch (ClassNotFoundException ex) {
     JOptionPane.showMessageDialog(
         null,
         ex,
         "Error1 en la Conexión con la BD " + ex.getMessage(),
         JOptionPane.ERROR_MESSAGE);
     conexion = null;
   } catch (SQLException ex) {
     JOptionPane.showMessageDialog(
         null,
         ex,
         "Error2 en la Conexión con la BD " + ex.getMessage(),
         JOptionPane.ERROR_MESSAGE);
     conexion = null;
   } catch (Exception ex) {
     JOptionPane.showMessageDialog(
         null,
         ex,
         "Error3 en la Conexión con la BD " + ex.getMessage(),
         JOptionPane.ERROR_MESSAGE);
     conexion = null;
   } finally {
     return conexion;
   }
 }
 /**
  * Stringly typed method for those who mistakenly describe their programming style as dynamic.
  *
  * @param className class to get
  * @return class instance (assuming you can spell and concatenate strings correctly)
  */
 public Object getInstance(String className) {
   try {
     return getInstance(Class.forName(className));
   } catch (ClassNotFoundException e) {
     throw new IllegalArgumentException(e.getMessage());
   }
 }
 static Class class$(String var0) {
   try {
     return Class.forName(var0);
   } catch (ClassNotFoundException var2) {
     throw new NoClassDefFoundError(var2.getMessage());
   }
 }
  private static String getFilePathByFileDialog(Shell shell, boolean isExport, String fileName) {
    try {
      final Class<EMFStoreFileDialogHelper> clazz =
          loadClass(EMFSTORE_CLIENT_UI_PLUGIN_ID, FILE_DIALOG_HELPER_CLASS);
      final EMFStoreFileDialogHelper fileDialogHelper = clazz.getConstructor().newInstance();

      if (isExport) {
        return fileDialogHelper.getPathForExport(shell, fileName);
      }

      return fileDialogHelper.getPathForImport(shell);
    } catch (final ClassNotFoundException ex) {
      WorkspaceUtil.logException(ex.getMessage(), ex);
    } catch (final InstantiationException ex) {
      WorkspaceUtil.logException(ex.getMessage(), ex);
    } catch (final IllegalAccessException ex) {
      WorkspaceUtil.logException(ex.getMessage(), ex);
    } catch (final IllegalArgumentException ex) {
      WorkspaceUtil.logException(ex.getMessage(), ex);
    } catch (final InvocationTargetException ex) {
      WorkspaceUtil.logException(ex.getMessage(), ex);
    } catch (final NoSuchMethodException ex) {
      WorkspaceUtil.logException(ex.getMessage(), ex);
    } catch (final SecurityException ex) {
      WorkspaceUtil.logException(ex.getMessage(), ex);
    }
    return null;
  }
  public static List<Star> findClosestKStars(int k, ObjectInputStream osin) {
    // maxHeap to store the closest k stars seen so far.
    PriorityQueue<Star> maxHeap = new PriorityQueue<>(k, Collections.reverseOrder());
    try {
      while (true) {
        // Add each star to the max-heap. If the max-heap size exceeds k,
        // remove the maximum element from the max-heap.
        Star star = (Star) osin.readObject();
        maxHeap.add(star);
        if (maxHeap.size() == k + 1) {
          maxHeap.remove();
        }
      }
    } catch (IOException e) {
      // Do nothing, read last element in stream.
    } catch (ClassNotFoundException e) {
      System.out.println("ClassNotFoundException: " + e.getMessage());
    }

    // We cannot go directly to an ArrayList from PriorityQueue, since
    // unlike LinkedList, it does not guarantee ordering of entries.
    List<Star> orderedStars = new ArrayList<Star>(maxHeap);
    // We need to reverse the orderedStars list since it goes from
    // largest to smallest because the PriorityQueue used the
    // Collections.reverse() comparator.
    Collections.reverse(orderedStars);
    return orderedStars;
  }
  public Connection getConexionTango() throws DataStoreException {

    if (_connTango == null) {
      _p = Props.getProps("partesMO", null);
      _driverTango = _p.getProperty("driverTango", "sun.jdbc.odbc.JdbcOdbcDriver");
      _urlTango = _p.getProperty("urlTango", "jdbc:odbc:tango");
      _userTango = _p.getProperty("userTango", "tango");
      _passWordTango = _p.getProperty("passWordTango", "tango");

      try {
        // Se carga el driver JDBC-ODBC
        Class.forName(_driverTango);
      } catch (ClassNotFoundException e) {
        MessageLog.writeErrorMessage(e, null);
        throw new DataStoreException("Imposible cargar el driver para Tango: " + e.getMessage());
      }

      try {
        // Se establece la conexión con la base de datos
        _connTango = DriverManager.getConnection(_urlTango, _userTango, _passWordTango);
      } catch (Exception e) {
        MessageLog.writeErrorMessage(e, null);
        throw new DataStoreException(
            "imposible establecer conexión con la base tango: " + e.getMessage());
      }
    }

    return _connTango;
  }
Exemple #18
0
  private void update(AjaxRequestTarget target) {
    JCas jCas = null;
    try {
      CuratorUtil.updatePanel(
          target,
          automateView,
          curationContainer,
          mergeVisualizer,
          repository,
          annotationSelectionByUsernameAndAddress,
          curationSegment,
          annotationService,
          userRepository);

      jCas = repository.readCorrectionCas(bModel.getDocument());
    } catch (UIMAException e) {
      error(ExceptionUtils.getRootCauseMessage(e));
    } catch (ClassNotFoundException e) {
      error(e.getMessage());
    } catch (IOException e) {
      error(e.getMessage());
    } catch (BratAnnotationException e) {
      error(e.getMessage());
    }

    gotoPageTextField.setModelObject(getFirstSentenceNumber(jCas, bModel.getSentenceAddress()) + 1);
    gotoPageAddress = getSentenceAddress(jCas, gotoPageTextField.getModelObject());

    target.add(gotoPageTextField);
    target.add(automateView);
    target.add(numberOfPages);
  }
  public void conectarBaseDeDatos() {
    try {
      final String CONTROLADOR = "org.postgresql.Driver";
      Class.forName(CONTROLADOR);
      // System.getProperty( "user.dir" )+"/CarpetaBD/NombredelaBasedeDatos.mdb";
      conexion =
          DriverManager.getConnection(
              "jdbc:postgresql://" + main.ipSeleccionada + "/" + objUtils.nameBD, user, pass);
      // conexion = DriverManager.getConnection("jdbc:postgresql://127.0.0.1/goliak_jg", "postgres",
      // "majcp071102kaiser");

      sentencia = conexion.createStatement();
      /*JOptionPane.showMessageDialog(null, "si conecta");*/
    } catch (ClassNotFoundException ex1) {
      // ex1.printStackTrace();
      javax.swing.JOptionPane.showMessageDialog(null, "Error Carga Driver." + ex1.getMessage());
      System.exit(1);
    } catch (SQLException ex) {
      // ex.printStackTrace();
      javax.swing.JOptionPane.showMessageDialog(
          null,
          "Error Creacion Statement."
              + ex.getMessage()
              + " / "
              + url
              + " / "
              + user
              + " / "
              + pass);
      System.exit(1);
    }
  }
 /* (non-Javadoc)
  * @see model.dao.IDataModel#insert()
  */
 @Override
 public Long insert() throws SQLException {
   try {
     Class.forName(Settings.DATABASE_JDBC_CLASSNAME);
   } catch (ClassNotFoundException e) {
     System.err.println("ClassNotFoundException: " + e.getMessage());
     e.printStackTrace();
   }
   Connection conn;
   PreparedStatement statement;
   try {
     conn = SQLiteManager.getInstance().getConnection();
     String sql =
         "INSERT INTO account_entries (account_id, booked_document_id, text, amount, created_time)"
             + " VALUES (?,          ?,                  ?,    ?,      ?)";
     statement = conn.prepareStatement(sql);
     statement.setLong(1, getAccount().getId());
     statement.setLong(2, bookedDocument.getId());
     statement.setString(3, text);
     statement.setDouble(4, amount);
     statement.setString(5, util.Date.toSqlTimeString(Calendar.getInstance().getTime()));
     statement.execute();
     sql = "SELECT last_insert_rowid()";
     ResultSet resultSet = conn.createStatement().executeQuery(sql);
     if (resultSet.next()) id = resultSet.getLong(1);
     else throw new SQLException("unable to fetch insert-id");
     resultSet.close();
   } catch (SQLException e) {
     System.err.println("SQLException: " + e.getMessage());
     e.printStackTrace();
   }
   return id;
 }
  private Object readValueFromDisk(InputStream is) throws IOException {
    BufferedReader fss = new BufferedReader(new InputStreamReader(is, "UTF-8"));
    String className = fss.readLine();

    if (className == null) {
      return null;
    }

    String line = null;
    String content = "";
    while ((line = fss.readLine()) != null) {
      content += line;
    }

    fss.close();

    Class<?> clazz;
    try {
      if (className.contains("google")) {
        clazz = Class.forName(className);
        return mJsonFactory.createJsonParser(content).parseAndClose(clazz, null);
      } else {
        clazz = Class.forName(className);
        return mGson.fromJson(content, clazz);
      }
    } catch (IllegalArgumentException e) {
      Timber.e("Deserializing from disk failed", e);
      return null;
    } catch (ClassNotFoundException e) {
      throw new IOException(e.getMessage());
    }
  }
Exemple #22
0
  @Override
  public void delete(Integer deptno) {
    int updateCount_EMPs = 0;

    Connection con = null;
    PreparedStatement pstmt = null;

    try {

      Class.forName(driver);
      con = DriverManager.getConnection(url, userid, passwd);

      // 1●設定於 pstm.executeUpdate()之前
      con.setAutoCommit(false);

      // 先刪除員工
      pstmt = con.prepareStatement(DELETE_EMPs);
      pstmt.setInt(1, deptno);
      updateCount_EMPs = pstmt.executeUpdate();
      // 再刪除部門
      pstmt = con.prepareStatement(DELETE_DEPT);
      pstmt.setInt(1, deptno);
      pstmt.executeUpdate();

      // 2●設定於 pstm.executeUpdate()之後
      con.commit();
      con.setAutoCommit(true);
      System.out.println("刪除部門編號" + deptno + "時,共有員工" + updateCount_EMPs + "人同時被刪除");

      // Handle any driver errors
    } catch (ClassNotFoundException e) {
      throw new RuntimeException("Couldn't load database driver. " + e.getMessage());
      // Handle any SQL errors
    } catch (SQLException se) {
      if (con != null) {
        try {
          // 3●設定於當有exception發生時之catch區塊內
          con.rollback();
        } catch (SQLException excep) {
          throw new RuntimeException("rollback error occured. " + excep.getMessage());
        }
      }
      throw new RuntimeException("A database error occured. " + se.getMessage());
    } finally {
      if (pstmt != null) {
        try {
          pstmt.close();
        } catch (SQLException se) {
          se.printStackTrace(System.err);
        }
      }
      if (con != null) {
        try {
          con.close();
        } catch (Exception e) {
          e.printStackTrace(System.err);
        }
      }
    }
  }
  public static AgentLauncher makeAgentLauncher(
      String launcherClass,
      AbstractMadkitBooter booter,
      String type,
      String className,
      String label,
      String typeArg,
      Object arg,
      boolean gui,
      Point p,
      Dimension d) {
    try {
      Class cl = Utils.loadClass(launcherClass);
      AgentLauncher agentLauncher = (AgentLauncher) cl.newInstance();
      agentLauncher.init(booter, type, className, label, typeArg, arg, new Boolean(gui), p, d);

      return agentLauncher;
    } catch (ClassNotFoundException ex) {
      System.err.println("Agent class does not exist:" + ex.getMessage());
    } catch (Exception ccex) {
      System.err.println("Agent launch exception:\n");
      ccex.printStackTrace();
    }
    return null;
  }
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    int id = Integer.valueOf(request.getParameter("id"));

    Connection conexao = null;
    try {
      conexao = AbstractConnectionFactory.getConexao();
      OrcamentoDao orcamentoDao = new OrcamentoDao(conexao);
      orcamentoDao.excluirOrcamento(id);

      write(response, "Orcamento excluido com sucesso");

    } catch (ClassNotFoundException e) {
      e.printStackTrace();
      write(response, "ERRO codigo CNFE10 " + e.getMessage());
    } catch (SQLException e) {
      e.printStackTrace();
      write(response, "ERRO codigo SQLE10 " + e.getMessage());
    } finally {
      try {
        conexao.close();
      } catch (SQLException e) {
        e.printStackTrace();
        write(response, "ERRO codigo SQLE10 " + e.getMessage());
      }
    }
  }
Exemple #25
0
 /*synthetic*/ public static Class method1623(String string) {
   try {
     return Class.forName(string);
   } catch (ClassNotFoundException classnotfoundexception) {
     throw new NoClassDefFoundError(classnotfoundexception.getMessage());
   }
 }
  /** Get new PHYSICAL connection, to be managed by a connection manager. */
  public XAConnection getXAConnection() throws SQLException {

    // Comment out before public release:
    System.err.print("Executing " + getClass().getName() + ".getXAConnection()...");

    try {
      Class.forName(driver).newInstance();
    } catch (ClassNotFoundException e) {
      throw new SQLException("Error opening connection: " + e.getMessage());
    } catch (IllegalAccessException e) {
      throw new SQLException("Error opening connection: " + e.getMessage());
    } catch (InstantiationException e) {
      throw new SQLException("Error opening connection: " + e.getMessage());
    }

    JDBCConnection connection = (JDBCConnection) DriverManager.getConnection(url, connProperties);

    // Comment out before public release:
    System.err.print("New phys:  " + connection);

    JDBCXAResource xaResource = new JDBCXAResource(connection, this);
    JDBCXAConnectionWrapper xaWrapper =
        new JDBCXAConnectionWrapper(connection, xaResource, connectionDefaults);
    JDBCXAConnection xaConnection = new JDBCXAConnection(xaWrapper, xaResource);

    xaWrapper.setPooledConnection(xaConnection);

    return xaConnection;
  }
  private static void applyMethodNameFiltering(TestNG testng, String methodNamePattern)
      throws TestSetFailedException {
    // the class is available in the testClassPath
    String clazzName = "org.apache.maven.surefire.testng.utils.MethodSelector";
    // looks to need a high value
    testng.addMethodSelector(clazzName, 10000);
    try {
      Class clazz = Class.forName(clazzName);

      Method method = clazz.getMethod("setMethodName", new Class[] {String.class});
      method.invoke(null, new Object[] {methodNamePattern});
    } catch (ClassNotFoundException e) {
      throw new TestSetFailedException(e.getMessage(), e);
    } catch (SecurityException e) {
      throw new TestSetFailedException(e.getMessage(), e);
    } catch (NoSuchMethodException e) {
      throw new TestSetFailedException(e.getMessage(), e);
    } catch (IllegalArgumentException e) {
      throw new TestSetFailedException(e.getMessage(), e);
    } catch (IllegalAccessException e) {
      throw new TestSetFailedException(e.getMessage(), e);
    } catch (InvocationTargetException e) {
      throw new TestSetFailedException(e.getMessage(), e);
    }
  }
Exemple #28
0
  public static void main(String[] args) {
    try {
      Class.forName("com.mysql.jdbc.Driver");
      // Connection conexion =
      // DriverManager.getConnection("jdbc:mysql://192.168.0.60:3306/juancarlos", "santi", "santi");
      Connection conexion =
          DriverManager.getConnection("jdbc:mysql://192.168.0.60:3306/mydb", "santi", "santi");
      Statement consulta = conexion.createStatement();

      ResultSet resultado;

      resultado = consulta.executeQuery("select * from persona");

      while (resultado.next()) {
        String nombre = resultado.getString("nombre");
        String apellidos = resultado.getString("direccion");
        int edad = resultado.getInt("edad");
        System.out.println(nombre + " - " + apellidos + " - Edad: " + edad);
      }

    } catch (ClassNotFoundException e) {
      System.out.println("No he encontrado la clase error: " + e.getMessage());
    } catch (SQLException e) {
      System.out.println("No se puede conectar a la base de datos error: " + e.getMessage());
    }
  }
  public void pendientesClaro() throws Exception {
    Connection connPostgres = null;
    String query;

    try {
      // Parámetros de conexión con Postgres
      try {
        Class.forName("org.postgresql.Driver");
      } catch (ClassNotFoundException e) {
        System.out.println("No se encuentra el Driver: " + e.getMessage());
      }
      String username = "******";
      String password = "";
      String url = "jdbc:postgresql://localhost:5432/multipagos";
      connPostgres = DriverManager.getConnection(url, username, password);

      corregirClaroDep();

      query = "drop table tmp_claro_dpts;";
      ejecutarQuery(connPostgres, query);

      query =
          "select	b.departamento_id, a.* "
              + "into	tmp_claro_dpts "
              + "from 	tmp_carteraclaro a "
              + "left 	outer join departamento b on upper(rtrim(ltrim(a.departamento))) = upper(rtrim(ltrim(b.departamento_nombre))) "
              + "ORDER BY 1;";
      ejecutarQuery(connPostgres, query);

      query =
          "select a.* into tmp_claro_dpts_2 from cartera_x_departamento a where departamento_id in (select departamento_id from tmp_claro_dpts);";
      ejecutarQuery(connPostgres, query);

      query =
          "delete from tmp_claro_dpts_2 where factura_interna in (select factura_interna from tmp_claro_dpts);";
      ejecutarQuery(connPostgres, query);

      query =
          "update cartera_x_departamento set pagado_claro=true where factura_interna in (select factura_interna from tmp_claro_dpts_2);";
      ejecutarQuery(connPostgres, query);

      query = "drop table tmp_claro_dpts_2;";
      ejecutarQuery(connPostgres, query);

      query = "drop table tmp_claro_dpts;";
      ejecutarQuery(connPostgres, query);

      // return cantidad;

    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      try {
        if (connPostgres != null) connPostgres.close();
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
    // return 0;
  }
    static
    {
	// The default allowUserAction in java.net.URLConnection is
	// false.
	try
	{
	    if (Boolean.getBoolean("HTTPClient.HttpURLConnection.AllowUI"))
		setDefaultAllowUserInteraction(true);
	}
	catch (SecurityException se)
	    { }

	// get the RedirectionModule class
	try
	    { redir_mod = Class.forName("HTTPClient.RedirectionModule"); }
	catch (ClassNotFoundException cnfe)
	    { throw new NoClassDefFoundError(cnfe.getMessage()); }

	// Set the User-Agent if the http.agent property is set
	try
	{
	    String agent = System.getProperty("http.agent");
	    if (agent != null)
		setDefaultRequestProperty("User-Agent", agent);
	}
	catch (SecurityException se)
	    { }
    }