Examples of DataSourceComponent


Examples of org.apache.avalon.excalibur.datasource.DataSourceComponent

    }

    private Connection getConnection() throws SourceException {

        ServiceSelector selector = null;
        DataSourceComponent datasource = null;

        try {
            try {
                selector = (ServiceSelector)this.manager.lookup(DataSourceComponent.ROLE + "Selector");

                datasource = (DataSourceComponent)selector.select(this.datasourceName);

            } catch (Exception e) {
                String msg = "Cannot get datasource '" + this.datasourceName + "'";
                getLogger().error(msg);
                throw new SourceException(msg, e);
            }

            try {
                return datasource.getConnection();
            } catch (Exception e) {
                String msg = "Cannot get connection for datasource '" + this .datasourceName + "'";
                getLogger().error(msg);
                throw new SourceException(msg, e);
            }
View Full Code Here

Examples of org.apache.avalon.excalibur.datasource.DataSourceComponent

     * to the AbstractDatabaseAction specifications.
     */
    public Map act( Redirector redirector, SourceResolver resolver, Map objectModel,
                    String source, Parameters param ) throws Exception {

        DataSourceComponent datasource = null;
        Connection conn = null;
        Map results = new HashMap();
        int rows = 0;

        // read global parameter settings
        boolean reloadable = Constants.DESCRIPTOR_RELOADABLE_DEFAULT;

        // call specific default modes apart from output mode are not supported
        // set request attribute
        String outputMode = param.getParameter("output", (String) defaultModeNames.get(MODE_OUTPUT));

        if (this.settings.containsKey("reloadable"))
            reloadable = Boolean.valueOf((String) this.settings.get("reloadable")).booleanValue();

        // read local parameter settings
        try {
            Configuration conf =
                this.getConfiguration(param.getParameter("descriptor", (String) this.settings.get("descriptor")),
                                      resolver,
                                      param.getParameterAsBoolean("reloadable",reloadable));

            // get database connection and try to turn off autocommit
            datasource = this.getDataSource(conf, param);
            conn = datasource.getConnection();
            if (conn.getAutoCommit() == true) {
                try {
                    conn.setAutoCommit(false);
                } catch (Exception ex) {
                    String tmp = param.getParameter("use-transactions",(String) this.settings.get("use-transactions",null));
View Full Code Here

Examples of org.apache.avalon.excalibur.datasource.DataSourceComponent

    }

    private Connection getConnection() throws SourceException {

        ComponentSelector selector = null;
        DataSourceComponent datasource = null;

        try {
            try {
                selector = (ComponentSelector)this.manager.lookup(DataSourceComponent.ROLE + "Selector");

                datasource = (DataSourceComponent)selector.select(this.datasourceName);

            } catch(Exception e) {
                String msg = "Cannot get datasource '" + this.datasourceName + "'";
                getLogger().error(msg);
                throw new SourceException(msg, e);
            }

            try {
                return datasource.getConnection();
            } catch(Exception e) {
                String msg = "Cannot get connection for datasource '" + this .datasourceName + "'";
                getLogger().error(msg);
                throw new SourceException(msg, e);
            }
View Full Code Here

Examples of org.apache.avalon.excalibur.datasource.DataSourceComponent

                final String connection = properties.getParameter( SQLTransformer.MAGIC_CONNECTION, null );
                if ( connection != null ) {
                    if (this.transformer.dbSelector == null) {
                        transformer.getTheLogger().error( "No DBSelector found, could not use connection: " + connection);
                    } else {
                        DataSourceComponent datasource = null;

                        try {
                            datasource = (DataSourceComponent) this.transformer.dbSelector.select( connection );
                            for ( int i = 0; i < transformer.connectAttempts && result == null; i++) {
                                try {
                                    result = datasource.getConnection();
                                } catch ( Exception e ) {
                                    final long waittime = transformer.connectWaittime;
                                    transformer.getTheLogger().debug(
                                            "SQLTransformer$Query: could not acquire a Connection -- waiting "
                                            + waittime + " ms to try again." );
View Full Code Here

Examples of org.apache.avalon.excalibur.datasource.DataSourceComponent

    /**
     * Main invocation routine.
     */
    public Map act (Redirector redirector, SourceResolver resolver, Map objectModel, String src,
            Parameters parameters) throws Exception {
        DataSourceComponent datasource = null;
        Connection conn = null;
        Statement st = null;
        ResultSet rs = null;

        // read global parameter settings
        boolean reloadable = Constants.DESCRIPTOR_RELOADABLE_DEFAULT;

        if (this.settings.containsKey("reloadable")) {
            reloadable = Boolean.valueOf((String) this.settings.get("reloadable")).booleanValue();
        }

        // read local settings
        try {
            Configuration conf = this.getConfiguration (
                    parameters.getParameter ("descriptor", (String) this.settings.get("descriptor")),
            resolver,
            parameters.getParameterAsBoolean("reloadable",reloadable));
            boolean cs = true;
            String create_session = parameters.getParameter ("create-session",
                                 (String) this.settings.get("create-session"));
            if (create_session != null &&
                    ("no".equals (create_session.trim ()) || "false".equals (create_session.trim ()))) {
                cs = false;
            }

            datasource = this.getDataSource(conf);
            conn = datasource.getConnection();
            Request req = ObjectModelHelper.getRequest(objectModel);

            /* check request validity */
            if (req == null) {
                getLogger ().debug ("DBAUTH: no request object");
View Full Code Here

Examples of org.apache.avalon.excalibur.datasource.DataSourceComponent

            String connection = properties.getProperty( SQLTransformer.MAGIC_CONNECTION );
            String dburl = properties.getProperty( SQLTransformer.MAGIC_DBURL );
            String username = properties.getProperty( SQLTransformer.MAGIC_USERNAME );
            String password = properties.getProperty( SQLTransformer.MAGIC_PASSWORD );

            DataSourceComponent datasource = null;
            try {
                if ( connection != null ) {
                    datasource = (DataSourceComponent) dbSelector.select( connection );
                    while ( result == null ) {
                        try {
                            result = datasource.getConnection();
                        } catch ( Exception e ) {
                            long waittime = 5000 * (long) Math.random();
                            getTheLogger().debug( "SQLTransformer$Query: could not acquire a Connection -- waiting " + waittime + " ms to try again." );
                            try {
                                Thread.sleep( waittime );
View Full Code Here

Examples of org.apache.avalon.excalibur.datasource.DataSourceComponent

    /**
     * Main invocation routine.
     */
    public Map act (Redirector redirector, SourceResolver resolver, Map objectModel, String src,
            Parameters parameters) throws Exception {
        DataSourceComponent datasource = null;
        Connection conn = null;
        Statement st = null;
        ResultSet rs = null;

        // read global parameter settings
        boolean reloadable = Constants.DESCRIPTOR_RELOADABLE_DEFAULT;

        if (this.settings.containsKey("reloadable")) {
            reloadable = Boolean.getBoolean((String) this.settings.get("reloadable"));
        }

        // read local settings
        try {
            Configuration conf = this.getConfiguration (
                    parameters.getParameter ("descriptor", (String) this.settings.get("descriptor")),
            resolver,
            parameters.getParameterAsBoolean("reloadable",reloadable));
            boolean cs = true;
            String create_session = parameters.getParameter ("create-session",
                                 (String) this.settings.get("create-session"));
            if (create_session != null &&
                    ("no".equals (create_session.trim ()) || "false".equals (create_session.trim ()))) {
                cs = false;
            }

            datasource = this.getDataSource(conf);
            conn = datasource.getConnection();
            Request req = ObjectModelHelper.getRequest(objectModel);

            /* check request validity */
            if (req == null) {
                getLogger ().debug ("DBAUTH: no request object");
View Full Code Here

Examples of org.apache.avalon.excalibur.datasource.DataSourceComponent

     * Select a record from the database.  This action assumes that
     * the file referenced by the "descriptor" parameter conforms
     * to the AbstractDatabaseAction specifications.
     */
    public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String source, Parameters param) throws Exception {
        DataSourceComponent datasource = null;
        Connection conn = null;
        int currentIndex = 0;

        // read global parameter settings
        boolean reloadable = Constants.DESCRIPTOR_RELOADABLE_DEFAULT;
        if (this.settings.containsKey("reloadable"))
            reloadable = Boolean.getBoolean((String) this.settings.get("reloadable"));
        // read local parameter settings
        try {
            Configuration conf =
                this.getConfiguration(param.getParameter("descriptor", (String) this.settings.get("descriptor")),
                                      resolver,
                                      param.getParameterAsBoolean("reloadable",reloadable));

            Request request = ObjectModelHelper.getRequest(objectModel);

            Configuration[] keys = conf.getChild("table").getChild("keys").getChildren("key");
            Configuration[] values = conf.getChild("table").getChild("values").getChildren("value");

            PreparedStatement statement = null;
            ResultSet rset = null;
            boolean result = false;

            for (int i = 0; i < keys.length; i++) {
                final String parameter = keys[i].getAttribute("param");
                Object value = request.getParameter(parameter);
                if (value == null || "".equals(value)) {
                    if (statement == null) {
                        final String query = this.getSelectQuery(conf);
                        datasource = this.getDataSource(conf);
                        conn = datasource.getConnection();

                        statement = conn.prepareStatement(query);
                        currentIndex = 1;
                        for (int j = 0; j < keys.length; j++, currentIndex++) {
                            this.setColumn(statement, currentIndex, request, keys[j]);
                        }

                        rset = statement.executeQuery();
                        result = rset.next();
                    }

                    if (result)
                        value = this.getColumn(rset, request, keys[i]);
                }

                if (value != null)
                    request.setAttribute(parameter, value.toString());
            }

            for (int i = 0; i < values.length; i++) {
                final String parameter = values[i].getAttribute("param");
                Object value = request.getParameter(parameter);
                if (value == null || "".equals(value)) {
                    if (statement == null) {
                        final String query = this.getSelectQuery(conf);
                        datasource = this.getDataSource(conf);
                        conn = datasource.getConnection();

                        statement = conn.prepareStatement(query);
                        currentIndex = 1;
                        for (int j = 0; j < keys.length; j++, currentIndex++) {
                            this.setColumn(statement, currentIndex, request, keys[j]);
View Full Code Here

Examples of plan_runner.components.DataSourceComponent

        inputTupleSchema.add(new ColumnNameType("N2.NAME", _sc));
        inputTupleSchema.add(new ColumnNameType("EXTRACT_YEAR(LINEITEM.SHIPDATE)", _ic));
        inputTupleSchema.add(new ColumnNameType("LINEITEM.EXTENDEDPRICE * (1.0 - LINEITEM.DISCOUNT)", _dblConv));
        inputTupleSchema.add(new ColumnNameType("LINEITEM.ORDERKEY", _lc)); // not used
       
        DataSourceComponent source = new DataSourceComponent("TestFullExprs", "", new QueryPlan());
       
        NameSelectItemsVisitor selectVisitor = new NameSelectItemsVisitor(new TupleSchema(inputTupleSchema), _map, source);
        for(SelectItem elem: _pq.getSelectItems()){
            elem.accept(selectVisitor);
        }
View Full Code Here

Examples of plan_runner.components.DataSourceComponent

    final SelectOperator selectionCustomer = new SelectOperator(new ComparisonPredicate(
        new ColumnReference(_sc, 6), new ValueSpecification(_sc, _customerMktSegment)));

    final ProjectOperator projectionCustomer = new ProjectOperator(new int[] { 0 });

    final DataSourceComponent relationCustomer = new DataSourceComponent("CUSTOMER", dataPath
        + "customer" + extension, _queryPlan).setHashIndexes(hashCustomer)
        .addOperator(selectionCustomer).addOperator(projectionCustomer);

    // -------------------------------------------------------------------------------------
    final List<Integer> hashOrders = Arrays.asList(1);

    final SelectOperator selectionOrders = new SelectOperator(new ComparisonPredicate(
        ComparisonPredicate.LESS_OP, new ColumnReference(_dateConv, 4),
        new ValueSpecification(_dateConv, _date)));

    final ProjectOperator projectionOrders = new ProjectOperator(new int[] { 0, 1, 4, 7 });

    final DataSourceComponent relationOrders = new DataSourceComponent("ORDERS", dataPath
        + "orders" + extension, _queryPlan).setHashIndexes(hashOrders)
        .addOperator(selectionOrders).addOperator(projectionOrders);

    new EquiJoinComponent(relationCustomer, relationOrders, _queryPlan).addOperator(
        new ProjectOperator(new int[] { 1, 2, 3 })).setHashIndexes(Arrays.asList(0));

    // -------------------------------------------------------------------------------------
    final List<Integer> hashLineitem = Arrays.asList(0);

    final SelectOperator selectionLineitem = new SelectOperator(new ComparisonPredicate(
        ComparisonPredicate.GREATER_OP, new ColumnReference(_dateConv, 10),
        new ValueSpecification(_dateConv, _date)));

    final ProjectOperator projectionLineitem = new ProjectOperator(new int[] { 0, 5, 6 });

    new DataSourceComponent("LINEITEM", dataPath + "lineitem" + extension, _queryPlan)
        .setHashIndexes(hashLineitem).addOperator(selectionLineitem)
        .addOperator(projectionLineitem).setPrintOut(false);

    // -------------------------------------------------------------------------------------
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.