Package javax.sql.rowset.spi

Examples of javax.sql.rowset.spi.SyncProviderException


            RowSetWriter rowSetWriter = syncProvider.getRowSetWriter();
            rowSetWriter.writeData(this);
            // acceptChanges(this.getConnection());
        } catch (SQLException e) {
            e.printStackTrace();
            throw new SyncProviderException();
        }
    }
View Full Code Here


        }
    }

    public void acceptChanges(Connection con) throws SyncProviderException {
        if (currentRow == insertRow)
            throw new SyncProviderException();
        throw new NotImplementedException();
    }
View Full Code Here

    assertFalse(this.dialect.indicatesFailure(new SQLTransactionRollbackException()));
    assertFalse(this.dialect.indicatesFailure(new SQLWarning()));
    assertFalse(this.dialect.indicatesFailure(new DataTruncation(1, false, false, 1, 1)));
    assertFalse(this.dialect.indicatesFailure(new SQLDataException()));
    assertFalse(this.dialect.indicatesFailure(new SyncFactoryException()));
    assertFalse(this.dialect.indicatesFailure(new SyncProviderException()));
  }
View Full Code Here

    assertFalse(this.dialect.indicatesFailure(new SQLTransactionRollbackException()));
    assertFalse(this.dialect.indicatesFailure(new SQLWarning()));
    assertFalse(this.dialect.indicatesFailure(new DataTruncation(1, false, false, 1, 1)));
    assertFalse(this.dialect.indicatesFailure(new SQLDataException()));
    assertFalse(this.dialect.indicatesFailure(new SyncFactoryException()));
    assertFalse(this.dialect.indicatesFailure(new SyncProviderException()));
  }
View Full Code Here

        this.columnCount = cloumnCount;
    }

    public void acceptChanges() throws SyncProviderException {
        if (currentRow == insertRow && currentRow != null) {
            throw new SyncProviderException();
        }

        try {
            acceptChanges(getConnection());
        } catch (SQLException e) {
View Full Code Here

    }

    public void acceptChanges(Connection con) throws SyncProviderException {
        if (currentRow == insertRow && currentRow != null) {
            // TODO add error messages
            throw new SyncProviderException();
        }

        try {
            CachedRowSetWriter rowSetWriter = (CachedRowSetWriter) syncProvider
                    .getRowSetWriter();
            rowSetWriter.setConnection(con);
            int beforeWriteIndex = currentRowIndex;
            rowSetWriter.writeData(this);
            absolute(beforeWriteIndex);
            /*
             * FIXME: if no conflicts happen when writeData, then call
             * setOriginalRow()
             */
            notifyRowSetChanged();

        } catch (SyncProviderException e) {
            throw e;
        } catch (SQLException e) {
            throw new SyncProviderException(e.getMessage());
        }
    }
View Full Code Here

    }

    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

    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

        }
        try {
            preSt.executeUpdate();
        } catch (SQLException e) {
            // TODO generate SyncProviderException
            throw new SyncProviderException();
        } finally {
            preSt.close();
        }
    }
View Full Code Here

        fillParamInPreStatement(preSt, updateCount + 1);
        try {
            preSt.executeUpdate();
        } catch (SQLException e) {
            // TODO generate SyncProviderException
            throw new SyncProviderException();
        } finally {
            preSt.close();
        }
    }
View Full Code Here

TOP

Related Classes of javax.sql.rowset.spi.SyncProviderException

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.