Package com.sun.star.sdbc

Examples of com.sun.star.sdbc.XResultSet


            command.Name = "open";
            command.Argument = cmargs2;

            Object result = xCommandProcessor.execute(command, 0, null);
            XDynamicResultSet xDynamicResultSet = UnoRuntime.queryInterface(XDynamicResultSet.class, result);
            XResultSet xResultSet = xDynamicResultSet.getStaticResultSet();
            XRow xRow = UnoRuntime.queryInterface(XRow.class, xResultSet);
            // create the new folder 'folderName': first, check if it's already there
            while(xResultSet.next()) {
                String existingFolderName = xRow.getString(1);
                System.out.println("Found existing folder: '" + existingFolderName + "'");
                if (folderName.equals(existingFolderName)) {
                    fail("Cannot create a new folder: folder already exists: adapt test or choose a different document.");
                }
View Full Code Here


            final XRowSet rowSet = UnoRuntime.queryInterface( XRowSet.class, m_rowSet);                  
            rowSet.execute();
            m_connection = UnoRuntime.queryInterface( XConnection.class, rowSetProps.getPropertyValue("ActiveConnection") );

            XResultSet xRes = UnoRuntime.queryInterface( XResultSet.class, m_rowSet );
            xRes.first();

            log.println( "creating a new environment for object" );
            TestEnvironment tEnv = new TestEnvironment( (XInterface)m_rowSet );

            // Adding obj relation for XRowSetApproveBroadcaster test
            {
                final XResultSet resultSet = UnoRuntime.queryInterface( XResultSet.class, m_rowSet );
                final XResultSetUpdate resultSetUpdate = UnoRuntime.queryInterface( XResultSetUpdate.class, m_rowSet );
                final XRowUpdate rowUpdate = UnoRuntime.queryInterface(XRowUpdate.class, m_rowSet );
                final PrintWriter logF = log ;
                tEnv.addObjRelation( "XRowSetApproveBroadcaster.ApproveChecker",
                    new ifc.sdb._XRowSetApproveBroadcaster.RowSetApproveChecker()
                    {
                        public void moveCursor()
                        {
                            try
                            {
                                resultSet.beforeFirst();
                                resultSet.afterLast();
                                resultSet.first();
                            }
                            catch (com.sun.star.sdbc.SQLException e)
                            {
                                logF.println("### _XRowSetApproveBroadcaster.RowSetApproveChecker.moveCursor() :");
                                e.printStackTrace(logF);
                                throw new StatusException( "RowSetApproveChecker.moveCursor failed", e );
                            }
                        }
                        public RowChangeEvent changeRow()
                        {
                            try
                            {
                                resultSet.first();
                                rowUpdate.updateString(1, "ORowSetTest2");
                                resultSetUpdate.updateRow();
                            }
                            catch (com.sun.star.sdbc.SQLException e)
                            {
                                logF.println("### _XRowSetApproveBroadcaster.RowSetApproveChecker.changeRow() :");
                                e.printStackTrace(logF);
                                throw new StatusException( "RowSetApproveChecker.changeRow failed", e );
                            }
                            RowChangeEvent ev = new RowChangeEvent();
                            ev.Action = com.sun.star.sdb.RowChangeAction.UPDATE ;
                            ev.Rows = 1 ;

                            return ev ;
                        }
                        public void changeRowSet()
                        {
                            try
                            {
                                // since we gave the row set a parametrized statement, we need to ensure the
                                // parameter is actually filled, otherwise we would get an empty result set,
                                // which would imply some further tests failing
                                XParameters rowSetParams = UnoRuntime.queryInterface( XParameters.class, resultSet );
                                rowSetParams.setString( 1, "String2" );
                                rowSet.execute();
                                resultSet.first();
                            }
                            catch (com.sun.star.sdbc.SQLException e)
                            {
                                logF.println("### _XRowSetApproveBroadcaster.RowSetApproveChecker.changeRowSet() :");
                                e.printStackTrace(logF);
                                throw new StatusException( "RowSetApproveChecker.changeRowSet failed", e );
                            }
                        }
                    }
                );
            }
            // Adding relations for XRow as a Vector with all data
            // of current row of RowSet.

            Vector rowData = new Vector();

            for (int i = 0; i < DBTools.TST_TABLE_VALUES[0].length; i++) {
                rowData.add(DBTools.TST_TABLE_VALUES[0][i]);
            }

            // here XRef must be added
            // here XBlob must be added
            // here XClob must be added
            // here XArray must be added

            tEnv.addObjRelation("CurrentRowData", rowData);

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

            // Adding relation for XCompletedExecution
            tEnv.addObjRelation( "InteractionHandlerChecker", new InteractionHandlerImpl() );
            try
            {
                String sqlCommand = isMySQLDB
                    ?   "SELECT Column0  FROM soffice_test_table  WHERE ( (  Column0 = :param1 ) )"
                    :   "SELECT \"_TEXT\" FROM \"" + tableName + "\" WHERE ( ( \"_TEXT\" = :param1 ) )";
                rowSetProps.setPropertyValue( "DataSourceName", dbSourceName );
                rowSetProps.setPropertyValue( "Command", sqlCommand );
                rowSetProps.setPropertyValue( "CommandType", new Integer(CommandType.COMMAND) );
            }
            catch(Exception e)
            {
                throw new StatusException( "setting up the RowSet with a parametrized command failed", e );
            }

            // Adding relation for XParameters ifc test
            tEnv.addObjRelation( "XParameters.ParamValues", new Vector() );

            // Adding relation for XRowUpdate
            final XRow row = UnoRuntime.queryInterface( XRow.class, m_rowSet );
            tEnv.addObjRelation("XRowUpdate.XRow", row);

            // Adding relation for XResultSetUpdate
            {
                final XResultSet resultSet = UnoRuntime.queryInterface( XResultSet.class, m_rowSet );
                final XRowUpdate rowUpdate = UnoRuntime.queryInterface( XRowUpdate.class, m_rowSet );

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

                        public int rowCount() throws SQLException
                        {
                            int prevPos = resultSet.getRow();
                            resultSet.last();
                            int count = resultSet.getRow();
                            resultSet.absolute(prevPos);

                            return count ;
                        }

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

                        public boolean wasUpdated() throws SQLException
                        {
                            String getStr = row.getString(1);
                            return lastUpdate.equals(getStr);
                        }

                        public int currentRow() throws SQLException
                        {
                            return resultSet.getRow();
                        }
                    }
                );
            }
View Full Code Here

    public int deleteAllRows(XConnection con, String table)
        throws com.sun.star.sdbc.SQLException {

        XStatement stat = con.createStatement() ;

        XResultSet set = stat.executeQuery("SELECT * FROM " + table) ;

        XResultSetUpdate updt = (XResultSetUpdate) UnoRuntime.queryInterface
            (XResultSetUpdate.class, set) ;

        int count = 0 ;
        set.last() ;
        int rowNum = set.getRow() ;
        set.first() ;

        for (int i = 0; i < rowNum; i++) {
            updt.deleteRow() ;
            set.next() ;
            count ++ ;
        }

        XCloseable xClose = (XCloseable) UnoRuntime.queryInterface
            (XCloseable.class, set) ;
View Full Code Here

        int streamLength)
        throws com.sun.star.sdbc.SQLException {

        XStatement stat = con.createStatement() ;

        XResultSet set = stat.executeQuery("SELECT * FROM " + table) ;

        XResultSetUpdate updt = (XResultSetUpdate) UnoRuntime.queryInterface
            (XResultSetUpdate.class, set) ;

        XRowUpdate rowUpdt = (XRowUpdate) UnoRuntime.queryInterface
View Full Code Here

    public String[] getCatalogNames()
    {
        try
        {
            XResultSet xResultSet = xDBMetaData.getCatalogs();
            return StringsFromResultSet(xResultSet, 1);
        }
        catch (SQLException e)
        {
            Logger.getLogger( DBMetaData.class.getName() ).log( Level.SEVERE, null, e );
View Full Code Here

    public String[] getSchemaNames()
    {
        try
        {
            XResultSet xResultSet = xDBMetaData.getSchemas();
            return StringsFromResultSet(xResultSet, 1);
        }
        catch (SQLException e)
        {
            Logger.getLogger( DBMetaData.class.getName() ).log( Level.SEVERE, null, e );
View Full Code Here

        XDynamicResultSet xSet;

        xSet = UnoRuntime.queryInterface(
          XDynamicResultSet.class,executeCommand(xContent, "open", aArg));

        XResultSet xResultSet = xSet.getStaticResultSet();
       
        List files = new Vector();

        if (xResultSet.first())
        {
            // obtain XContentAccess interface for child content access and XRow for properties
            XContentAccess xContentAccess = UnoRuntime.queryInterface(
                XContentAccess.class, xResultSet);
            XRow xRow = UnoRuntime.queryInterface(XRow.class, xResultSet);
            do
            {
                // Obtain URL of child.
                String aId = xContentAccess.queryContentIdentifierString();
                // First column: Title (column numbers are 1-based!)
                String aTitle = xRow.getString(1);
                if (aTitle.length() == 0 && xRow.wasNull())
                {
                    //ignore
                }
                else
                {
                    files.add(aTitle);
                }
            }
            while (xResultSet.next()); // next child
        }
       
        if (verifier != null)
        {
            for (int i = 0; i<files.size(); i++)
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 = 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 = 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

        if (resSet == null) {
            log.println("!!! Method returned null !!!") ;
            result = false ;
        } else {
            try {
                XResultSet resSetS = resSet.getStaticResultSet() ;
                XResultSet resSetStubS = resSetStub.getStaticResultSet() ;

                resSetStubS.last() ;
                int stubRowNum = resSetStubS.getRow() ;

                resSetS.last() ;
                int setRowNum = resSetS.getRow() ;

                result = stubRowNum == setRowNum && setRowNum > 0 ;
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.