Examples of SyncProviderException


Examples of javax.sql.rowset.spi.SyncProviderException

        assertEquals(copy.getString(2), "updated");
        assertEquals(crset.getString(2), "again");

        crset.updateRow();

        SyncProviderException ex = null;
        try {
            crset.acceptChanges(conn);
        } catch (SyncProviderException e) {
            ex = e;
        }

        SyncResolver resolver = ex.getSyncResolver();

        try {
            resolver.absolute(1);
            fail("Should throw UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
View Full Code Here

Examples of javax.sql.rowset.spi.SyncProviderException

    }

    public void acceptChanges() throws SyncProviderException {
        if (isCursorOnInsert) {
            // rowset.11=Illegal operation on an insert row
            throw new SyncProviderException(Messages.getString("rowset.11")); //$NON-NLS-1$
        }

        Connection currentConn = null;
        Connection preConn = conn;
        try {
            currentConn = retrieveConnection();
            currentConn.setTypeMap(getTypeMap());
            acceptChanges(currentConn);
            currentConn.commit();
        } catch (SQLException e) {
            try {
                if (currentConn != null) {
                    currentConn.rollback();
                }
            } catch (SQLException ex) {
                // ignore
            }
            SyncProviderException ex = new SyncProviderException();
            ex.initCause(e);
            throw ex;
        } finally {
            conn = preConn;
            if (currentConn != null) {
                try {
                    currentConn.close();
                } catch (SQLException ex) {
                    SyncProviderException spe = new SyncProviderException();
                    spe.initCause(ex);
                    throw spe;
                }
            }
        }
    }
View Full Code Here

Examples of javax.sql.rowset.spi.SyncProviderException

    public void acceptChanges(Connection connection)
            throws SyncProviderException {
        if (isCursorOnInsert) {
            // rowset.11=Illegal operation on an insert row
            throw new SyncProviderException(Messages.getString("rowset.11")); //$NON-NLS-1$
        }

        // Follow RI to assign conn before checking whether conn is null
        conn = connection;

        if (conn == null) {
            // rowset.31=No current connection
            throw new SyncProviderException(Messages.getString("rowset.31")); //$NON-NLS-1$
        }

        boolean isShowDeleted = false;
        try {
            isShowDeleted = getShowDeleted();
        } catch (SQLException e) {
            // ignore
        }

        try {
            conn.setAutoCommit(false);
            CachedRowSetWriter rowSetWriter = (CachedRowSetWriter) syncProvider
                    .getRowSetWriter();
            rowSetWriter.setConnection(conn);
            int beforeWriteIndex = currentRowIndex;
            // writer use next navigate rowset, so must make all rows visible
            setShowDeleted(true);

            if (!rowSetWriter.writeData(this)) {
                throw rowSetWriter.getSyncException();
            }

            // must reset curosr before reset showDeleted
            absolute(beforeWriteIndex);
            setShowDeleted(isShowDeleted);

            // record to the next visible row index
            int index = getRow();
            if (index == 0) {
                next();
                index = getRow();
                if (index == 0) {
                    index = rows.size() + 1;
                }
            }

            boolean isChanged = false;
            for (int i = rows.size() - 1; i >= 0; i--) {
                currentRow = rows.get(i);
                if (rowDeleted()) {
                    isChanged = true;
                    setOriginalRow();
                } else if (rowInserted() || rowUpdated()) {
                    isChanged = true;
                    setOriginalRow();
                }
            }
            // Set originalResultSet
            if (isChanged) {
                try {
                    ArrayList<CachedRow> nowRows = new ArrayList<CachedRow>();
                    for (int i = 0; i < rows.size(); i++) {
                        nowRows.add(rows.get(i).createClone());
                        nowRows.get(i).restoreOriginal();
                    }
                    originalResultSet.setRows(nowRows, columnCount);
                } catch (CloneNotSupportedException cloneE) {
                    throw new SyncProviderException(cloneE.getMessage());
                }
            }

            deletedRowCount = 0;

            // move cursor
            if (index > rows.size()) {
                afterLast();
            } else if (index <= 0) {
                beforeFirst();
            } else {
                absolute(index);
            }

            if (isNotifyListener) {
                notifyRowSetChanged();
            }

        } catch (SyncProviderException e) {
            throw e;
        } catch (SQLException e) {
            SyncProviderException ex = new SyncProviderException();
            ex.initCause(e);
            throw ex;
        } finally {
            try {
                setShowDeleted(isShowDeleted);
            } catch (SQLException e) {
View Full Code Here

Examples of javax.sql.rowset.spi.SyncProviderException

    }

    public void acceptChanges() throws SyncProviderException {
        if (isCursorOnInsert) {
            // rowset.11=Illegal operation on an insert row
            throw new SyncProviderException(Messages.getString("rowset.11")); //$NON-NLS-1$
        }

        Connection currentConn = null;
        Connection preConn = conn;
        try {
            currentConn = retrieveConnection();
            currentConn.setTypeMap(getTypeMap());
            acceptChanges(currentConn);
            currentConn.commit();
        } catch (SQLException e) {
            try {
                if (currentConn != null) {
                    currentConn.rollback();
                }
            } catch (SQLException ex) {
                // ignore
            }
            SyncProviderException ex = new SyncProviderException();
            ex.initCause(e);
            throw ex;
        } finally {
            conn = preConn;
            if (currentConn != null) {
                try {
                    currentConn.close();
                } catch (SQLException ex) {
                    SyncProviderException spe = new SyncProviderException();
                    spe.initCause(ex);
                    throw spe;
                }
            }
        }
    }
View Full Code Here

Examples of javax.sql.rowset.spi.SyncProviderException

    public void acceptChanges(Connection connection)
            throws SyncProviderException {
        if (isCursorOnInsert) {
            // rowset.11=Illegal operation on an insert row
            throw new SyncProviderException(Messages.getString("rowset.11")); //$NON-NLS-1$
        }

        // Follow RI to assign conn before checking whether conn is null
        conn = connection;

        if (conn == null) {
            throw new SyncProviderException();
        }

        boolean isShowDeleted = false;
        try {
            isShowDeleted = getShowDeleted();
        } catch (SQLException e) {
            // ignore
        }

        try {
            conn.setAutoCommit(false);
            CachedRowSetWriter rowSetWriter = (CachedRowSetWriter) syncProvider
                    .getRowSetWriter();
            rowSetWriter.setConnection(conn);
            int beforeWriteIndex = currentRowIndex;
            // writer use next navigate rowset, so must make all rows visible
            setShowDeleted(true);

            if (!rowSetWriter.writeData(this)) {
                throw rowSetWriter.getSyncException();
            }

            // must reset curosr before reset showDeleted
            absolute(beforeWriteIndex);
            setShowDeleted(isShowDeleted);

            // record to the next visible row index
            int index = getRow();
            if (index == 0) {
                next();
                index = getRow();
                if (index == 0) {
                    index = rows.size() + 1;
                }
            }

            boolean isChanged = false;
            for (int i = rows.size() - 1; i >= 0; i--) {
                currentRow = rows.get(i);
                if (rowDeleted()) {
                    isChanged = true;
                    setOriginalRow();
                } else if (rowInserted() || rowUpdated()) {
                    isChanged = true;
                    setOriginalRow();
                }
            }
            // Set originalResultSet
            if (isChanged) {
                try {
                    ArrayList<CachedRow> nowRows = new ArrayList<CachedRow>();
                    for (int i = 0; i < rows.size(); i++) {
                        nowRows.add(rows.get(i).createClone());
                        nowRows.get(i).restoreOriginal();
                    }
                    originalResultSet.setRows(nowRows, columnCount);
                } catch (CloneNotSupportedException cloneE) {
                    throw new SyncProviderException(cloneE.getMessage());
                }
            }

            deletedRowCount = 0;

            // move cursor
            if (index > rows.size()) {
                afterLast();
            } else if (index <= 0) {
                beforeFirst();
            } else {
                absolute(index);
            }

            if (isNotifyListener) {
                notifyRowSetChanged();
            }

        } catch (SyncProviderException e) {
            throw e;
        } catch (SQLException e) {
            SyncProviderException ex = new SyncProviderException();
            ex.initCause(e);
            throw ex;
        } finally {
            try {
                setShowDeleted(isShowDeleted);
            } catch (SQLException e) {
View Full Code Here

Examples of javax.sql.rowset.spi.SyncProviderException

    @Override
    public void setDataSourceLock(int dataSourceLock)
            throws SyncProviderException {
        if (dataSourceLock != DATASOURCE_NO_LOCK) {
            // rowset.23=Locking classification is not supported
            throw new SyncProviderException("rowset.23"); //$NON-NLS-1$
        }
    }
View Full Code Here

Examples of javax.sql.rowset.spi.SyncProviderException

                }
            }
        }

        if (resolver != null) {
            syncException = new SyncProviderException(resolver);
            return false;
        }
        return true;
    }
View Full Code Here

Examples of javax.sql.rowset.spi.SyncProviderException

                preSt.setObject(i + 1, insertColValues[i]);
            }
            preSt.executeUpdate();
        } catch (SQLException e) {
            // rowset.29=Insert failed
            throw new SyncProviderException(Messages.getString("rowset.29"));//$NON-NLS-1$
        } finally {
            try {
                preSt.close();
            } catch (SQLException e) {
                // ignore
View Full Code Here

Examples of javax.sql.rowset.spi.SyncProviderException

            // the WHERE part of SQL
            fillParamInPreStatement(preSt, updateCount + 1);
            preSt.executeUpdate();
        } catch (SQLException e) {
            // rowset.5=There are conflicts between rowset and data source
            throw new SyncProviderException(Messages.getString("rowset.5"));//$NON-NLS-1$
        } finally {
            try {
                preSt.close();
            } catch (SQLException e) {
                // ignore
View Full Code Here

Examples of javax.sql.rowset.spi.SyncProviderException

    }

    public void acceptChanges() throws SyncProviderException {
        if (isCursorOnInsert) {
            // rowset.11=Illegal operation on an insert row
            throw new SyncProviderException(Messages.getString("rowset.11")); //$NON-NLS-1$
        }

        Connection currentConn = null;
        Connection preConn = conn;
        try {
            currentConn = retrieveConnection();
            currentConn.setTypeMap(getTypeMap());
            acceptChanges(currentConn);
            currentConn.commit();
        } catch (SQLException e) {
            try {
                if (currentConn != null) {
                    currentConn.rollback();
                }
            } catch (SQLException ex) {
                // ignore
            }
            SyncProviderException ex = new SyncProviderException();
            ex.initCause(e);
            throw ex;
        } finally {
            conn = preConn;
            if (currentConn != null) {
                try {
                    currentConn.close();
                } catch (SQLException ex) {
                    SyncProviderException spe = new SyncProviderException();
                    spe.initCause(ex);
                    throw spe;
                }
            }
        }
    }
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.