Package com.samskivert.io

Examples of com.samskivert.io.PersistenceException


    {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        try {
            update.persistTo(new ObjectOutputStream(out));
        } catch (IOException ioe) {
            throw new PersistenceException("Error serializing update " + update, ioe);
        }
        return out.toByteArray();
    }
View Full Code Here


        try {
            Class<?> updateClass = getUpdateClass(updateType);
            if (updateClass == null) {
                errmsg = "No class registered for update type [sceneId=" + sceneId +
                    ", sceneVersion=" + sceneVersion + ", updateType=" + updateType + "].";
                throw new PersistenceException(errmsg);
            }

            // create the update
            SceneUpdate update = (SceneUpdate)updateClass.newInstance();
            update.init(sceneId, sceneVersion);

            // decode its contents from the serialized data
            ByteArrayInputStream bin = new ByteArrayInputStream(data);
            update.unpersistFrom(new ObjectInputStream(bin));
            return update;

        } catch (IOException ioe) {
            error = ioe;
            errmsg = "Unable to decode update";

        } catch (ClassNotFoundException cnfe) {
            error = cnfe;
            errmsg = "Unable to instantiate update";

        } catch (InstantiationException ie) {
            error = ie;
            errmsg = "Unable to instantiate update";
        } catch (IllegalAccessException iae) {
            error = iae;
            errmsg = "Unable to instantiate update";
        }

        errmsg += " [sceneId=" + sceneId + ", sceneVersion=" + sceneVersion +
            ", updateType=" + updateType + "].";
        throw new PersistenceException(errmsg, error);
    }
View Full Code Here

                conn = _writeSource.getConnection();
            }
            return conn;

        } catch (SQLException sqe) {
            throw new PersistenceException(sqe);
        }
    }
View Full Code Here

                    PreparedStatement stmt = null;
                    try {
                        stmt = conn.prepareStatement("insert into sites (siteString) VALUES (?)");
                        stmt.setString(1, site.siteString);
                        if (1 != stmt.executeUpdate()) {
                            throw new PersistenceException("Not inserted " + site);
                        }
                        site.siteId = liaison.lastInsertedId(conn, stmt, "sites", "siteId");

                    } finally {
                        JDBCUtil.close(stmt);
View Full Code Here

    {
        int modified = stmt.executeUpdate();
        if (modified != expectedCount) {
            String err = "Statement did not modify expected number of rows [stmt=" + stmt +
                ", expected=" + expectedCount + ", modified=" + modified + "]";
            throw new PersistenceException(err);
        }
    }
View Full Code Here

    {
        int modified = stmt.executeUpdate(query);
        if (modified != expectedCount) {
            String err = "Statement did not modify expected number of rows [stmt=" + stmt +
                ", expected=" + expectedCount + ", modified=" + modified + "]";
            throw new PersistenceException(err);
        }
    }
View Full Code Here

                        conmap.connection.setAutoCommit(Boolean.valueOf(autoCommit));
                    } catch (SQLException sqe) {
                        closeConnection(ident, conmap.connection);
                        err = "Failed to configure auto-commit [key=" + key +
                            ", ident=" + ident + ", autoCommit=" + autoCommit + "].";
                        throw new PersistenceException(err, sqe);
                    }
                }

                // make the connection read-only to let the JDBC driver know that it can and should
                // use the read-only mirror(s)
                if (readOnly) {
                    try {
                        conmap.connection.setReadOnly(true);
                    } catch (SQLException sqe) {
                        closeConnection(ident, conmap.connection);
                        err = "Failed to make connection read-only [key=" + key +
                            ", ident=" + ident + "].";
                        throw new PersistenceException(err, sqe);
                    }
                }
                _keys.put(key, conmap);

            } else {
View Full Code Here

        Driver jdriver;
        try {
            jdriver = (Driver)Class.forName(driver).newInstance();
        } catch (Exception e) {
            String err = "Error loading driver [class=" + driver + "].";
            throw new PersistenceException(err, e);
        }

        // create the connection
        try {
            Properties props = new Properties();
            props.put("user", username);
            props.put("password", passwd);
            return jdriver.connect(url, props);

        } catch (SQLException sqe) {
            String err = "Error creating database connection [driver=" + driver + ", url=" + url +
                ", username=" + username + "].";
            throw new PersistenceException(err, sqe);
        }
    }
View Full Code Here

        throws PersistenceException
    {
        String value = props.getProperty(name);
        if (StringUtil.isBlank(value)) {
            errmsg = "Unable to get connection. " + errmsg; // augment the error message
            throw new PersistenceException(errmsg);
        }
        return value;
    }
View Full Code Here

                }

                if (!retryOnTransientFailure || liaison == null ||
                    !liaison.isTransientException(sqe)) {
                    String err = "Operation invocation failed";
                    throw new PersistenceException(err, sqe);
                }

                // the MySQL JDBC driver has the annoying habit of including the embedded exception
                // stack trace in the message of their outer exception; if I want a fucking stack
                // trace, I'll call printStackTrace() thanksverymuch
View Full Code Here

TOP

Related Classes of com.samskivert.io.PersistenceException

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.