コード例 #1
0
  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);
    }
  }
コード例 #2
0
  public void conectarBDdinamic(String ip) {

    if (ip == null) {
      ip = "192.168.8.231";
    }
    url = "jdbc:postgresql://" + ip + "/ventasalm";
    // javax.swing.JOptionPane.showMessageDialog(null, url);
    String estado;
    try {

      final String CONTROLADOR = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
      Class.forName(CONTROLADOR);
      // System.getProperty( "user.dir" )+"/CarpetaBD/NombredelaBasedeDatos.mdb";
      conexion = DriverManager.getConnection(url, user, pass);
      sentencia = conexion.createStatement();
      // estado="Conectado Correctamente";
    } catch (ClassNotFoundException ex1) {
      ex1.printStackTrace();
      javax.swing.JOptionPane.showMessageDialog(null, "Error Carga Driver");
      estado = "Servidor no esta disponible";
      // System.exit(1);
    } catch (SQLException ex) {
      ex.printStackTrace();
      javax.swing.JOptionPane.showMessageDialog(null, "Error Creacion Statement");
      estado = "Servidor no esta disponible";
      // System.exit(1);
    }
    // return estado;
  }
コード例 #3
0
 // 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);
   }
 }
コード例 #4
0
 public static void main(String[] args) {
   // Ouverture d'un flux de lecture sur le fichier utilisateurs.xml
   try (InputStream fluxLecture = new FileInputStream("utilisateurs.xml")) {
     // Analyse des utilisateurs du document XML
     AnalyseurXMLForum analyseurXML = new AnalyseurXMLForum();
     Set<Utilisateur> utilisateurs = analyseurXML.lireUtilisateursXML(fluxLecture);
     // Construction d'un texte avec tous les utilisateurs trouves
     String texte = "";
     for (Utilisateur utilisateur : utilisateurs) texte += "\u25cf " + utilisateur + "\n";
     javax.swing.JOptionPane.showMessageDialog(null, texte);
   } catch (IOException ex) {
     javax.swing.JOptionPane.showMessageDialog(null, ex);
   }
 }
コード例 #5
0
ファイル: MainJVM.java プロジェクト: jonathansharman/drjava
  /** Call invokeSlave with the appropriate JVMBuilder. */
  private void _doStartup() {
    File dir = _workingDir;
    // TODO: Eliminate NULL_FILE.  It is a bad idea!  The correct behavior when it is used always
    // depends on
    // context, so it can never be treated transparently.  In this case, the process won't start.
    if (dir == FileOps.NULL_FILE) {
      dir = IOUtil.WORKING_DIRECTORY;
    }

    List<String> jvmArgs = new ArrayList<String>();

    // ConcJUnit argument: -Xbootclasspath/p:rt.concjunit.jar
    // ------------------------------------------------------
    // this section here loops if the rt.concjunit.jar file is
    // being re-generated or the settings are changed
    final CompletionMonitor cm = new CompletionMonitor();
    boolean repeat;
    do {
      repeat = false;
      File junitLocation = DrJava.getConfig().getSetting(OptionConstants.JUNIT_LOCATION);
      boolean javaVersion7 = JavaVersion.CURRENT.supports(JavaVersion.JAVA_7);
      // ConcJUnit is available if (a) the built-in framework is used, or (b) the external
      // framework is a valid ConcJUnit jar file, AND the compiler is not Java 7 or newer.
      boolean concJUnitAvailable =
          !javaVersion7
              && (!DrJava.getConfig().getSetting(OptionConstants.JUNIT_LOCATION_ENABLED)
                  || edu.rice.cs.drjava.model.junit.ConcJUnitUtils.isValidConcJUnitFile(
                      junitLocation));

      File rtLocation = DrJava.getConfig().getSetting(OptionConstants.RT_CONCJUNIT_LOCATION);
      boolean rtLocationConfigured =
          edu.rice.cs.drjava.model.junit.ConcJUnitUtils.isValidRTConcJUnitFile(rtLocation);

      if (DrJava.getConfig()
              .getSetting(OptionConstants.CONCJUNIT_CHECKS_ENABLED)
              .equals(OptionConstants.ConcJUnitCheckChoices.ALL)
          && // "lucky" enabled
          !rtLocationConfigured
          && // not valid
          (rtLocation != null)
          && // not null
          (!FileOps.NULL_FILE.equals(rtLocation))
          && // not NULL_FILE
          (rtLocation.exists())) { // but exists
        // invalid file, clear setting
        DrJava.getConfig()
            .setSetting(
                OptionConstants.CONCJUNIT_CHECKS_ENABLED,
                OptionConstants.ConcJUnitCheckChoices.NO_LUCKY);
        rtLocationConfigured = false;
        javax.swing.JOptionPane.showMessageDialog(
            null,
            "The selected file is invalid and was disabled:\n" + rtLocation,
            "Invalid ConcJUnit Runtime File",
            javax.swing.JOptionPane.ERROR_MESSAGE);
      }
      if (concJUnitAvailable
          && // ConcJUnit available
          rtLocationConfigured
          && // runtime configured
          DrJava.getConfig()
              .getSetting(OptionConstants.CONCJUNIT_CHECKS_ENABLED)
              .equals(OptionConstants.ConcJUnitCheckChoices.ALL)) { // and "lucky" enabled
        try {
          // NOTE: this is a work-around
          // it seems like it's impossible to pass long file names here on Windows
          // so we are using a clumsy method that determines the short file name
          File shortF = FileOps.getShortFile(rtLocation);

          // check the JavaVersion of the rt.concjunit.jar file to make sure it is compatible
          if (edu.rice.cs.drjava.model.junit.ConcJUnitUtils.isCompatibleRTConcJUnitFile(shortF)) {
            // enabled, valid and compatible
            // add the JVM argument
            jvmArgs.add(
                "-Xbootclasspath/p:" + shortF.getAbsolutePath().replace(File.separatorChar, '/'));
          } else {
            // enabled, valid but incompatible
            // ask to regenerate
            repeat = true; // re-check settings
            cm.reset();
            boolean attempted =
                edu.rice.cs.drjava.model.junit.ConcJUnitUtils
                    .showIncompatibleWantToRegenerateDialog(
                        null,
                        new Runnable() {
                          public void run() {
                            cm.signal();
                          }
                        }, // yes
                        new Runnable() {
                          public void run() {
                            cm.signal();
                          }
                        }); // no
            while (!cm.attemptEnsureSignaled()) ; // wait for dialog to finish
            if (!attempted) {
              repeat = false;
            }
          }
        } catch (IOException ioe) {
          // we couldn't get the short file name (on Windows), disable "lucky" warnings
          DrJava.getConfig()
              .setSetting(
                  OptionConstants.CONCJUNIT_CHECKS_ENABLED,
                  OptionConstants.ConcJUnitCheckChoices.NO_LUCKY);
          rtLocationConfigured = false;
          javax.swing.JOptionPane.showMessageDialog(
              null,
              "There was a problem with the selected file, and it was disabled:\n" + rtLocation,
              "Invalid ConcJUnit Runtime File",
              javax.swing.JOptionPane.ERROR_MESSAGE);
        }
      }
    } while (repeat);
    // end of the section that may loop
    // ------------------------------------------------------

    if (_allowAssertions) {
      jvmArgs.add("-ea");
    }
    int debugPort = _getDebugPort();
    if (debugPort > -1) {
      jvmArgs.add("-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=" + debugPort);
      jvmArgs.add("-Xdebug");
      jvmArgs.add("-Xnoagent");
      jvmArgs.add("-Djava.compiler=NONE");
    }
    String slaveMemory = DrJava.getConfig().getSetting(OptionConstants.SLAVE_JVM_XMX);
    if (!"".equals(slaveMemory) && !OptionConstants.heapSizeChoices.get(0).equals(slaveMemory)) {
      jvmArgs.add("-Xmx" + slaveMemory + "M");
    }
    String slaveArgs = DrJava.getConfig().getSetting(OptionConstants.SLAVE_JVM_ARGS);
    if (PlatformFactory.ONLY.isMacPlatform()) {
      jvmArgs.add("-Xdock:name=Interactions");
    }

    // add additional boot class path items specified by the selected compiler
    for (File f : _interactionsModel.getCompilerBootClassPath()) {
      try {
        // NOTE: this is a work-around
        // it seems like it's impossible to pass long file names here on Windows
        // so we are using a clumsy method that determines the short file name
        File shortF = FileOps.getShortFile(f);
        jvmArgs.add(
            "-Xbootclasspath/a:" + shortF.getAbsolutePath().replace(File.separatorChar, '/'));
      } catch (IOException ioe) {
        // TODO: figure out what to do here. error? warn?
      }
    }

    jvmArgs.addAll(ArgumentTokenizer.tokenize(slaveArgs));

    JVMBuilder jvmb = new JVMBuilder(_startupClassPath).directory(dir).jvmArguments(jvmArgs);

    // extend classpath if JUnit/ConcJUnit location specified
    File junitLocation = DrJava.getConfig().getSetting(OptionConstants.JUNIT_LOCATION);
    boolean junitLocationConfigured =
        (edu.rice.cs.drjava.model.junit.ConcJUnitUtils.isValidJUnitFile(junitLocation)
            || edu.rice.cs.drjava.model.junit.ConcJUnitUtils.isValidConcJUnitFile(junitLocation));
    if (DrJava.getConfig().getSetting(OptionConstants.JUNIT_LOCATION_ENABLED)
        && // enabled
        !junitLocationConfigured
        && // not valid
        (junitLocation != null)
        && // not null
        (!FileOps.NULL_FILE.equals(junitLocation))
        && // not NULL_FILE
        (junitLocation.exists())) { // but exists
      // invalid file, clear setting
      DrJava.getConfig().setSetting(OptionConstants.JUNIT_LOCATION_ENABLED, false);
      junitLocationConfigured = false;
    }
    ArrayList<File> extendedClassPath = new ArrayList<File>();
    if (DrJava.getConfig().getSetting(OptionConstants.JUNIT_LOCATION_ENABLED)
        && junitLocationConfigured) {
      extendedClassPath.add(junitLocation);
    }
    for (File f : jvmb.classPath()) {
      extendedClassPath.add(f);
    }
    jvmb = jvmb.classPath(edu.rice.cs.plt.iter.IterUtil.asSizedIterable(extendedClassPath));

    // add Java properties controlling ConcJUnit
    Map<String, String> props = jvmb.propertiesCopy();

    // settings are mutually exclusive
    boolean all =
        DrJava.getConfig()
            .getSetting(OptionConstants.CONCJUNIT_CHECKS_ENABLED)
            .equals(OptionConstants.ConcJUnitCheckChoices.ALL);
    boolean noLucky =
        DrJava.getConfig()
            .getSetting(OptionConstants.CONCJUNIT_CHECKS_ENABLED)
            .equals(OptionConstants.ConcJUnitCheckChoices.NO_LUCKY);
    boolean none =
        DrJava.getConfig()
            .getSetting(OptionConstants.CONCJUNIT_CHECKS_ENABLED)
            .equals(OptionConstants.ConcJUnitCheckChoices.NONE);
    // "threads" is enabled as long as the setting isn't NONE
    props.put("edu.rice.cs.cunit.concJUnit.check.threads.enabled", new Boolean(!none).toString());
    // "join" is enabled for ALL and NO_LUCKY
    props.put(
        "edu.rice.cs.cunit.concJUnit.check.join.enabled", new Boolean(all || noLucky).toString());
    // "lucky" is enabled only for ALL
    props.put("edu.rice.cs.cunit.concJUnit.check.lucky.enabled", new Boolean(all).toString());

    jvmb = jvmb.properties(props);

    invokeSlave(jvmb);
  }
コード例 #6
0
ファイル: ImageJ.java プロジェクト: chrisp87/ImageJA
 public static void main(String args[]) {
   if (System.getProperty("java.version").substring(0, 3).compareTo("1.5") < 0) {
     javax.swing.JOptionPane.showMessageDialog(
         null, "ImageJ " + VERSION + " requires Java 1.5 or later.");
     System.exit(0);
   }
   boolean noGUI = false;
   int mode = STANDALONE;
   arguments = args;
   // System.setProperty("file.encoding", "UTF-8");
   int nArgs = args != null ? args.length : 0;
   boolean commandLine = false;
   for (int i = 0; i < nArgs; i++) {
     String arg = args[i];
     if (arg == null) continue;
     if (args[i].startsWith("-")) {
       if (args[i].startsWith("-batch")) noGUI = true;
       else if (args[i].startsWith("-debug")) IJ.setDebugMode(true);
       else if (args[i].startsWith("-ijpath") && i + 1 < nArgs) {
         if (IJ.debugMode) IJ.log("-ijpath: " + args[i + 1]);
         Prefs.setHomeDir(args[i + 1]);
         commandLine = true;
         args[i + 1] = null;
       } else if (args[i].startsWith("-port")) {
         int delta = (int) Tools.parseDouble(args[i].substring(5, args[i].length()), 0.0);
         commandLine = true;
         if (delta == 0) mode = EMBEDDED;
         else if (delta > 0 && DEFAULT_PORT + delta < 65536) port = DEFAULT_PORT + delta;
       }
     }
   }
   // If existing ImageJ instance, pass arguments to it and quit.
   boolean passArgs = mode == STANDALONE && !noGUI;
   if (IJ.isMacOSX() && !commandLine) passArgs = false;
   if (passArgs && isRunning(args)) return;
   ImageJ ij = IJ.getInstance();
   if (!noGUI && (ij == null || (ij != null && !ij.isShowing()))) {
     ij = new ImageJ(null, mode);
     ij.exitWhenQuitting = true;
   }
   int macros = 0;
   for (int i = 0; i < nArgs; i++) {
     String arg = args[i];
     if (arg == null) continue;
     if (arg.startsWith("-")) {
       if ((arg.startsWith("-macro") || arg.startsWith("-batch")) && i + 1 < nArgs) {
         String arg2 = i + 2 < nArgs ? args[i + 2] : null;
         Prefs.commandLineMacro = true;
         if (noGUI && args[i + 1].endsWith(".js")) Interpreter.batchMode = true;
         IJ.runMacroFile(args[i + 1], arg2);
         break;
       } else if (arg.startsWith("-eval") && i + 1 < nArgs) {
         String rtn = IJ.runMacro(args[i + 1]);
         if (rtn != null) System.out.print(rtn);
         args[i + 1] = null;
       } else if (arg.startsWith("-run") && i + 1 < nArgs) {
         IJ.run(args[i + 1]);
         args[i + 1] = null;
       }
     } else if (macros == 0 && (arg.endsWith(".ijm") || arg.endsWith(".txt"))) {
       IJ.runMacroFile(arg);
       macros++;
     } else if (arg.length() > 0 && arg.indexOf("ij.ImageJ") == -1) {
       File file = new File(arg);
       IJ.open(file.getAbsolutePath());
     }
   }
   if (IJ.debugMode && IJ.getInstance() == null) new JavaProperties().run("");
   if (noGUI) System.exit(0);
 }
コード例 #7
0
  /** The run method. */
  public void run() {
    instances.add(this);
    try {
      listener.startUnpack();
      String currentOs = System.getProperty("os.name").toLowerCase();
      //
      // Initialisations
      FileOutputStream out = null;
      ArrayList parsables = new ArrayList();
      ArrayList executables = new ArrayList();
      List packs = idata.selectedPacks;
      int npacks = packs.size();
      udata = UninstallData.getInstance();

      // Specific to the web installers
      if (idata.kind.equalsIgnoreCase("web") || idata.kind.equalsIgnoreCase("web-kunststoff")) {
        InputStream kin = getClass().getResourceAsStream("/res/WebInstallers.url");
        BufferedReader kreader = new BufferedReader(new InputStreamReader(kin));
        jarLocation = kreader.readLine();
      }

      // We unpack the selected packs
      for (int i = 0; i < npacks; i++) {
        // We get the pack stream
        int n = idata.allPacks.indexOf(packs.get(i));
        ObjectInputStream objIn = new ObjectInputStream(getPackAsStream(n));

        // We unpack the files
        int nfiles = objIn.readInt();
        listener.changeUnpack(0, nfiles, ((Pack) packs.get(i)).name);
        for (int j = 0; j < nfiles; j++) {
          // We read the header
          PackFile pf = (PackFile) objIn.readObject();
          if (null == pf.os || matchOS(currentOs, pf.os.toLowerCase())) {
            // We translate & build the path
            String path = translatePath(pf.targetPath);
            File pathFile = new File(path);
            String fname = pathFile.getName();
            int z = fname.length();
            File dest = pathFile.getParentFile();
            if (!dest.exists()) dest.mkdirs();

            // We add the path to the log,
            udata.addFile(path);

            listener.progressUnpack(j, path);

            // if this file exists and shouldnot override skip this file
            if (((pf.override == false) && (pathFile.exists()))) {
              objIn.skip(pf.length);
              continue;
            }

            // We copy the file
            out = new FileOutputStream(path);
            byte[] buffer = new byte[5120];
            long bytesCopied = 0;
            while (bytesCopied < pf.length) {
              int maxBytes =
                  (pf.length - bytesCopied < buffer.length
                      ? (int) (pf.length - bytesCopied)
                      : buffer.length);
              int bytesInBuffer = objIn.read(buffer, 0, maxBytes);
              if (bytesInBuffer == -1) throw new IOException("Unexpected end of stream");

              out.write(buffer, 0, bytesInBuffer);

              bytesCopied += bytesInBuffer;
            }
            // Cleanings
            out.close();

            // Empty dirs restoring
            String _n = pathFile.getName();
            if (_n.startsWith("izpack-keepme") && _n.endsWith(".tmp")) pathFile.delete();

          } else objIn.skip(pf.length);
        }

        // Load information about parsable files
        int numParsables = objIn.readInt();
        int k;
        for (k = 0; k < numParsables; k++) {
          ParsableFile pf = (ParsableFile) objIn.readObject();
          pf.path = translatePath(pf.path);
          parsables.add(pf);
        }

        // Load information about executable files
        int numExecutables = objIn.readInt();
        for (k = 0; k < numExecutables; k++) {
          ExecutableFile ef = (ExecutableFile) objIn.readObject();
          ef.path = translatePath(ef.path);
          if (null != ef.argList && !ef.argList.isEmpty()) {
            String arg = null;
            for (int j = 0; j < ef.argList.size(); j++) {
              arg = (String) ef.argList.get(j);
              arg = translatePath(arg);
              ef.argList.set(j, arg);
            }
          }
          executables.add(ef);
          if (ef.executionStage == ExecutableFile.UNINSTALL) {
            udata.addExecutable(ef);
          }
        }
        objIn.close();
      }

      // We use the scripts parser
      ScriptParser parser = new ScriptParser(parsables, vs);
      parser.parseFiles();

      // We use the file executor
      FileExecutor executor = new FileExecutor(executables);
      if (executor.executeFiles(ExecutableFile.POSTINSTALL) != 0)
        javax.swing.JOptionPane.showMessageDialog(
            null,
            "The installation was not completed.",
            "Installation warning",
            javax.swing.JOptionPane.WARNING_MESSAGE);

      // We put the uninstaller
      putUninstaller();

      // The end :-)
      listener.stopUnpack();
    } catch (Exception err) {
      listener.stopUnpack();
      listener.errorUnpack(err.toString());
    }
    instances.remove(instances.indexOf(this));
  }
コード例 #8
0
  private void buttonOKActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_buttonOKActionPerformed

    // verification si les champs sont vides
    if (textIndDestinataire.getText().equals("")
        || textIndObjet.getText().equals("")
        || textMessage.getText().equals("")) {
      JOptionPane.showMessageDialog(
          this,
          Bundle.getText("JDialogAlerteChampsVides"),
          Bundle.getText("JDialogAlerteAttentionMessage"),
          JOptionPane.WARNING_MESSAGE);
      return;
    }

    try {
      // Envoie du login et du password a la servlet "CreerSuperviseurServlet" pour l'ajouter a la
      // BD
      URL url =
          new URL(
              "http://"
                  + P2S.P2S.Preferences.getProperty("host")
                  + ":"
                  + P2S.P2S.Preferences.getProperty("port")
                  + "/p2sserver/CreerUnMessageServlet?login="******"&sujet="
                  + this.textIndObjet.getText()
                  + "&message="
                  + this.textMessage.getText());

      // Buffer qui va recuperer la reponse de la servlet
      BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
      // On recupere la reponse
      String inputLine = in.readLine();
      if (inputLine.equalsIgnoreCase("ok")) { // on a enregistré dans la bd
        this.dispose();
        in.close();
        return;
      } else if (inputLine.equalsIgnoreCase("nok")) {
        JOptionPane.showMessageDialog(
            this,
            Bundle.getText("JDialogAlerteNoSup"),
            Bundle.getText("JDialogAlerteAttentionMessage"),
            JOptionPane.WARNING_MESSAGE);
      }
      in.close();
    } catch (MalformedURLException e1) {
      javax.swing.JOptionPane.showMessageDialog(
          null,
          Bundle.getText("ExceptionErrorURL"),
          Bundle.getText("ExceptionErrorTitle"),
          javax.swing.JOptionPane.ERROR_MESSAGE);
    } catch (IOException e2) {
      javax.swing.JOptionPane.showMessageDialog(
          null,
          Bundle.getText("ExceptionErrorIO"),
          Bundle.getText("ExceptionErrorTitle"),
          javax.swing.JOptionPane.ERROR_MESSAGE);
    } catch (IllegalArgumentException e3) {
      javax.swing.JOptionPane.showMessageDialog(
          null,
          Bundle.getText("ExceptionErrorARGS"),
          Bundle.getText("ExceptionErrorTitle"),
          javax.swing.JOptionPane.ERROR_MESSAGE);
    }
  } // GEN-LAST:event_buttonOKActionPerformed