Package org.apache.tuscany.das.rdb.config

Examples of org.apache.tuscany.das.rdb.config.Config


   
    //<Config> useGetGeneratedKeys set to FALSE - Company -
    // exception as insert.getGen..Keys will throw RuntimeException
    public void testInsert2() throws Exception {
        ConfigHelper helper = new ConfigHelper();
        Config config = helper.getConfig();
        config.setGeneratedKeysSupported("false");

        DAS das = DAS.FACTORY.createDAS(config, getConnection());
        Command insert = das.createCommand("insert into COMPANY (NAME) values (?)");
        insert.setParameter(1, "AAA Rental");
        insert.execute();//this will happen as table is created with proper clause
View Full Code Here


    }
   
    //<Config> useGetGeneratedKeys set to TRUE - Customer - flag should be ignored during insert
    public void testInsert3() throws Exception {
        ConfigHelper helper = new ConfigHelper();
        Config config = helper.getConfig();
        config.setGeneratedKeysSupported("true");
     
        DAS das = DAS.FACTORY.createDAS(config, getConnection());
        Command insert = das.createCommand("insert into CUSTOMER (ID, LASTNAME, ADDRESS) values (?, ?, ?)");
        String key = "10";
        insert.setParameter(1, key);
View Full Code Here

    }
   
    //<Config> useGetGeneratedKeys set to FALSE - Customer, flag has no effect
    public void testInsert4() throws Exception {
        ConfigHelper helper = new ConfigHelper();
        Config config = helper.getConfig();
        config.setGeneratedKeysSupported("false");
     
        DAS das = DAS.FACTORY.createDAS(config, getConnection());
        Command insert = das.createCommand("insert into CUSTOMER (ID, LASTNAME, ADDRESS) values (?, ?, ?)");
        String key = "10";
        insert.setParameter(1, key);
View Full Code Here

    }
   
    //<Config> useGetGeneratedKeys not set - Customer - default TRUE is ignored
    public void testInsert5() throws Exception {
        ConfigHelper helper = new ConfigHelper();
        Config config = helper.getConfig();
     
        DAS das = DAS.FACTORY.createDAS(config, getConnection());
        Command insert = das.createCommand("insert into CUSTOMER (ID, LASTNAME, ADDRESS) values (?, ?, ?)");
        String key = "10";
        insert.setParameter(1, key);
View Full Code Here

                configWrapper.addImpliedRelationship(pkTableName, fkTableName, columnName);
            }
        }
        // Add any tables defined in the model but not included in the ResultSet
        // to the list of propertyNames
        Config model = configWrapper.getConfig();
        if (model != null) {
            Iterator tablesFromModel = model.getTable().iterator();
            while (tablesFromModel.hasNext()) {
                TableWrapper t = new TableWrapper((Table) tablesFromModel.next());
                if (tableToPropertyMap.get(t.getTypeName()) == null) {
                    tableToPropertyMap.put(t.getTypeName(), Collections.EMPTY_LIST);
                }
View Full Code Here

    Parameter parameter3 = ConfigFactory.INSTANCE.createParameter();
    parameter3.setName("ADDRESS");
    insertAdhoc.getParameter().add(parameter1);
    insertAdhoc.getParameter().add(parameter2);
    insertAdhoc.getParameter().add(parameter3);
    Config cfg = helper.getConfig();
    cfg.getCommand().add(insertAdhoc);
    DAS das = DAS.FACTORY.createDAS(cfg, getConnection());
   
    //setup is over, now set values in params and execute
    Command insert = das.getCommand("insertCustomer");
    insert.setParameter("ID", new Integer(6));
View Full Code Here

                configWrapper.addImpliedRelationship(pkTableName, fkTableName, columnName);
            }
        }
        // Add any tables defined in the model but not included in the ResultSet
        // to the list of propertyNames
        Config model = configWrapper.getConfig();
        if (model != null) {
            Iterator tablesFromModel = model.getTable().iterator();
            while (tablesFromModel.hasNext()) {
                TableWrapper t = new TableWrapper((Table) tablesFromModel.next());
                if (tableToPropertyMap.get(t.getTypeName()) == null) {
                    tableToPropertyMap.put(t.getTypeName(), Collections.EMPTY_LIST);
                }
View Full Code Here

      configFile = args[0];
    }
   
    CustomerClient cclient = new CustomerClient();
   
    Config config = ConfigUtil.loadConfig(cclient.getClass().getClassLoader().getResourceAsStream(configFile));
   
    String dbType = null;
    String dbURL = null;
    String user = null;
    String password = null;
   
    if(config.getConnectionInfo().getConnectionProperties().getDriverClass().indexOf(DERBY) != -1){
      dbType = DERBY;
    }
   
    if(config.getConnectionInfo().getConnectionProperties().getDriverClass().indexOf(MYSQL) != -1){
      dbType = MYSQL;
    }
   
    if(config.getConnectionInfo().getConnectionProperties().getDriverClass().indexOf(DB2) != -1){
      dbType = DB2;
    }
 
    //get connection info from config
    dbURL = config.getConnectionInfo().getConnectionProperties().getDatabaseURL();
    user = config.getConnectionInfo().getConnectionProperties().getUserName();
    password = config.getConnectionInfo().getConnectionProperties().getPassword();
   
    System.out.println("connection info from config***************");
    System.out.println("dbName:"+dbURL+" user:"+user+" password:"+password);
    System.out.println("******************************************");
    //dt create/connect/create schema
View Full Code Here

        this(ConfigUtil.loadConfig(stream));

    }

    public DASImpl(Config inConfig) {
        Config cfg = inConfig;
        if (cfg == null) {
            cfg = ConfigFactory.INSTANCE.createConfig();
        }
        this.configWrapper = new MappingWrapper(cfg);
View Full Code Here

        }
        return connection;
    }
   
    private void initializeConnection() {
        Config config = configWrapper.getConfig();
        if (config == null || config.getConnectionInfo() == null ||
            (config.getConnectionInfo().getDataSource() == null && config.getConnectionInfo().getConnectionProperties() == null)) {
            throw new RuntimeException("No connection has been provided and no data source has been specified");
        }

        if(config.getConnectionInfo().getDataSource() != null && config.getConnectionInfo().getConnectionProperties() != null){
            throw new RuntimeException("Use either dataSource or ConnectionProperties. Can't use both !");
        }
       
        ConnectionInfo connectionInfo = configWrapper.getConfig().getConnectionInfo();
        if(config.getConnectionInfo().getConnectionProperties() != null){
            initializeDriverManagerConnection(connectionInfo);
        }else{
            initializeDatasourceConnection(connectionInfo);
        }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.das.rdb.config.Config

Copyright © 2018 www.massapicom. 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.