Examples of Database


Examples of org.boris.expr.util.Database

        // Get database argument
        Expr edb = evalArg(args[0]);
        if (!(edb instanceof ExprArray)) {
            return ExprError.VALUE;
        }
        Database db = Database.valueOf((ExprArray) edb);
        if (db == null) {
            return ExprError.VALUE;
        }

        // Get field argument
        Expr ef = evalArg(args[1]);
        String field = null;
        if (ef instanceof ExprString) {
            field = ((ExprString) ef).str;
        } else if (ef instanceof ExprInteger) {
            int col = ((ExprInteger) ef).intValue();
            int cc = db.getColumnCount();
            if (col < 1 || col > cc)
                return ExprError.VALUE;
            field = db.getColumnName(col - 1);
        }

        // Get criteria argument
        Expr ec = evalArg(args[2]);
        if (!(ec instanceof ExprArray)) {
View Full Code Here

Examples of org.castor.cpa.test.framework.xml.Database

            _configurations.put(config.getName(), config);
        }
       
        Iterator dbIter = cpactfconf.iterateDatabase();
        while (dbIter.hasNext()) {
            Database database = (Database) dbIter.next();
            _databases.put(database.getName(), database);
        }
       
        Iterator transIter = cpactfconf.iterateTransaction();
        while (transIter.hasNext()) {
            Transaction trans = (Transaction) transIter.next();
View Full Code Here

Examples of org.castor.jdo.conf.Database

    public static Database createDatabase(final String name, final String engine,
            final DataSource ds, final Mapping[] mappings) {
        DatabaseChoice dbChoice = new DatabaseChoice();
        dbChoice.setDataSource(ds);

        Database dbConf = createDatabase(name, engine);
        dbConf.setDatabaseChoice(dbChoice);
        dbConf.setMapping(mappings);
        return dbConf;
    }
View Full Code Here

Examples of org.cishell.service.database.Database

      String driver, String url, String username, String password)
  throws DatabaseCreationException {
    DataSource dataSource =
      createNewDataSource(driver, url, username, password);
    //TODO: See if we can get the default schema as a property somehow.
    Database db = new ExternalDatabase(dataSource, "APP");
    return db;
  }
View Full Code Here

Examples of org.databene.jdbacl.model.Database

  protected DBCatalog catalog;
  protected DBSchema schema;

  @Before
  public void prepareDB() {
    this.db = new Database(null, null, false);
    this.catalog = new DBCatalog("catalog", this.db);
    this.schema = new DBSchema("schema", this.catalog);
  }
View Full Code Here

Examples of org.dbwiki.data.database.Database

      DatabaseWiki wiki = server.get(wikiName);
     
      // [wiki] should never be null
      assert(wiki != null);
     
      Database database = wiki.database();
           
      Connection con = connector.getConnection();
      con.setAutoCommit(false);

      ImportPresentationFiles p = new ImportPresentationFiles(server, wiki, database, username);
View Full Code Here

Examples of org.exist.Database

  public void responseEvent(CommandContinuation command, Response response) {
    System.out.println("getResponse command = "+command);
  }
 
    private void store(String name,  String data) throws EXistException {
      Database pool = BrokerPool.getInstance();;
     
        DBBroker broker = null;
        TransactionManager transact = null;
        Txn transaction = null;
        try {
            broker = pool.get(pool.getSecurityManager().getSystemSubject());
            assertNotNull(broker);
            transact = pool.getTransactionManager();
            assertNotNull(transact);
            transaction = transact.beginTransaction();
            assertNotNull(transaction);

            Collection root = broker.getOrCreateCollection(transaction, TestConstants.TEST_COLLECTION_URI);
        broker.saveCollection(transaction, root);
            assertNotNull(root);

            root.addBinaryResource(transaction, broker, XmldbURI.create(name), data.getBytes(), "application/xquery");

            transact.commit(transaction);
        } catch (Exception e) {
            if (transact != null)
                transact.abort(transaction);
            e.printStackTrace();
            fail(e.getMessage());
        } finally {
            pool.release(broker);
        }
    }
View Full Code Here

Examples of org.exolab.castor.jdo.Database


  public void run( PrintWriter writer )
    throws Exception
  {
    Database      db;
    Product       product;
    ProductGroup  group;
    ProductDetail detail;
    Computer      computer;
    OQLQuery      productOql;
    OQLQuery      groupOql;
    OQLQuery      computerOql;
    QueryResults  results;

    db = _jdo.getDatabase();

    db.begin();
    writer.println( "Begin transaction" );

    // Look up the product and if found in the database,
    // delete this object from the database
    productOql = db.getOQLQuery( "SELECT p FROM myapp.Product p WHERE id = $1" );
    productOql.bind( 4 );
    results = productOql.execute();
    while ( results.hasMore() ) {
      product = (Product) results.next();
      writer.println( "Deleting existing product: " + product );
      db.removeproduct );
    }
       
    // Look up the computer and if found in the database,
    // delete ethis object from the database
    computerOql = db.getOQLQuery( "SELECT c FROM myapp.Computer c WHERE id = $1" );
    computerOql.bind( 6 );
    results = computerOql.execute();
    while ( results.hasMore() ) {
      computer = (Computer) results.next();
      writer.println( "Deleting existing computer: " + computer );
      db.remove( computer );
    }

    // Look up the group and if found in the database,
    // delete this object from the database
    groupOql = db.getOQLQuery( "SELECT g FROM myapp.ProductGroup g WHERE id = $1" );
    groupOql.bind( 3 );
    results = groupOql.execute();
    while ( results.hasMore() ) {
      group = (ProductGroup) results.next();
      writer.println( "Deleting existing group: " + group );
      db.remove( group );
    }
       
    // Checkpoint commits all the updates to the database
    // but leaves the transaction (and locks) open
    writer.println( "Transaction checkpoint" );
    db.commit();

    db.begin();
    // If no such group exists in the database, create a new
    // object and persist it
    groupOql.bind( 3 );
    results = groupOql.execute();
    if ( ! results.hasMore() ) {
      group = new ProductGroup();
      group.setId( 3 );
      group.setName( "a group" );
      db.create( group );
      writer.println( "Creating new group: " + group );
    } else {
      group = (ProductGroup) results.next();
      writer.println( "Query result: " + group );
    }

    // If no such product exists in the database, create a new
    // object and persist it
    // Note: product uses group, so group object has to be
    //       created first, but can be persisted later
    productOql.bind( 4 );
    results = productOql.execute();
    if ( ! results.hasMore() ) {
      product = new Product();
      product.setId( 4 );
      product.setName( "some product" );
      product.setPrice( 55 );
      product.setGroup( group );
      detail = new ProductDetail();
      detail.setId( 1 );
      detail.setName( "one" );
      product.addDetail( detail );
      detail = new ProductDetail();
      detail.setId( 2 );
      detail.setName( "two" );
      product.addDetail( detail );
      writer.println( "Creating new product: " + product );
      db.create( product );
    } else {
      writer.println( "Query result: " + results.next() );
    }

    // If no such computer exists in the database, create a new
    // object and persist it
    // Note: computer uses group, so group object has to be
    //       created first, but can be persisted later
    computerOql.bind( 6 );
    results = computerOql.execute();
    if ( ! results.hasMore() ) {
      computer = new Computer();
      computer.setId( 6 );
      computer.setCpu( "Pentium" );
      computer.setName( "MyPC" );
      computer.setPrice( 300 );
      computer.setGroup( group );
      detail = new ProductDetail();
      detail.setId( 4 );
      detail.setName( "mouse" );
      computer.addDetail( detail );
      detail = new ProductDetail();
      detail.setId( 5 );
      detail.setName( "screen" );
      computer.addDetail( detail );
      writer.println( "Creating new computer: " + computer );
      db.create( computer );
    } else {
      writer.println( "Query result: " + results.next() );
    }
    writer.println( "Commit transaction" );
    db.commit();

    Marshaller     marshaller;

    marshaller = new Marshaller( writer );
    marshaller.setMapping( _mapping );

    db.begin();
    marshaller.marshal( db.load( Product.class, new Integer( 4 ) ) );
    computerOql = db.getOQLQuery( "SELECT c FROM myapp.Computer c" );
    results = computerOql.execute();
    while( results.hasMore() )
      marshaller.marshal( results.next() );
    db.commit();

    db.close();
  }
View Full Code Here

Examples of org.exolab.castor.jdo.conf.Database

     private static synchronized void loadDatabase(Database[] databases, EntityResolver resolver, ClassLoader loader, String baseURI)
        throws MappingException
    {
        Mapping            mapping;
        Enumeration        mappings;
        Database           database;
        // Database[]         databases;
        DatabaseRegistry   dbs;
        PersistenceFactory factory;

        try {
            // Load the JDO configuration file from the specified input source.
            // databases = JDOConfLoader.getDatabases (baseURI, resolver);
           
          for (int i = 0; i < databases.length ;i++) {
           
            database = databases[i];
           
            // If the database was already configured, ignore
            // this database configuration (allowing multiple loadings).
            if ( _databases.get( database.getName() ) != null )
              return;
           
            // Complain if no database engine was specified, otherwise get
            // a persistence factory for that database engine.
            if ( database.getEngine() == null  )
              factory = PersistenceFactoryRegistry.getPersistenceFactory( GenericEngine );
            else
              factory = PersistenceFactoryRegistry.getPersistenceFactory( database.getEngine() );
            if ( factory == null )
              throw new MappingException( "jdo.noSuchEngine", database.getEngine() );
           
            // Load the mapping file from the URL specified in the database
            // configuration file, relative to the configuration file.
            // Fail if cannot load the mapping for whatever reason.
            mapping = new Mapping( loader );
            if ( resolver != null )
              mapping.setEntityResolver( resolver );
            if ( baseURI != null )
              mapping.setBaseURL( baseURI );
           
            mappings = database.enumerateMapping();
            while ( mappings.hasMoreElements() )
            {
              String mappingUrl = ( (org.exolab.castor.jdo.conf.Mapping) mappings.nextElement() ).getHref();
              _log.debug( "Loading the mapping descriptor: " + mappingUrl );
             
              if ( mappingUrl != null )
              {
                mapping.loadMapping( mappingUrl );
              }
            }
           
            if (database.getDatabaseChoice() == null) {
              throw new MappingException( "jdo.missingDataSource", database.getName() );
            }
           
                if ( database.getDatabaseChoice().getDriver() != null ) {
            // JDO configuration file specifies a driver, use the driver
            // properties to create a new registry object.
                    dbs = initFromDriver(mapping, database, factory);
          } else if ( database.getDatabaseChoice().getDataSource() != null ) {
            // JDO configuration file specifies a DataSource object, use the
            // DataSource which was configured from the JDO configuration file
            // to create a new registry object.
            dbs = initFromDataSource(mapping, database, factory, loader);
          } else if ( database.getDatabaseChoice().getJndi() != null ) {
            // JDO configuration file specifies a DataSource lookup through JNDI,
            // locate the DataSource object frome the JNDI namespace and use it.
            dbs = initFromJNDI(mapping, database, factory);
                } else {
                    throw new MappingException( "jdo.missingDataSource", database.getName() );
                }
               
            // Register the new registry object for the given database name.
            _databases.put( database.getName(), dbs );
         
          }
        } catch ( MappingException except ) {
            throw except;
        } catch ( Exception except ) {
View Full Code Here

Examples of org.exolab.jms.tools.db.Database

    public V072toV076SchemaConverter(Connection connection) {
        _connection = connection;
    }

    public void convert() throws PersistenceException {
        Database schema = SchemaHelper.getSchema();
        try {
            if (_connection.getAutoCommit()) {
                _connection.setAutoCommit(false);
            }
            _tool = new RDBMSTool(_connection);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.