Package com.sun.star.sdbc

Examples of com.sun.star.sdbc.XPreparedStatement


                                // silent this error, this was just a try. If we're here, we did not change sStatementToExecute,
                                // so it will still be _rCommand, which then will be executed without being touched
                            }

                            // now execute
                            final XPreparedStatement xStatement = connection.prepareStatement(sStatementToExecute);
                            // transfer ownership of this temporary object to the caller
                            out[0] = (XComponent) UnoRuntime.queryInterface(XComponent.class, xStatement);

                            // set the "MaxRows" to 0. This is just in case our attempt to append a 0=1 filter
                            // failed - in this case, the MaxRows restriction should at least ensure that there
                            // is no data returned (which would be potentially expensive)
                            final XPropertySet xStatementProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xStatement);
                            try
                            {
                                if ( xStatementProps != null )
                                {
                                    xStatementProps.setPropertyValue("MaxRows", new Integer(0));
                                }
                            } catch ( com.sun.star.uno.Exception ex )
                            {
                                // oh damn. Not much of a chance to recover, we will no retrieve the complete
                                // full blown result set
                            }

                            xSupplyColumns = (XColumnsSupplier) UnoRuntime.queryInterface(XColumnsSupplier.class, xStatement.executeQuery());
                            // this should have given us a result set which does not contain any data, but
                            // the structural information we need

                            // so the next state is to get the columns
                            eState = RETRIEVE_COLUMNS;
View Full Code Here


    {
        m_database.executeSQL("DROP TABLE \"TEST1\" IF EXISTS");
        m_database.executeSQL("CREATE TABLE \"TEST1\" (\"ID\" integer not null primary key, \"col2\" varchar(50) )");

        final XConnection connection = m_database.defaultConnection();
        final XPreparedStatement prep = connection.prepareStatement("INSERT INTO \"TEST1\" values (?,?)");
        final XParameters para = (XParameters) UnoRuntime.queryInterface(XParameters.class, prep);
        for (int i = 1; i <= MAX_TABLE_ROWS; ++i)
        {
            para.setInt(1, i);
            para.setString(2, "Test" + i);
            prep.executeUpdate();
        }

        final XTablesSupplier suppTables = (XTablesSupplier) UnoRuntime.queryInterface(XTablesSupplier.class, connection);
        final XRefreshable refresh = (XRefreshable) UnoRuntime.queryInterface(XRefreshable.class, suppTables.getTables());
        refresh.refresh();
View Full Code Here

                            // silent this error, this was just a try. If we're here, we did not change sStatementToExecute,
                            // so it will still be _rCommand, which then will be executed without being touched
                            }

                        // now execute
                        final XPreparedStatement xStatement = connection.prepareStatement(sStatementToExecute);
                        // transfer ownership of this temporary object to the caller
                        out[0] = (XComponent) UnoRuntime.queryInterface(XComponent.class, xStatement);

                        // set the "MaxRows" to 0. This is just in case our attempt to append a 0=1 filter
                        // failed - in this case, the MaxRows restriction should at least ensure that there
                        // is no data returned (which would be potentially expensive)
                        final XPropertySet xStatementProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xStatement);
                        try
                        {
                            if (xStatementProps != null)
                            {
                                xStatementProps.setPropertyValue("MaxRows", Integer.valueOf(0));
                            }
                        }
                        catch (com.sun.star.uno.Exception ex)
                        {
                            // oh damn. Not much of a chance to recover, we will no retrieve the complete
                            // full blown result set
                            }

                        xSupplyColumns = (XColumnsSupplier) UnoRuntime.queryInterface(XColumnsSupplier.class, xStatement.executeQuery());
                        // this should have given us a result set which does not contain any data, but
                        // the structural information we need

                        // so the next state is to get the columns
                        eState = RETRIEVE_COLUMNS;
View Full Code Here

    {
        m_database.executeSQL("DROP TABLE \"TEST1\" IF EXISTS");
        m_database.executeSQL("CREATE TABLE \"TEST1\" (\"ID\" integer not null primary key, \"col2\" varchar(50) )");

        final Connection connection = m_database.defaultConnection();
        final XPreparedStatement prep = connection.prepareStatement("INSERT INTO \"TEST1\" values (?,?)");
        final XParameters para = UnoRuntime.queryInterface( XParameters.class, prep );
        for (int i = 1; i <= MAX_TABLE_ROWS; ++i)
        {
            para.setInt(1, i);
            para.setString(2, "Test" + i);
            prep.executeUpdate();
        }

        connection.refreshTables();
    }
View Full Code Here

                            // silent this error, this was just a try. If we're here, we did not change sStatementToExecute,
                            // so it will still be _rCommand, which then will be executed without being touched
                            }

                        // now execute
                        final XPreparedStatement xStatement = connection.prepareStatement(sStatementToExecute);
                        // transfer ownership of this temporary object to the caller
                        out[0] = (XComponent) UnoRuntime.queryInterface(XComponent.class, xStatement);

                        // set the "MaxRows" to 0. This is just in case our attempt to append a 0=1 filter
                        // failed - in this case, the MaxRows restriction should at least ensure that there
                        // is no data returned (which would be potentially expensive)
                        final XPropertySet xStatementProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xStatement);
                        try
                        {
                            if (xStatementProps != null)
                            {
                                xStatementProps.setPropertyValue("MaxRows", Integer.valueOf(0));
                            }
                        }
                        catch (com.sun.star.uno.Exception ex)
                        {
                            // oh damn. Not much of a chance to recover, we will no retrieve the complete
                            // full blown result set
                            }

                        xSupplyColumns = (XColumnsSupplier) UnoRuntime.queryInterface(XColumnsSupplier.class, xStatement.executeQuery());
                        // this should have given us a result set which does not contain any data, but
                        // the structural information we need

                        // so the next state is to get the columns
                        eState = RETRIEVE_COLUMNS;
View Full Code Here

                                // silent this error, this was just a try. If we're here, we did not change sStatementToExecute,
                                // so it will still be _rCommand, which then will be executed without being touched
                            }

                            // now execute
                            XPreparedStatement xStatement = connection.prepareStatement(sStatementToExecute);
                            // transfer ownership of this temporary object to the caller
                            out[0] = (XComponent) UnoRuntime.queryInterface(XComponent.class, xStatement);

                            // set the "MaxRows" to 0. This is just in case our attempt to append a 0=1 filter
                            // failed - in this case, the MaxRows restriction should at least ensure that there
                            // is no data returned (which would be potentially expensive)
                            final XPropertySet xStatementProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xStatement);
                            try
                            {
                                if (xStatementProps != null)
                                {
                                    xStatementProps.setPropertyValue("MaxRows", new Integer(0));
                                }
                            }
                            catch (com.sun.star.uno.Exception ex)
                            {
                                // oh damn. Not much of a chance to recover, we will no retrieve the complete
                                // full blown result set
                            }

                            xSupplyColumns = (XColumnsSupplier) UnoRuntime.queryInterface(XColumnsSupplier.class, xStatement.executeQuery());
                            // this should have given us a result set which does not contain any data, but
                            // the structural information we need

                            // so the next state is to get the columns
                            eState = RETRIEVE_COLUMNS;
View Full Code Here

                // insert a few rows
                StringBuffer sql = new StringBuffer();
                sql.append( "INSERT INTO \"" );
                sql.append( tableName );
                sql.append( "\" VALUES (?, ?)");
                XPreparedStatement statement = connection.prepareStatement( sql.toString() );
                XParameters statementParameters = UnoRuntime.queryInterface( XParameters.class, statement );

                final String[] keyValues = impl_getTypedValue( keyTypes[i], 0 );

                for ( int row=0; row<displayValues.length; ++row )
                {
                    statementParameters.setString( 1, keyValues[row] );
                    statementParameters.setString( 2, displayValues[row] );
                    statement.execute();
                }

                // remember a column descriptor for later creation of the table with the foreign keys
                foreignKeyColumns.addnew HsqlColumnDescriptor( columnFKName, columnType, HsqlColumnDescriptor.REQUIRED,
                    tableName, columnPKName ) );

                // remember the data to fill into this table
                foreignKeyValues.add( keyValues );
                foreignKeyInsertSQL.append( ", ?" );
            }

            // create the table taking all those foreign keys
            m_database.createTable( new HsqlTableDescriptor( m_foreignKeyTableName, foreignKeyColumns.toArray( new HsqlColumnDescriptor[0] ) ) );
            // fill in some data
            foreignKeyInsertSQL.append( ")" );
            XPreparedStatement statement = connection.prepareStatement( foreignKeyInsertSQL.toString() );
            XParameters statementParameters = UnoRuntime.queryInterface( XParameters.class, statement );
            for ( int row=0; row<2; ++row )
            {
                statementParameters.setInt( 1, row );
                for ( int i=0; i<keyTypes.length; ++i )
                {
                    statementParameters.setString( i+2, foreignKeyValues.get(i)[row] );
                }
                statement.execute();
            }

            m_database.defaultConnection().refreshTables();
        }
        finally
View Full Code Here

    {
        m_database.executeSQL("DROP TABLE \"TEST1\" IF EXISTS");
        m_database.executeSQL("CREATE TABLE \"TEST1\" (\"ID\" integer not null primary key, \"col2\" varchar(50) )");

        final XConnection connection = m_database.defaultConnection();
        final XPreparedStatement prep = connection.prepareStatement("INSERT INTO \"TEST1\" values (?,?)");
        final XParameters para = (XParameters) UnoRuntime.queryInterface(XParameters.class, prep);
        for (int i = 1; i <= MAX_TABLE_ROWS; ++i)
        {
            para.setInt(1, i);
            para.setString(2, "Test" + i);
            prep.executeUpdate();
        }

        final XTablesSupplier suppTables = (XTablesSupplier) UnoRuntime.queryInterface(XTablesSupplier.class, connection);
        final XRefreshable refresh = (XRefreshable) UnoRuntime.queryInterface(XRefreshable.class, suppTables.getTables());
        refresh.refresh();
View Full Code Here

    {
        m_database.executeSQL("DROP TABLE \"TEST1\" IF EXISTS");
        m_database.executeSQL("CREATE TABLE \"TEST1\" (\"ID\" integer not null primary key, \"col2\" varchar(50) )");

        final Connection connection = m_database.defaultConnection();
        final XPreparedStatement prep = connection.prepareStatement("INSERT INTO \"TEST1\" values (?,?)");
        final XParameters para = UnoRuntime.queryInterface( XParameters.class, prep );
        for (int i = 1; i <= MAX_TABLE_ROWS; ++i)
        {
            para.setInt(1, i);
            para.setString(2, "Test" + i);
            prep.executeUpdate();
        }

        connection.refreshTables();
    }
View Full Code Here

                // insert a few rows
                StringBuffer sql = new StringBuffer();
                sql.append( "INSERT INTO \"" );
                sql.append( tableName );
                sql.append( "\" VALUES (?, ?)");
                XPreparedStatement statement = connection.prepareStatement( sql.toString() );
                XParameters statementParameters = UnoRuntime.queryInterface( XParameters.class, statement );

                final String[] keyValues = impl_getTypedValue( keyTypes[i], 0 );

                for ( int row=0; row<displayValues.length; ++row )
                {
                    statementParameters.setString( 1, keyValues[row] );
                    statementParameters.setString( 2, displayValues[row] );
                    statement.execute();
                }

                // remember a column descriptor for later creation of the table with the foreign keys
                foreignKeyColumns.addnew HsqlColumnDescriptor( columnFKName, columnType, HsqlColumnDescriptor.REQUIRED,
                    tableName, columnPKName ) );

                // remember the data to fill into this table
                foreignKeyValues.add( keyValues );
                foreignKeyInsertSQL.append( ", ?" );
            }

            // create the table taking all those foreign keys
            m_database.createTable( new HsqlTableDescriptor( m_foreignKeyTableName, foreignKeyColumns.toArray( new HsqlColumnDescriptor[0] ) ) );
            // fill in some data
            foreignKeyInsertSQL.append( ")" );
            XPreparedStatement statement = connection.prepareStatement( foreignKeyInsertSQL.toString() );
            XParameters statementParameters = UnoRuntime.queryInterface( XParameters.class, statement );
            for ( int row=0; row<2; ++row )
            {
                statementParameters.setInt( 1, row );
                for ( int i=0; i<keyTypes.length; ++i )
                {
                    statementParameters.setString( i+2, foreignKeyValues.get(i)[row] );
                }
                statement.execute();
            }

            m_database.defaultConnection().refreshTables();
        }
        finally
View Full Code Here

TOP

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

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.