Exemple #1
0
  public static void recieveTrafficRates(String IP, float upload, float download) {
    System.out.println("Insertion of Data into Database!");
    Connection con = null;
    String url = "jdbc:mysql://localhost:3306/";
    String dbName = "traffic_report";
    String driverName = "com.mysql.jdbc.Driver";
    String userName = "******";
    String password = "******";
    String IP_address = IP;

    float up = upload, down = download;

    try {
      Class.forName(driverName).newInstance();
      con = DriverManager.getConnection(url + dbName, userName, password);
      try {
        Statement st = con.createStatement();

        int val =
            st.executeUpdate(
                "INSERT current_traffic VALUES('" + IP + "','" + up + "','" + down + "')");

        System.out.println("Data Entry process successfully!");
      } catch (SQLException s) {
        System.out.println("Table all ready exists!" + s);
      }
      con.close();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Exemple #2
0
  public static void main(String args[]) {
    String fileToSend = "C:\\test1.txt";
    while (true) {
      // Maak lokale variabels eerst aan.
      // Dit is nodig om deze ook te gebruiken buiten de "try catch" blok.
      ServerSocket welcomeSocket = null;
      Socket connectionSocket = null;
      BufferedOutputStream outToClient = null;

      try {
        // poort waar gebruiker kan op connecteren
        welcomeSocket = new ServerSocket(3248);
        // Tot er een gebruiker gevonden is zal .accept() blijven wachten
        // Nadat er iemand geconnecteerd is zal er een nieuwe socket aangemaakt worden waarmee deze
        // met elkaar communiceren
        connectionSocket = welcomeSocket.accept();
        // buffer voor data communicatie tussen server en client
        outToClient = new BufferedOutputStream(connectionSocket.getOutputStream());
      } catch (IOException ex) {
        System.out.println("IOException1");
      } // if an I/O error occurs when opening the socket.

      if (outToClient
          != null) // wanneer buffer correct is aangemaakt zal deze niet een null waarde hebben
      {
        // gemaakte variabele doorgeven aan thread
        Connection c = new Connection(connectionSocket, outToClient, fileToSend);
        // thread starten
        c.start();
      }
    }
  }
  public static void main(String args[]) {
    int myport = 9090;
    Socket s;
    ServerSocket ss;
    BufferedReader fromSoc, fromKbd;
    PrintStream toSoc;
    String line, msg;
    try {
      s = new Socket("169.254.63.10", 6016);
      System.out.println("enter line");
      System.out.println("connected");
      toSoc = new PrintStream(s.getOutputStream());

      toSoc.println(myport);
      String url =
          "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)}; DBQ=D://db.mdb; DriverID=22;READONLY=true;";

      Connection con = DriverManager.getConnection(url, "", "");
      Statement st = con.createStatement();
      String ip = "169.254.63.10";
      int port = 6016;
      String video = "rooney";

      st.executeUpdate(
          " insert into p3 values('" + ip + "' , '" + port + "' , '" + video + "' );  ");

      fun();

    } catch (Exception e) {

      System.out.println("exception" + e);
    }
  }
 private void handleKeepAlive() {
   Connection c = null;
   try {
     netCode = ois.readInt();
     c = checkConnectionNetCode();
     if (c != null && c.getState() == Connection.STATE_CONNECTED) {
       oos.writeInt(ACK_KEEP_ALIVE);
       oos.flush();
       System.out.println("->ACK_KEEP_ALIVE"); // $NON-NLS-1$
     } else {
       System.out.println("->NOT_CONNECTED"); // $NON-NLS-1$
       oos.writeInt(NOT_CONNECTED);
       oos.flush();
     }
   } catch (IOException e) {
     System.out.println("handleKeepAlive: " + e.getMessage()); // $NON-NLS-1$
     if (c != null) {
       c.setState(Connection.STATE_DISCONNECTED);
       System.out.println(
           "Connection closed with "
               + c.getRemoteAddress()
               + //$NON-NLS-1$
               ":"
               + c.getRemotePort()); // $NON-NLS-1$
     }
   }
 }
  /* to search the DB table for req. video*/
  boolean search(String file) {

    boolean found = false;

    Connection con = null;
    String url =
        "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};  DBQ=D://db.mdb; DriverID=22;READONLY=true;";

    try {
      con = DriverManager.getConnection(url, "", "");
      try {
        Statement st = con.createStatement();
        ResultSet rs = st.executeQuery("SELECT video FROM p3");
        while (rs.next()) {
          String colvalue = rs.getString("video");
          if (colvalue.equalsIgnoreCase(file)) found = true;
        }

      } catch (SQLException s) {
        System.out.println("SQL statement is not executed!");
      }
    } catch (Exception e) {
      System.out.println(e);
    }
    return found;
  }
 private Connection checkConnectionNetCode() {
   synchronized (connections) {
     for (Connection c : connections) {
       if (c.getNetCode() == netCode) return c;
     }
   }
   return null;
 }
 private Connection newConnection() {
   Connection c = checkConnectionDuplicity();
   if (c == null) {
     c = new Connection(currentWorld.getWorld(), address, port, netCode);
     connections.add(c);
     c.addConnectionListener(this);
   } else return null;
   return c;
 }
 public void closeServer() {
   isActive = false;
   // Remove all connections
   synchronized (connections) {
     for (Connection c : connections) {
       c.send(DISCONNECT);
       c.setState(DISCONNECTED);
     }
   }
   connections = Collections.synchronizedList(new ArrayList<Connection>());
 }
 public Connection newConnection(InetAddress remoteAddress, int remotePort) {
   address = remoteAddress;
   port = remotePort;
   Connection c = checkConnectionDuplicity();
   if (c == null) {
     c = new Connection(currentWorld.getWorld(), remoteAddress, remotePort);
     connections.add(c);
     c.addConnectionListener(this);
   } else return null;
   return c;
 }
 private Connection checkConnectionDuplicity() {
   synchronized (connections) {
     for (Connection c : connections) {
       if (c.getRemoteAddress().equals(address) && c.getRemotePort() == port) {
         System.out.println("Duplicated connection"); // $NON-NLS-1$
         return c;
       }
     }
   }
   return null;
 }
Exemple #11
0
 public void dispose() {
   try {
     stmt.close();
     con.close();
   } catch (SQLException e) {
   }
 }
Exemple #12
0
  public static void failJobs(Connection conn) throws SQLException {
    String method = "failJobs";
    int location = 1000;
    try {
      Statement stmt = conn.createStatement();

      String strSQL =
          "INSERT INTO os.ao_queue (queue_id, status, queue_date, start_date, end_date, "
              + "error_message, num_rows, id, refresh_type, target_schema_name, target_table_name, target_append_only, "
              + "target_compressed, target_row_orientation, source_type, source_server_name, source_instance_name, "
              + "source_port, source_database_name, source_schema_name, source_table_name, source_user_name, "
              + "source_pass, column_name, sql_text, snapshot) "
              + "SELECT queue_id, 'failed' as status, queue_date, start_date, now() as end_date, "
              + "'Outsourcer stop requested' as error_message, num_rows, id, refresh_type, target_schema_name, "
              + "target_table_name, target_append_only, target_compressed, target_row_orientation, source_type, "
              + "source_server_name, source_instance_name, source_port, source_database_name, source_schema_name, "
              + "source_table_name, source_user_name, source_pass, column_name, sql_text, snapshot "
              + "FROM os.queue WHERE status = 'queued'";

      stmt.executeUpdate(strSQL);

    } catch (SQLException ex) {
      throw new SQLException(
          "(" + myclass + ":" + method + ":" + location + ":" + ex.getMessage() + ")");
    }
  }
  /**
   * Establishes a connection to a registry.
   *
   * @param queryUrl the URL of the query registry
   * @param publishUrl the URL of the publish registry
   */
  public void makeConnection(String queryUrl, String publishUrl) {

    Context context = null;
    ConnectionFactory factory = null;

    /*
     * Define connection configuration properties.
     * To publish, you need both the query URL and the
     * publish URL.
     */
    Properties props = new Properties();
    props.setProperty("javax.xml.registry.queryManagerURL", queryUrl);
    props.setProperty("javax.xml.registry.lifeCycleManagerURL", publishUrl);

    try {
      // Create the connection, passing it the
      // configuration properties
      context = new InitialContext();
      factory = (ConnectionFactory) context.lookup("java:comp/env/eis/JAXR");
      factory.setProperties(props);
      connection = factory.createConnection();
      System.out.println("Created connection to registry");
    } catch (Exception e) {
      e.printStackTrace();
      if (connection != null) {
        try {
          connection.close();
        } catch (JAXRException je) {
        }
      }
    }
  }
Exemple #14
0
  public static String getVersion(Connection conn) throws SQLException {
    String method = "getVersion";
    int location = 1000;
    try {
      location = 2000;
      String value = "";

      location = 2100;
      Statement stmt = conn.createStatement();
      String strSQL =
          "SELECT CASE "
              + "WHEN POSITION ('HAWQ 2.0.1' in version) > 0 THEN 'HAWQ_2_0_1' "
              + "WHEN POSITION ('HAWQ 2.0.0' in version) > 0 THEN 'HAWQ_2_0_0' "
              + "WHEN POSITION ('HAWQ 1' in version) > 0 THEN 'HAWQ_1' "
              + "WHEN POSITION ('HAWQ' in version) = 0 AND POSITION ('Greenplum Database' IN version) > 0 THEN 'GPDB' "
              + "ELSE 'OTHER' END "
              + "FROM version()";
      if (debug) Logger.printMsg("Getting Variable: " + strSQL);

      location = 2200;
      ResultSet rs = stmt.executeQuery(strSQL);

      while (rs.next()) {
        value = rs.getString(1);
      }

      location = 2300;
      return value;

    } catch (SQLException ex) {
      throw new SQLException(
          "(" + myclass + ":" + method + ":" + location + ":" + ex.getMessage() + ")");
    }
  }
Exemple #15
0
  public static void customStartAll(Connection conn) throws SQLException {
    String method = "customStartAll";
    int location = 1000;
    try {
      Statement stmt = conn.createStatement();

      int id = 0;
      int gpfdistPort = 0;
      String strSQL = "SELECT id\n";
      strSQL += "FROM os.custom_sql";

      ResultSet rs = stmt.executeQuery(strSQL);
      while (rs.next()) {
        id = rs.getInt(1);
        gpfdistPort = GpfdistRunner.customStart(OSProperties.osHome);

        strSQL = "INSERT INTO os.ao_custom_sql\n";
        strSQL +=
            "(id, table_name, columns, column_datatypes, sql_text, source_type, source_server_name, source_instance_name, source_port, source_database_name, source_user_name, source_pass, gpfdist_port)\n";
        strSQL +=
            "SELECT id, table_name, columns, column_datatypes, sql_text, source_type, source_server_name, source_instance_name, source_port, source_database_name, source_user_name, source_pass, "
                + gpfdistPort
                + "\n";
        strSQL += "FROM os.custom_sql\n";
        strSQL += "WHERE id = " + id;

        stmt.executeUpdate(strSQL);
      }
    } catch (SQLException ex) {
      throw new SQLException(
          "(" + myclass + ":" + method + ":" + location + ":" + ex.getMessage() + ")");
    }
  }
Exemple #16
0
  public static String getVariable(Connection conn, String name) throws SQLException {
    String method = "getVariable";
    int location = 1000;
    try {
      location = 2000;
      String value = "";

      location = 2100;
      Statement stmt = conn.createStatement();
      String strSQL = "SELECT os.fn_get_variable('" + name + "')";

      if (debug) Logger.printMsg("Getting Variable: " + strSQL);

      location = 2200;
      ResultSet rs = stmt.executeQuery(strSQL);

      while (rs.next()) {
        value = rs.getString(1);
      }

      location = 2300;
      return value;

    } catch (SQLException ex) {
      throw new SQLException(
          "(" + myclass + ":" + method + ":" + location + ":" + ex.getMessage() + ")");
    }
  }
 private void handleConnect() {
   try {
     int program_version = ois.readInt();
     port = ois.readInt();
     address = listenSocket.getInetAddress();
     netCode = ois.readInt();
     Connection c = checkConnectionNetCode();
     if (c != null) {
       oos.writeInt(ALREADY_CONNECTED);
       oos.flush();
       System.out.println("->ALREADY_CONNECTED"); // $NON-NLS-1$
     } else {
       if (isAcceptingConnections()) {
         if (connections.size() < Utils.getMAX_CONNECTIONS()) {
           if (Utils.VERSION == program_version) {
             Connection newConnection = newConnection();
             if (newConnection != null) {
               oos.writeInt(CONNECTED);
               newConnection.setState(Connection.STATE_CONNECTED);
               System.out.println("->CONNECTED"); // $NON-NLS-1$
             } else {
               oos.writeInt(ALREADY_CONNECTED);
               System.out.println("->ALREADY_CONNECTED"); // $NON-NLS-1$
             }
             oos.flush();
           } else {
             oos.writeInt(INCOMPATIBLE_PROGRAM_VERSION);
             oos.flush();
             System.out.println("->INCOMPATIBLE_PROGRAM_VERSION"); // $NON-NLS-1$
           }
         } else {
           oos.writeInt(TOO_MANY_CONNECTIONS);
           oos.flush();
           System.out.println("->TOO_MANY_CONNECTIONS"); // $NON-NLS-1$
         }
       } else {
         oos.writeInt(NOT_ACCEPTING_CONNECTIONS);
         oos.flush();
         System.out.println("->NOT_ACCEPTING_CONNECTIONS"); // $NON-NLS-1$
       }
     }
   } catch (IOException ex) {
     System.out.println(ex.getMessage());
   }
 }
 public void setStatement(Connection conn, String sqlString) throws SQLException {
   if (LOG.isDebugEnabled())
     LOG.debug(serverWorkerName + ". TrafStatement.setStatement [" + stmtLabel + "]");
   closeTStatement();
   if (sqlString != null) {
     stmt = conn.prepareStatement(sqlString);
     if (LOG.isDebugEnabled())
       LOG.debug(
           serverWorkerName
               + ". T2 conn.prepareStatement ["
               + stmtLabel
               + "] sqlString :"
               + sqlString);
   } else {
     this.stmt = conn.createStatement();
     if (LOG.isDebugEnabled())
       LOG.debug(serverWorkerName + ". T2 conn.createStatement [" + stmtLabel + "]");
   }
 }
  private void handleSendCode() {
    Connection c = null;
    GeneticCode code;

    try {
      netCode = ois.readInt();
      c = checkConnectionNetCode();
      if (c != null && c.getState() == Connection.STATE_CONNECTED) {
        oos.writeInt(WAITING_CODE);
        oos.flush();
        System.out.println("->WAITING_CODE"); // $NON-NLS-1$
        code = (GeneticCode) ois.readObject();
        System.out.println("Genetic code"); // $NON-NLS-1$
        oos.writeInt(CODE_RECEIVED);
        oos.flush();
        System.out.println("->CODE_RECEIVED"); // $NON-NLS-1$
        c.getInCorridor().receiveOrganism(code);
      } else {
        System.out.println("->NOT_CONNECTED"); // $NON-NLS-1$
        oos.writeInt(NOT_CONNECTED);
        oos.flush();
      }
    } catch (IOException e) {
      System.out.println("handleSendCode: " + e.getMessage()); // $NON-NLS-1$
      if (c != null) {
        c.setState(Connection.STATE_DISCONNECTED);
        System.out.println(
            "Connection closed with "
                + c.getRemoteAddress()
                + //$NON-NLS-1$
                ":"
                + c.getRemotePort()); // $NON-NLS-1$
      }
    } catch (ClassNotFoundException e) {
      System.out.println("handleSendCode: " + e.getMessage()); // $NON-NLS-1$
      if (c != null) {
        c.setState(Connection.STATE_DISCONNECTED);
        System.out.println(
            "Connection closed with "
                + c.getRemoteAddress()
                + //$NON-NLS-1$
                ":"
                + c.getRemotePort()); // $NON-NLS-1$
      }
    }
  }
Exemple #20
0
 static void connectDb() {
   // before: localhost/rsc
   sqlURL = "jdbc:postgresql://" + sqlURL;
   // after: "jdbc:postgresql://localhost/rsc";
   // "jdbc:postgresql://webbie.berkeley.intel-research.net/rsc"
   try {
     Class.forName("org.postgresql.Driver");
   } catch (ClassNotFoundException cnfe) {
     System.out.println("Couldn't find the driver!");
     System.out.println("Let's print a stack trace, and exit.");
     System.exit(1);
   }
   Connection connection = null;
   try {
     connection = DriverManager.getConnection(sqlURL, sqlUser, sqlPassword);
     query = connection.createStatement();
   } catch (SQLException se) {
     System.out.println("Couldn't connect: " + se);
     System.exit(1);
   }
 }
Exemple #21
0
  public void login() {
    String driver = "oracle.jdbc.driver.OracleDriver";
    String url = "jdbc:oracle:thin:@localhost:1521:orcl";
    Connection con = null;
    Statement stmt = null;
    ResultSet rs = null;

    String id, pw, sql;
    try {
      Class.forName(driver);
      con = DriverManager.getConnection(url, "hr", "hr");
      stmt = con.createStatement();
      sql = "select * from chatuser where id = '" + lid.getText() + "'";
      rs = stmt.executeQuery(sql);
      if (rs.next()) {
        pw = rs.getString(2);
        nick = rs.getString(3);
        if (lpw.getText().equals(pw)) {
          jd.setVisible(false);
          setVisible(true);
        } else {
          lpw.setText("일치하지 않습니다.");
        }
      } else {
        lid.setText("일치하지 않습니다.");
      }
    } catch (Exception e1) {
      e1.printStackTrace();
      System.out.println("데이터 베이스 연결 실패!!");
    } finally {
      try {
        if (rs != null) rs.close();
        if (stmt != null) stmt.close();
        if (con != null) con.close();
      } catch (Exception e1) {
        System.out.println(e1.getMessage());
      }
    }
  }
Exemple #22
0
 void serv(int i) {
   try {
     S = new DatagramSocket(i);
     S.setSoTimeout(5000);
   } catch (Exception exception) {
     exception.printStackTrace();
     if (S != null)
       try {
         S.close();
       } catch (Exception exception2) {
       }
     return;
   }
   System.out.println(DF.format(new Date()) + "Waiting connections ...");
   do
     try {
       buf = new byte[256];
       P = new DatagramPacket(buf, buf.length);
       S.receive(P);
       Connection connection =
           (Connection) Connections.get(P.getAddress().toString() + P.getPort());
       if (connection == null) {
         System.out.println(
             DF.format(new Date())
                 + "Connect from "
                 + " ("
                 + P.getAddress().getHostAddress()
                 + ")");
         connection = new Connection(this, P);
         Connections.put(P.getAddress().toString() + P.getPort(), connection);
         connection.start();
       } else {
         connection.packet(P);
       }
     } catch (Exception exception1) {
     }
   while (true);
 }
Exemple #23
0
  public static void emailAlert(Connection conn, String errorMsg) throws SQLException {
    String method = "emailAlert";
    int location = 1000;
    try {
      Statement stmt = conn.createStatement();

      String strSQL = "SELECT gp_elog('" + errorMsg + "',true)";
      ResultSet rs = stmt.executeQuery(strSQL);

    } catch (SQLException ex) {
      throw new SQLException(
          "(" + myclass + ":" + method + ":" + location + ":" + ex.getMessage() + ")");
    }
  }
Exemple #24
0
  public static int insertReplTable(Connection conn, String targetSchema, String targetTable)
      throws SQLException {
    String method = "insertReplTable";
    int location = 1000;

    int numRows = 0;
    try {
      location = 2000;
      String replTargetSchema = externalSchema;

      location = 2100;
      String replTargetTable = getStageTableName(targetSchema, targetTable);

      location = 2200;
      String externalTable = getExternalTableName(replTargetSchema, replTargetTable);

      location = 2305;
      // truncate the stage table before loading
      truncateTable(conn, replTargetSchema, replTargetTable);

      location = 2400;
      Statement stmt = conn.createStatement();

      location = 2500;
      String strSQL =
          "INSERT INTO \""
              + replTargetSchema
              + "\".\""
              + replTargetTable
              + "\" \n"
              + "SELECT * FROM \""
              + externalSchema
              + "\".\""
              + externalTable
              + "\"";
      if (debug) Logger.printMsg("Executing SQL: " + strSQL);

      location = 2600;
      numRows = stmt.executeUpdate(strSQL);

      location = 2700;
      return numRows;
    } catch (SQLException ex) {
      throw new SQLException(
          "(" + myclass + ":" + method + ":" + location + ":" + ex.getMessage() + ")");
    }
  }
Exemple #25
0
    public void run() {
      while (Thread.currentThread() == thread) {
        con.run();
        count++;
        con = null;

        if (count > 200 || threadpool.size() > 20) return;

        synchronized (this) {
          releaseRunner(this);
          try {
            wait();
          } catch (InterruptedException ir) {
            Thread.currentThread().interrupt();
          }
        }
      }
    }
Exemple #26
0
  public static boolean checkStageTable(Connection conn, String targetSchema, String targetTable)
      throws SQLException {
    String method = "checkStageTable";
    int location = 1000;

    try {
      location = 2000;
      boolean found = false;

      String stageTable = getStageTableName(targetSchema, targetTable);

      location = 2100;
      String strSQL =
          "SELECT NULL \n"
              + "FROM INFORMATION_SCHEMA.TABLES \n"
              + "WHERE table_schema = '"
              + externalSchema
              + "' \n"
              + "	AND table_name = '"
              + stageTable
              + "'";

      if (debug) Logger.printMsg("Executing sql: " + strSQL);

      location = 2200;
      Statement stmt = conn.createStatement();

      location = 2310;
      ResultSet rs = stmt.executeQuery(strSQL);

      location = 2400;
      while (rs.next()) {
        found = true;
      }

      location = 2500;
      return found;

    } catch (SQLException ex) {
      throw new SQLException(
          "(" + myclass + ":" + method + ":" + location + ":" + ex.getMessage() + ")");
    }
  }
Exemple #27
0
  public static boolean createSchema(Connection conn, String schema) throws SQLException {
    String method = "createSchema";
    int location = 1000;
    try {
      location = 2000;
      boolean found = false;

      String strSQL =
          "SELECT COUNT(*) \n"
              + "FROM INFORMATION_SCHEMA.SCHEMATA \n"
              + "WHERE SCHEMA_NAME = '"
              + schema
              + "'";

      location = 2100;
      Statement stmt = conn.createStatement();

      location = 2200;
      ResultSet rs = stmt.executeQuery(strSQL);

      location = 2306;
      while (rs.next()) {
        if (rs.getInt(1) > 0) found = true;
      }

      location = 2400;
      if (!(found)) {
        location = 2500;
        String schemaDDL = "CREATE SCHEMA \"" + schema + "\"";
        ;
        if (debug) Logger.printMsg("Schema DDL: " + schemaDDL);

        location = 2600;
        stmt.executeUpdate(schemaDDL);
      }

      location = 2700;
      return found;

    } catch (SQLException ex) {
      return true;
    }
  }
Exemple #28
0
  public static String getMax(Connection conn, String schema, String table, String columnName)
      throws SQLException {
    String method = "getMax";
    int location = 1000;

    try {
      location = 2000;
      String strSQL =
          "SELECT MAX(\""
              + columnName.toLowerCase()
              + "\") \n"
              + "FROM \""
              + schema
              + "\".\""
              + table
              + "\"";

      if (debug) Logger.printMsg("Executing sql: " + strSQL);

      String max = "-1";

      location = 2100;
      Statement stmt = conn.createStatement();

      location = 2200;
      ResultSet rs = stmt.executeQuery(strSQL);

      while (rs.next()) {
        max = rs.getString(1);
      }

      location = 2313;
      if (max == null) {
        max = "-1";
      }
      return max;

    } catch (SQLException ex) {
      throw new SQLException(
          "(" + myclass + ":" + method + ":" + location + ":" + ex.getMessage() + ")");
    }
  }
Exemple #29
0
  public static void truncateTable(Connection conn, String schema, String table)
      throws SQLException {
    String method = "truncateTable";
    int location = 1000;
    try {
      location = 2000;
      Statement stmt = conn.createStatement();

      location = 2100;
      String strSQL = "truncate table \"" + schema + "\".\"" + table + "\"";

      if (debug) Logger.printMsg("Truncating table: " + strSQL);

      location = 2200;
      stmt.executeUpdate(strSQL);
    } catch (SQLException ex) {
      throw new SQLException(
          "(" + myclass + ":" + method + ":" + location + ":" + ex.getMessage() + ")");
    }
  }
Exemple #30
0
  public static void cancelJobs(Connection conn) throws SQLException {
    String method = "cancelJobs";
    int location = 1000;
    try {
      List<String> jobIdList = new ArrayList<String>();
      Statement stmt = conn.createStatement();

      String strSQL = "SELECT id FROM os.queue WHERE status = 'processing'";
      ResultSet rs = stmt.executeQuery(strSQL);
      while (rs.next()) {
        jobIdList.add(rs.getString(1));
      }

      for (String jobId : jobIdList) {
        strSQL = "SELECT os.fn_cancel_job(" + jobId + ")";
        rs = stmt.executeQuery(strSQL);
      }
    } catch (SQLException ex) {
      throw new SQLException(
          "(" + myclass + ":" + method + ":" + location + ":" + ex.getMessage() + ")");
    }
  }