Exemplo n.º 1
0
  /** Create the BUSINESS_SERVICE table. */
  public static void create(Connection connection) {
    System.out.print("CREATE TABLE BUSINESS_SERVICE: ");
    Statement statement = null;

    try {
      statement = connection.createStatement();
      int returnCode = statement.executeUpdate(createSQL);
      System.out.println("Successful (return code=" + returnCode + ")");
    } catch (java.sql.SQLException sqlex) {
      System.out.println("Failed (error message=" + sqlex.getMessage() + ")\n");
      System.out.println("SQL=" + createSQL);
    } finally {
      try {
        statement.close();
      } catch (Exception e) {
        /* ignored */
      }
    }
  }
Exemplo n.º 2
0
  // system test-driver
  public static void test(Connection connection) {
    Transaction txn = new Transaction();

    if (connection != null) {
      try {
        String businessKey = UUID.nextID();
        BusinessEntity business = new BusinessEntity();
        business.setBusinessKey(businessKey);
        business.setAuthorizedName("sviens");
        business.setOperator("WebServiceRegistry.com");

        String serviceKey = UUID.nextID();
        BusinessService service = new BusinessService();
        service.setBusinessKey(businessKey);
        service.setServiceKey(serviceKey);

        // begin a new transaction
        txn.begin(connection);

        String authorizedUserID = "sviens";

        // insert a new BusinessEntity
        BusinessEntityTable.insert(business, authorizedUserID, connection);

        // insert a new BusinessService
        BusinessServiceTable.insert(service, connection);

        // insert another new BusinessService
        service.setServiceKey(UUID.nextID());
        BusinessServiceTable.insert(service, connection);

        // insert one more new BusinessService
        service.setServiceKey(UUID.nextID());
        BusinessServiceTable.insert(service, connection);

        // select a BusinessService object
        service = BusinessServiceTable.select(serviceKey, connection);

        // delete a BusinessService object
        BusinessServiceTable.delete(serviceKey, connection);

        // select a BusinessService object
        service = BusinessServiceTable.select(serviceKey, connection);

        // select a Collection BusinessService objects by BusinessKey
        BusinessServiceTable.selectByBusinessKey(businessKey, connection);

        // delete a Collection BusinessService objects by BusinessKey
        BusinessServiceTable.deleteByBusinessKey(businessKey, connection);

        // select a Collection BusinessService objects by BusinessKey
        BusinessServiceTable.selectByBusinessKey(businessKey, connection);

        // commit the transaction
        txn.commit();
      } catch (Exception ex) {
        ex.printStackTrace();
        try {
          txn.rollback();
        } catch (java.sql.SQLException sqlex) {
          sqlex.printStackTrace();
        }
      }
    }
  }