Package org.exolab.jms.persistence

Examples of org.exolab.jms.persistence.PersistenceException


            if (_connection.getAutoCommit()) {
                _connection.setAutoCommit(false);
            }
            _tool = new RDBMSTool(_connection);
        } catch (SQLException exception) {
            throw new PersistenceException(exception.getMessage());
        }

        try {
            convertMessagesTable(schema);
            convertHandlesTable(schema);
            createUsersTable(schema);
            SchemaHelper.setVersion(_connection, "V0.7.6");
            _connection.commit();
        } catch (PersistenceException exception) {
            SQLHelper.rollback(_connection);
            throw exception;
        } catch (SQLException exception) {
            SQLHelper.rollback(_connection);
            throw new PersistenceException(exception);
        }
    }
View Full Code Here


            if (_connection.getAutoCommit()) {
                _connection.setAutoCommit(false);
            }
            _tool = new RDBMSTool(_connection);
        } catch (SQLException exception) {
            throw new PersistenceException(exception.getMessage());
        }

        try {
            if (needsConversion(schema)) {
                doConvert(schema);
            }
            SchemaHelper.setVersion(_connection, "V0.7.2");
            _connection.commit();
        } catch (SQLException exception) {
            SQLHelper.rollback(_connection);
            throw new PersistenceException(exception);
        }
    }
View Full Code Here

                boolean isQueue = (set.getInt(2) > 0);
                long id = set.getLong(3);
                insert(tmpName, name, isQueue, id);
            }
        } catch (SQLException exception) {
            throw new PersistenceException("Failed to convert destinations",
                exception);
        } finally {
            SQLHelper.close(set);
            SQLHelper.close(select);
        }

        // recreate the destinations table
        _tool.drop(table);
        _tool.create(table);

        // copy the data from the temporary table into the destinations table
        PreparedStatement insert = null;
        try {
            insert = _connection.prepareStatement(
                "insert into " + DESTINATIONS_TABLE + " select * from " +
                tmpName);
            insert.executeQuery();
        } catch (SQLException exception) {
            throw new PersistenceException(
                "Failed to copy converted destinations", exception);
        } finally {
            SQLHelper.close(insert);
        }

View Full Code Here

            set = select.executeQuery();
            while (set.next()) {
                result.add(set.getString(1));
            }
        } catch (SQLException exception) {
            throw new PersistenceException("Failed to execute query: " + query,
                                           exception);
        } finally {
            SQLHelper.close(set);
            SQLHelper.close(select);
        }
View Full Code Here

        boolean parameters = false;
        if (start != -1) {
            name = type.substring(0, start);
            int end = type.indexOf(')', start);
            if (end == -1) {
                throw new PersistenceException("Illegal type: " + type);
            }
            precision = Long.parseLong(type.substring(start + 1, end));
            parameters = true;
        }

        Descriptor descriptor = Descriptor.getDescriptor(name.trim());
        if (descriptor == null) {
            throw new PersistenceException("Type name=" + type +
                " is not a valid type");
        }
        return new Type(descriptor.getType(), precision, parameters);
    }
View Full Code Here

        // get a connection to the proxy database
        Connection source;
        try {
            source = _dataSource.getConnection();
        } catch (SQLException exception) {
            throw new PersistenceException(
                    "Failed to get connection to source database",
                    exception);
        }

        _database.start();

        // init master stores
        MasterDestinationStore masterDestinations
                = new MasterDestinationStore(_database);
        MasterMessageStore masterMessages = new MasterMessageStore(_database);
        MasterConsumerStore masterConsumers
                = new MasterConsumerStore(_database);
        MasterUserStore masterUsers = new MasterUserStore(_database);

        // init proxy stores
        PropertyStore properties = new PropertyStore(source);
        VersionInfo info = new VersionInfo(properties);
        String schemaVersion = info.getProxySchemaVersion();
        if (schemaVersion == null || !schemaVersion.equals("1.0")) {
            throw new PersistenceException("Cannot import data: unsupported schema version: "
                                           + schemaVersion);
        }
        Date created = new Date(info.getCreationTimestamp());
        _log.info("Importing data created on " + created + " by OpenJMS "
                  + info.getOpenJMSVersion());

        DestinationStore destinations = new DestinationStore(source);
        ConsumerStore consumers = new ConsumerStore(destinations, source);
        MessageStore messages = new MessageStore(destinations, source);
        UserStore users = new UserStore(source);

        // import data from the proxy database to the master database
        _log.info("Importing destinations...");
        apply(destinations, masterDestinations);
        _log.info("Imported " + masterDestinations.size() + " destinations");

        _log.info("Importing messages...");
        apply(messages, masterMessages);
        _log.info("Imported " + masterMessages.size() + " messages");

        _log.info("Importing consumers...");
        apply(consumers, new MasterConsumerStore(_database));
        _log.info("Imported " + masterConsumers.size() + " consumers");

        _log.info("Importing users...");
        apply(users, new MasterUserStore(_database));
        _log.info("Imported " + masterUsers.size() + " users");

        try {
            source.close();
        } catch (SQLException exception) {
            throw new PersistenceException("Failed to close source",
                                           exception);
        }
        _database.stop();
        _dataSource.setShutdownDatabase("shutdown");
View Full Code Here

        try {
            if (tool.hasTables(schema.getTable())) {
                if (delete) {
                    tool.delete(schema);
                } else {
                    throw new PersistenceException(
                            "Cannot import data: master database already exists "
                            + "but delete not specified");
                }
            } else {
                tool.create(schema);
View Full Code Here

                    attribute.setNotNull(false);
                }
                result.addAttribute(attribute);
            }
        } catch (SQLException exception) {
            throw new PersistenceException(
                    "Failed to determine the schema of table=" + name,
                    exception);
        } finally {
            SQLHelper.close(select);
        }
View Full Code Here

    public Type getType(Attribute attribute) throws PersistenceException {
        Type result = null;
        Type type = Type.getType(attribute.getType());
        Type map = _mapper.getType(type.getType(), type.getPrecision());
        if (map == null) {
            throw new PersistenceException(
                    "Database does not support type=" + attribute.getType());
        }

        if (type.getType() != map.getType()) {
            result = map;
        } else {
            boolean parameters = type.getParameters();
            long precision = type.getPrecision();
            if (precision <= map.getPrecision()) {
                if (precision == -1) {
                    precision = map.getPrecision();
                    parameters = map.getParameters();
                }
                result = new Type(map.getType(), map.getName(),
                                  precision, parameters);
            } else {
                throw new PersistenceException(
                        attribute.getName() + type + " exceeds precision for "
                        + map + " precision=" + map.getPrecision());
            }
        }
        return result;
View Full Code Here

                                     name, null);
            if (set.next()) {
                result = true;
            }
        } catch (SQLException exception) {
            throw new PersistenceException("Failed to determine if table="
                                           + table + " exists", exception);
        } finally {
            SQLHelper.close(set);
        }
        return result;
View Full Code Here

TOP

Related Classes of org.exolab.jms.persistence.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.