当前位置: 首页>>代码示例>>Java>>正文


Java Database.addDatabaseObject方法代码示例

本文整理汇总了Java中org.h2.engine.Database.addDatabaseObject方法的典型用法代码示例。如果您正苦于以下问题:Java Database.addDatabaseObject方法的具体用法?Java Database.addDatabaseObject怎么用?Java Database.addDatabaseObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.h2.engine.Database的用法示例。


在下文中一共展示了Database.addDatabaseObject方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: update

import org.h2.engine.Database; //导入方法依赖的package包/类
@Override
public int update() {
    session.getUser().checkSchemaAdmin();
    session.commit(true);
    Database db = session.getDatabase();
    User user = db.getUser(authorization);
    // during DB startup, the Right/Role records have not yet been loaded
    if (!db.isStarting()) {
        user.checkSchemaAdmin();
    }
    if (db.findSchema(schemaName) != null) {
        if (ifNotExists) {
            return 0;
        }
        throw DbException.get(ErrorCode.SCHEMA_ALREADY_EXISTS_1, schemaName);
    }
    int id = getObjectId();
    Schema schema = new Schema(db, id, schemaName, user, false);
    db.addDatabaseObject(session, schema);
    return 0;
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:22,代码来源:CreateSchema.java

示例2: update

import org.h2.engine.Database; //导入方法依赖的package包/类
@Override
public int update() {
    session.commit(true);
    session.getUser().checkAdmin();
    Database db = session.getDatabase();
    if (db.findAggregate(name) != null || schema.findFunction(name) != null) {
        if (!ifNotExists) {
            throw DbException.get(
                    ErrorCode.FUNCTION_ALIAS_ALREADY_EXISTS_1, name);
        }
    } else {
        int id = getObjectId();
        UserAggregate aggregate = new UserAggregate(
                db, id, name, javaClassMethod, force);
        db.addDatabaseObject(session, aggregate);
    }
    return 0;
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:19,代码来源:CreateAggregate.java

示例3: grantRole

import org.h2.engine.Database; //导入方法依赖的package包/类
private void grantRole(Role grantedRole) {
    if (grantedRole != grantee && grantee.isRoleGranted(grantedRole)) {
        return;
    }
    if (grantee instanceof Role) {
        Role granteeRole = (Role) grantee;
        if (grantedRole.isRoleGranted(granteeRole)) {
            // cyclic role grants are not allowed
            throw DbException.get(ErrorCode.ROLE_ALREADY_GRANTED_1, grantedRole.getSQL());
        }
    }
    Database db = session.getDatabase();
    int id = getObjectId();
    Right right = new Right(db, id, grantee, grantedRole);
    db.addDatabaseObject(session, right);
    grantee.grantRole(grantedRole, right);
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:18,代码来源:GrantRevoke.java

示例4: update

import org.h2.engine.Database; //导入方法依赖的package包/类
@Override
public int update() {
    session.getUser().checkAdmin();
    session.commit(true);
    Database db = session.getDatabase();
    if (db.findUser(roleName) != null) {
        throw DbException.get(ErrorCode.USER_ALREADY_EXISTS_1, roleName);
    }
    if (db.findRole(roleName) != null) {
        if (ifNotExists) {
            return 0;
        }
        throw DbException.get(ErrorCode.ROLE_ALREADY_EXISTS_1, roleName);
    }
    int id = getObjectId();
    Role role = new Role(db, id, roleName, false);
    db.addDatabaseObject(session, role);
    return 0;
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:20,代码来源:CreateRole.java

示例5: update

import org.h2.engine.Database; //导入方法依赖的package包/类
@Override
public int update() {
    session.getUser().checkAdmin();
    session.commit(true);
    Database db = session.getDatabase();
    if (db.findRole(userName) != null) {
        throw DbException.get(ErrorCode.ROLE_ALREADY_EXISTS_1, userName);
    }
    if (db.findUser(userName) != null) {
        if (ifNotExists) {
            return 0;
        }
        throw DbException.get(ErrorCode.USER_ALREADY_EXISTS_1, userName);
    }
    int id = getObjectId();
    User user = new User(db, id, userName, false);
    user.setAdmin(admin);
    user.setComment(comment);
    if (hash != null && salt != null) {
        user.setSaltAndHash(getByteArray(salt), getByteArray(hash));
    } else if (password != null) {
        char[] passwordChars = getCharArray(password);
        byte[] userPasswordHash;
        if (userName.length() == 0 && passwordChars.length == 0) {
            userPasswordHash = new byte[0];
        } else {
            userPasswordHash = SHA256.getKeyPasswordHash(userName, passwordChars);
        }
        user.setUserPasswordHash(userPasswordHash);
    } else {
        throw DbException.throwInternalError();
    }
    db.addDatabaseObject(session, user);
    return 0;
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:36,代码来源:CreateUser.java

示例6: grantRight

import org.h2.engine.Database; //导入方法依赖的package包/类
private void grantRight() {
    Database db = session.getDatabase();
    for (Table table : tables) {
        Right right = grantee.getRightForTable(table);
        if (right == null) {
            int id = getObjectId();
            right = new Right(db, id, grantee, rightMask, table);
            grantee.grantRight(table, right);
            db.addDatabaseObject(session, right);
        } else {
            right.setRightMask(right.getRightMask() | rightMask);
            db.updateMeta(session, right);
        }
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:16,代码来源:GrantRevoke.java

示例7: update

import org.h2.engine.Database; //导入方法依赖的package包/类
@Override
public int update() {
    session.getUser().checkAdmin();
    session.commit(true);
    Database db = session.getDatabase();
    session.getUser().checkAdmin();
    if (db.findUserDataType(typeName) != null) {
        if (ifNotExists) {
            return 0;
        }
        throw DbException.get(
                ErrorCode.USER_DATA_TYPE_ALREADY_EXISTS_1,
                typeName);
    }
    DataType builtIn = DataType.getTypeByName(typeName);
    if (builtIn != null) {
        if (!builtIn.hidden) {
            throw DbException.get(
                    ErrorCode.USER_DATA_TYPE_ALREADY_EXISTS_1,
                    typeName);
        }
        Table table = session.getDatabase().getFirstUserTable();
        if (table != null) {
            throw DbException.get(
                    ErrorCode.USER_DATA_TYPE_ALREADY_EXISTS_1,
                    typeName + " (" + table.getSQL() + ")");
        }
    }
    int id = getObjectId();
    UserDataType type = new UserDataType(db, id, typeName);
    type.setColumn(column);
    db.addDatabaseObject(session, type);
    return 0;
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:35,代码来源:CreateUserDataType.java

示例8: addOrUpdateSetting

import org.h2.engine.Database; //导入方法依赖的package包/类
private void addOrUpdateSetting(Session session, String name, String s,
        int v) {
    Database database = session.getDatabase();
    if (database.isReadOnly()) {
        return;
    }
    Setting setting = database.findSetting(name);
    boolean addNew = false;
    if (setting == null) {
        addNew = true;
        int id = getObjectId();
        setting = new Setting(database, id, name);
    }
    if (s != null) {
        if (!addNew && setting.getStringValue().equals(s)) {
            return;
        }
        setting.setStringValue(s);
    } else {
        if (!addNew && setting.getIntValue() == v) {
            return;
        }
        setting.setIntValue(v);
    }
    if (addNew) {
        database.addDatabaseObject(session, setting);
    } else {
        database.updateMeta(session, setting);
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:31,代码来源:Set.java


注:本文中的org.h2.engine.Database.addDatabaseObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。