Package com.sun.star.sdbc

Examples of com.sun.star.sdbc.XResultSet


    }

    /* ------------------------------------------------------------------ */
    private void moveToFirst() throws com.sun.star.uno.Exception, java.lang.Exception
    {
        XResultSet xResultSet = (XResultSet)UnoRuntime.queryInterface( XResultSet.class, m_masterForm );
        xResultSet.first( );
    }
View Full Code Here


    }

    /* ------------------------------------------------------------------ */
    private void moveToNext() throws com.sun.star.uno.Exception, java.lang.Exception
    {
        XResultSet xResultSet = (XResultSet)UnoRuntime.queryInterface( XResultSet.class, m_masterForm );
        xResultSet.next( );
    }
View Full Code Here

        };
        try
        {
            String[] sTableNames = super.getCommandMetaData().getTableNames();
            Vector aReferencedTableVector = new Vector();
            XResultSet xResultSet = super.getCommandMetaData().xDBMetaData.getExportedKeys((getCatalogName(this)), getSchemaName(), getTableName());
            XRow xRow = (XRow) UnoRuntime.queryInterface(XRow.class, xResultSet);
            while (xResultSet.next())
            {
                String sForeignCatalog = xRow.getString(FKTABLE_CAT);
                String sForeignScheme = xRow.getString(FKTABLE_SCHEM);
                String sForeignTableName = xRow.getString(FKTABLE_NAME);
                CommandName oCommandName = new CommandName(getCommandMetaData(), sForeignCatalog, sForeignScheme, sForeignTableName, false);
View Full Code Here

        {
        };
        try
        {
            CommandName oLocCommandName = new CommandName(super.getCommandMetaData(), _sreferencedtablename);
            XResultSet xResultSet = super.getCommandMetaData().xDBMetaData.getImportedKeys(getCatalogName(oLocCommandName), oLocCommandName.getSchemaName(), oLocCommandName.getTableName());
            XRow xRow = (XRow) UnoRuntime.queryInterface(XRow.class, xResultSet);
            boolean bleaveLoop = false;
            Vector aMasterFieldNamesVector = new Vector();
            Vector aSlaveFieldNamesVector = new Vector();
            while (xResultSet.next() && !bleaveLoop)
            {
                String sPrimaryCatalog = null;
                String sPrimarySchema = null;
                if (super.getCommandMetaData().xDBMetaData.supportsCatalogsInDataManipulation())
                {
View Full Code Here

            log.println("Couldn't get OEditControl");
            e.printStackTrace(log);
            throw new StatusException("Couldn't get OEditControl", e);
        }

        XResultSet the_set = (XResultSet) UnoRuntime.queryInterface(
                                     XResultSet.class, oObj);

        try {
            the_set.first();
        } catch (SQLException e) {
            log.println("Cann't move cursor to the first row.");
            e.printStackTrace();
            throw new StatusException("Can't move cursor to the first row.", e);
        }

        tEnv.addObjRelation("Model1", shape1.getControl());
        tEnv.addObjRelation("Model2", shape2.getControl());


        // adding an object for XNameReplace testing
        log.println("adding oInstace as obj relation to environment");
        tEnv.addObjRelation("INSTANCE", oInstance);


        // INDEX : _XNameContainer
        log.println("adding INDEX as obj relation to environment");
        tEnv.addObjRelation("INDEX", "0");


        // INDEX : _XNameReplace
        log.println("adding NameReplaceIndex as obj relation to environment");
        tEnv.addObjRelation("XNameReplaceINDEX", "2");


        // INSTANCEn : _XNameContainer; _XNameReplace
        log.println("adding INSTANCEn as obj relation to environment");

        //XComponent xComp = (XComponent)
        //    UnoRuntime.queryInterface(XComponent.class, xDrawDoc);
        String tc = (String) Param.get("THRCNT");
        int THRCNT = 1;

        if (tc != null) {
            THRCNT = Integer.parseInt(tc);
        }

        for (int n = 1; n < (2 * (THRCNT + 1)); n++) {
            log.println("adding INSTANCE" + n +
                        " as obj relation to environment");
            tEnv.addObjRelation("INSTANCE" + n,
                                FormTools.createControl(xTextDoc, "CheckBox"));
        }


        // adding relation for XNameContainer
        tEnv.addObjRelation("XNameContainer.AllowDuplicateNames", new Object());


        // adding relation for XPersistObject
        tEnv.addObjRelation("OBJNAME", "stardiv.one.form.component.Form");

        if (the_set != null) {
            log.println("The Form has a not empty ResultSet");
        }

        // Adding obj relation for XRowSetApproveBroadcaster test
        final XResultSet xResSet = (XResultSet) UnoRuntime.queryInterface(
                                           XResultSet.class, oObj);
        final XResultSetUpdate xResSetUpdate = (XResultSetUpdate) UnoRuntime.queryInterface(
                                                       XResultSetUpdate.class,
                                                       oObj);
        final XRowSet xRowSet = (XRowSet) UnoRuntime.queryInterface(
                                        XRowSet.class, oObj);
        final PrintWriter logF = log;
        tEnv.addObjRelation("XRowSetApproveBroadcaster.ApproveChecker",
                            new ifc.sdb._XRowSetApproveBroadcaster.RowSetApproveChecker() {
            public void moveCursor() {
                try {
                    xResSet.beforeFirst();
                    xResSet.afterLast();
                } catch (com.sun.star.sdbc.SQLException e) {
                    logF.println("### _XRowSetApproveBroadcaster." + "RowSetApproveChecker.moveCursor() :");
                    e.printStackTrace(logF);
                }
            }

            public RowChangeEvent changeRow() {
                try {
                    xResSet.first();

                    XRowUpdate row = (XRowUpdate) UnoRuntime.queryInterface(
                                             XRowUpdate.class, xResSet);
                    row.updateString(1, "1");
                    xResSetUpdate.updateRow();
                } catch (com.sun.star.sdbc.SQLException e) {
                    logF.println("### _XRowSetApproveBroadcaster." + "RowSetApproveChecker.changeRow() :");
                    e.printStackTrace(logF);
                }

                RowChangeEvent ev = new RowChangeEvent();
                ev.Action = com.sun.star.sdb.RowChangeAction.UPDATE;
                ev.Rows = 1;

                return ev;
            }

            public void changeRowSet() {
                try {
                    xRowSet.execute();
                } catch (com.sun.star.sdbc.SQLException e) {
                    logF.println("### _XRowSetApproveBroadcaster." + "RowSetApproveChecker.changeRowSet() :");
                    e.printStackTrace(logF);
                }
            }
        });


        // Adding relation for XColumnLocate test
        tEnv.addObjRelation("XColumnLocate.ColumnName", DBTools.TST_STRING_F);

        // Adding relation for XParameters ifc test
        Vector params = new Vector();


        /*****  statement parameter types and their initial
                values must be added here as relation. */
        params.add(new String("SAU99")) ;
        params.add(new Boolean(false)) ;
        params.add(new Byte((byte) 123)) ;
        params.add(new Short((short) 234)) ;
        params.add(new Integer(12345)) ;
        params.add(new Long(23456)) ;
        params.add(new Float(1.234)) ;
        params.add(new Double(2.345)) ;
        params.add(new byte[] {1, 2, 3}) ;
        Date d = new Date();
        d.Day = 26; d.Month = 1; d.Year = 2001;
        params.add(d) ;
        Time t = new Time();
        t.Hours = 1; t.HundredthSeconds = 12; t.Minutes = 25; t.Seconds = 14;
        params.add(t) ;
        DateTime dt = new DateTime();
        dt.Day = 26; dt.Month = 1; dt.Year = 2001; dt.Hours = 1;
        dt.HundredthSeconds = 12; dt.Minutes = 25; dt.Seconds = 14;
        params.add(dt) ;
        tEnv.addObjRelation("XParameters.ParamValues", params);

        // Adding relation for XCompletedExecution
        tEnv.addObjRelation("InteractionHandlerChecker", new InteractionHandlerImpl());
       
        // Adding for XWarningSupplier
        tEnv.addObjRelation("CheckWarningsSupplier", new Boolean(isMySQLDB));

        // Adding relation for XDatabaseParameterBroadcaster
        tEnv.addObjRelation("ParameterListenerChecker", new ODatabaseForm.ParameterListenerImpl());  
        XPropertySet xSetProp = (XPropertySet) UnoRuntime.queryInterface
            (XPropertySet.class, oObj) ;
        try {
            xSetProp.setPropertyValue("DataSourceName", dbSourceName) ;
            if(isMySQLDB) {
                xSetProp.setPropertyValue("Command", "SELECT Column0  FROM soffice_test_table  WHERE ( (  Column0 = :param1 ) )");
            }
            else {
                xSetProp.setPropertyValue("Command", "SELECT \"_TEXT\" FROM \"ODatabaseForm_tmp0\" WHERE ( ( \"_TEXT\" = :param1 ) )");
            }
               
            xSetProp.setPropertyValue("CommandType",
                new Integer(CommandType.COMMAND)) ;
        }
        catch(Exception e) {
        }

        // Adding relation for XResultSetUpdate
        final XRowUpdate xRowUpdate = (XRowUpdate) UnoRuntime.queryInterface(
                                              XRowUpdate.class, oObj);
        final XRow xRow = (XRow) UnoRuntime.queryInterface(XRow.class, oObj);

        tEnv.addObjRelation("XResultSetUpdate.UpdateTester",
                            new ifc.sdbc._XResultSetUpdate.UpdateTester() {
            String lastUpdate = null;

            public int rowCount() throws SQLException {
                int prevPos = xResSet.getRow();
                xResSet.last();

                int count = xResSet.getRow();
                xResSet.absolute(prevPos);

                return count;
            }

            public void update() throws SQLException {
                lastUpdate = xRow.getString(1);
                lastUpdate += "_";
                xRowUpdate.updateString(1, lastUpdate);
            }

            public boolean wasUpdated() throws SQLException {
                String getStr = xRow.getString(1);

                return lastUpdate.equals(getStr);
            }

            public int currentRow() throws SQLException {
                return xResSet.getRow();
            }
        });

        // Adding relations for XRow as a Vector with all data
        // of current row of RowSet.
View Full Code Here

            XDynamicResultSet set;

            // Execute command "open".
            set = ( XDynamicResultSet )UnoRuntime.queryInterface(
                XDynamicResultSet.class, m_helper.executeCommand( m_content, "open", arg ));
            XResultSet resultSet = ( XResultSet )set.getStaticResultSet();

            result = new Vector();

            /////////////////////////////////////////////////////////////////////
            // Iterate over children, access children and property values...
            /////////////////////////////////////////////////////////////////////

                // Move to begin.
            if ( resultSet.first() ) {
                XContentAccess contentAccess = ( XContentAccess )UnoRuntime.queryInterface(
                    XContentAccess.class, resultSet );
                XRow row = ( XRow )UnoRuntime.queryInterface( XRow.class, resultSet );

                do {
                    Vector propsValues = new Vector();

                    // Obtain URL of child.
                    String id = contentAccess.queryContentIdentifierString();
                    propsValues.add( id );
                    for ( int i = 1; i <= size ; i++)  {
                        Object propValue = row.getObject( i, null );
                        if ( !row.wasNull() && !(propValue instanceof com.sun.star.uno.Any )) {
                            propsValues.add( propValue );
                        } else {
                            propsValues.add( "[ Property not found ]" );
                        }
                    }
                    result.add( propsValues );
                } while ( resultSet.next() ); // next child
            }
        }
        return result;
    }
View Full Code Here

            XDynamicResultSet set;

            // Execute command "open".
            set = ( XDynamicResultSet )UnoRuntime.queryInterface(
                XDynamicResultSet.class, m_helper.executeCommand( m_content, "open", arg ));
            XResultSet resultSet = ( XResultSet )set.getStaticResultSet();

            result = new Vector();

            /////////////////////////////////////////////////////////////////////
            // Iterate over children, access children and property values...
            /////////////////////////////////////////////////////////////////////

                // Move to begin.
            if ( resultSet.first() ) {
                XContentAccess contentAccess = ( XContentAccess )UnoRuntime.queryInterface(
                    XContentAccess.class, resultSet );
                XRow row = ( XRow )UnoRuntime.queryInterface( XRow.class, resultSet );

                do {
                    Vector propsValues = new Vector();

                    // Obtain URL of child.
                    String id = contentAccess.queryContentIdentifierString();
                    propsValues.add( id );
                    for ( int i = 1; i <= size ; i++)  {
                        Object propValue = row.getObject( i, null );
                        if ( !row.wasNull() && !(propValue instanceof com.sun.star.uno.Any )) {
                            propsValues.add( propValue );
                        } else {
                            propsValues.add( "[ Property not found ]" );
                        }
                    }
                    result.add( propsValues );
                } while ( resultSet.next() ); // next child
            }
        }
        return result;
    }
View Full Code Here

    }

    /* ------------------------------------------------------------------ */
    private void moveToFirst() throws com.sun.star.uno.Exception, java.lang.Exception
    {
        XResultSet xResultSet = (XResultSet)UnoRuntime.queryInterface( XResultSet.class, m_masterForm );
        xResultSet.first( );
    }
View Full Code Here

    }

    /* ------------------------------------------------------------------ */
    private void moveToNext() throws com.sun.star.uno.Exception, java.lang.Exception
    {
        XResultSet xResultSet = (XResultSet)UnoRuntime.queryInterface( XResultSet.class, m_masterForm );
        xResultSet.next( );
    }
View Full Code Here

            //Object prepStmnt = xConnection.prepareStatement("SELECT * FROM t1 WHERE t1.c1 = ?");
            Object prepStmnt = xConnection.prepareStatement("SELECT * FROM i90114 WHERE i90114.c1 = ?");
            ((XParameters) UnoRuntime.queryInterface(XParameters.class, prepStmnt)).clearParameters();
            ((XParameters) UnoRuntime.queryInterface(XParameters.class, prepStmnt)).setInt(1, 1);
            XResultSet xResultSet = ((XPreparedStatement) prepStmnt).executeQuery();
            XRow xRow = (XRow) UnoRuntime.queryInterface(XRow.class, xResultSet);

            XResultSetMetaDataSupplier xRsMetaSup = (XResultSetMetaDataSupplier) UnoRuntime.queryInterface(XResultSetMetaDataSupplier.class, xResultSet);
            XResultSetMetaData xRsMetaData = xRsMetaSup.getMetaData();
            int nColumnCount = xRsMetaData.getColumnCount();

            System.out.println("== MetaData ==");
            for (int i = 1; i <= nColumnCount; ++i)
            {
                System.out.println("Name: " + xRsMetaData.getColumnName(i) + " Type: " +
                        xRsMetaData.getColumnType(i));
            }

            System.out.println("== Result ==");
            while (xResultSet.next())
            {
                String str = "not set";

                XClob xClob = null;
                xClob = xRow.getClob(2);
View Full Code Here

TOP

Related Classes of com.sun.star.sdbc.XResultSet

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.