Exemple #1
0
  public static void create(Dia dia) {

    Connector.connect();
    Connector.update("INSERT INTO dia (data)" + " VALUES ('" + dia.getData() + "'); ");

    Connector.close();
  }
Exemple #2
0
  public static void update(Dia dia) {
    Connector.connect();
    Connector.update(
        "UPDATE dia SET iddia = " + dia.getIdDia() + ", data ='" + dia.getData() + "';");

    Connector.close();
  }
Exemple #3
0
 @Test
 public void testTwoBinary() throws ConnectorException {
   Passthrough p1 = new Passthrough(2);
   QueueSink qs1 = new QueueSink(2);
   Connector.connect(p1, qs1, 0, 1);
   Connector.connect(p1, qs1, 1, 0);
   Pushable push1 = p1.getPushableInput(0);
   Pushable push2 = p1.getPushableInput(1);
   for (int k = 0; k < 2; k++) {
     Queue<Object> queue1 = qs1.getQueue(0);
     Queue<Object> queue2 = qs1.getQueue(1);
     for (int i = 0; i < 5; i++) {
       push1.push(i);
       push2.push(2 * i + 1);
       Utilities.queueContains(i, queue2);
       Utilities.queueContains(2 * i + 1, queue1);
     }
     p1.reset();
     qs1.reset();
   }
 }
Exemple #4
0
 public static Dia read(Date data) {
   Dia dia = null;
   Connector.connect();
   ResultSet resultSet = Connector.query("SELECT * FROM dia WHERE data ='" + data + "';");
   try {
     if (resultSet.next()) {
       dia = new Dia();
       dia.setIdDia(resultSet.getLong("iddia"));
       dia.setData(resultSet.getDate("data"));
     }
   } catch (Exception e) {
     System.out.println(e.getMessage());
   }
   Connector.close();
   return dia;
 }
Exemple #5
0
 @Test
 public void testThreeUnary1() throws ConnectorException {
   Passthrough p1 = new Passthrough(1);
   QueueSink qs1 = new QueueSink(1);
   Connector.connect(p1, qs1);
   Pushable push1 = p1.getPushableInput(0);
   for (int k = 0; k < 2; k++) {
     Queue<Object> queue = qs1.getQueue(0);
     for (int i = 0; i < 5; i++) {
       push1.push(i);
       Utilities.queueContains(i, queue);
     }
     p1.reset();
     qs1.reset();
   }
 }
Exemple #6
0
 public static ArrayList<Dia> getAll() {
   ArrayList<Dia> lista = new ArrayList<Dia>();
   Dia dia = null;
   Connector.connect();
   ResultSet resultSet = Connector.query("SELECT * FROM dia;");
   try {
     while (resultSet.next()) {
       dia = new Dia();
       dia.setIdDia(resultSet.getLong("iddia"));
       dia.setData(resultSet.getDate("data"));
       lista.add(dia);
     }
   } catch (Exception e) {
     System.out.println(e.getMessage());
   }
   Connector.close();
   return lista;
 }
  public static void main(String[] args) {

    // Create a Connector object and open the connection to the server
    Connector server = new Connector();
    boolean success = server.connect("MNP", "0a34d4ea3cc0da36ee91172b9cccb621");

    if (success == false) {
      System.out.println("Fatal error: could not open connection to server");
      System.exit(1);
    }

    DataTable data = server.getData();

    int rowCount = data.getRowCount();
    for (int row = 0; row < rowCount; ++row) {
      for (int col = 0; col < 4; ++col) {
        if (col > 0) {
          System.out.print(",");
        }
        System.out.print(data.getCell(row, col));
      }
      System.out.println();
    }
  }
 /**
  * Connects and invokes the various methods.
  *
  * @param info The configuration information
  */
 CreateImage(ConfigurationInfo info) {
   if (info == null) {
     info = new ConfigurationInfo();
     info.setHostName(hostName);
     info.setPassword(password);
     info.setUserName(userName);
     info.setDatasetId(datasetId);
     info.setImageId(imageId);
   }
   connector = new Connector(info);
   try {
     connector.connect();
     image = loadImage(info.getImageId());
     CreateNewImage(info);
   } catch (Exception e) {
     e.printStackTrace();
   } finally {
     try {
       connector.disconnect(); // Be sure to disconnect
     } catch (Exception e) {
       e.printStackTrace();
     }
   }
 }
  /**
   * Factory method that makes a TCP connection and returns a corresponding <code>Receiver</code>.
   *
   * @param connector Connector to use to make the connection to the server.
   * @param address The address of this ClientReceiver - can be used with {@link
   *     FanOutServerSender#send(Address, Message)}.
   * @return The ClientReceiver.
   * @throws CommunicationException If failed to connect.
   */
  public static ClientReceiver connect(Connector connector, Address address)
      throws CommunicationException {

    return new ClientReceiver(new SocketWrapper(connector.connect(address)));
  }
Exemple #10
0
 public static void delete(long idDia) {
   Connector.connect();
   Connector.update("DELETE FROM dia WHERE iddia=" + idDia + ";");
   Connector.close();
 }