Package net.canarymod.database.exceptions

Examples of net.canarymod.database.exceptions.DatabaseWriteException


            if (ps.execute()) {
                Canary.logDebug("Statment Executed!");
            }
        }
        catch (SQLException ex) {
            throw new DatabaseWriteException("Error creating SQLite table '" + data.getName() + "'. " + ex.getMessage());
        }
        catch (DatabaseTableInconsistencyException ex) {
            Canary.logStacktrace(ex.getMessage() + " Error creating SQLite table '" + data.getName() + "'. ", ex);
        }
        finally {
View Full Code Here


                ps = conn.prepareStatement("ALTER TABLE `" + tableName + "` ADD `" + column.columnName() + "` " + getDataTypeSyntax(column.dataType()));
                ps.execute();
            }
        }
        catch (SQLException ex) {
            throw new DatabaseWriteException("Error adding SQLite collumn: " + column.columnName());
        }
        finally {
            closePS(ps);
        }
View Full Code Here

                ps = conn.prepareStatement("ALTER TABLE `" + tableName + "` DROP `" + columnName + "`");
                ps.execute();
            }
        }
        catch (SQLException ex) {
            throw new DatabaseWriteException("Error deleting SQLite collumn: " + columnName);
        }
        finally {
            closePS(ps);
        }
    }
View Full Code Here

            ps.setObject(1, convert(value));
            toRet = ps.execute();

        }
        catch (SQLException ex) {
            throw new DatabaseWriteException("Error checking Value for SQLite Primary "
                    + "Key in Table `" + data.getName() + "` for key `" + primaryKey
                    + "` and value '" + String.valueOf(value) + "'.");
        }
        finally {
            closePS(ps);
View Full Code Here

                toRet = rs.next();
            }

        }
        catch (SQLException ex) {
            throw new DatabaseWriteException(ex.getMessage() + " Error checking SQLite Entry Key in "
                    + data.toString());
        }
        catch (DatabaseTableInconsistencyException ex) {
            Logger.getLogger(SQLiteDatabase.class.getName()).log(Level.SEVERE, null, ex);
        }
View Full Code Here

            try {
                file.createNewFile();
                initFile(file, data.getName());
            }
            catch (IOException e) {
                throw new DatabaseWriteException(e.getMessage());
            }
        }
        Document dbTable;

        try {
            FileInputStream in = new FileInputStream(file);
            dbTable = fileBuilder.build(in);
            in.close();
            insertData(file, data, dbTable);
        }
        catch (JDOMException e) {
            throw new DatabaseWriteException(e.getMessage(), e);
        }
        catch (IOException e) {
            throw new DatabaseWriteException(e.getMessage(), e);
        }
        catch (DatabaseTableInconsistencyException e) {
            throw new DatabaseWriteException(e.getMessage(), e);
        }
    }
View Full Code Here

    @Override
    public void update(DataAccess data, String[] fieldNames, Object[] fieldValues) throws DatabaseWriteException {
        File file = new File("db/" + data.getName() + ".xml");

        if (!file.exists()) {
            throw new DatabaseWriteException("Table " + data.getName() + " does not exist!");
        }
        if (fieldNames.length != fieldValues.length) {
            throw new DatabaseWriteException("Field and Value field lenghts are inconsistent!");
        }
        try {
            FileInputStream in = new FileInputStream(file);
            Document table = fileBuilder.build(in);
            in.close();

            updateData(file, table, data, fieldNames, fieldValues);
        }
        catch (JDOMException e) {
            throw new DatabaseWriteException(e.getMessage(), e);
        }
        catch (IOException e) {
            throw new DatabaseWriteException(e.getMessage(), e);
        }
        catch (DatabaseTableInconsistencyException e) {
            throw new DatabaseWriteException(e.getMessage(), e);
        }
    }
View Full Code Here

    @Override
    public void remove(String tableName, String[] fieldNames, Object[] fieldValues) throws DatabaseWriteException {
        File file = new File("db/" + tableName + ".xml");

        if (!file.exists()) {
            throw new DatabaseWriteException("Table " + tableName + " does not exist!");
        }
        if (fieldNames.length != fieldValues.length) {
            throw new DatabaseWriteException("Field and Value field lenghts are inconsistent!");
        }
        try {
            FileInputStream in = new FileInputStream(file);
            Document table = fileBuilder.build(in);
            in.close();

            removeData(file, table, fieldNames, fieldValues);
        }
        catch (JDOMException e) {
            throw new DatabaseWriteException(e.getMessage(), e);
        }
        catch (IOException e) {
            throw new DatabaseWriteException(e.getMessage(), e);
        }
    }
View Full Code Here

            try {
                file.createNewFile();
                initFile(file, data.getName());
            }
            catch (IOException e) {
                throw new DatabaseWriteException(e.getMessage(), e);
            }
        }
        try {
            FileInputStream in = new FileInputStream(file);
            Document table = fileBuilder.build(in);
            in.close();

            HashSet<Column> tableLayout = data.getTableLayout();

            for (Element element : table.getRootElement().getChildren()) {
                addFields(element, tableLayout);
                removeFields(element, tableLayout);
            }
            write(file.getPath(), table);
        }
        catch (JDOMException e) {
            throw new DatabaseWriteException(e.getMessage(), e);
        }
        catch (IOException e) {
            throw new DatabaseWriteException(e.getMessage(), e);
        }
        catch (DatabaseTableInconsistencyException e) {
            throw new DatabaseWriteException(e.getMessage(), e);
        }
    }
View Full Code Here

TOP

Related Classes of net.canarymod.database.exceptions.DatabaseWriteException

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.