本文整理汇总了Java中org.h2.engine.Database.updateMeta方法的典型用法代码示例。如果您正苦于以下问题:Java Database.updateMeta方法的具体用法?Java Database.updateMeta怎么用?Java Database.updateMeta使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.h2.engine.Database
的用法示例。
在下文中一共展示了Database.updateMeta方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: update
import org.h2.engine.Database; //导入方法依赖的package包/类
@Override
public int update() {
session.commit(true);
Database db = session.getDatabase();
session.getUser().checkRight(oldTable, Right.ALL);
Table t = getSchema().findTableOrView(session, newTableName);
if (t != null && hidden && newTableName.equals(oldTable.getName())) {
if (!t.isHidden()) {
t.setHidden(hidden);
oldTable.setHidden(true);
db.updateMeta(session, oldTable);
}
return 0;
}
if (t != null || newTableName.equals(oldTable.getName())) {
throw DbException.get(ErrorCode.TABLE_OR_VIEW_ALREADY_EXISTS_1, newTableName);
}
if (oldTable.isTemporary()) {
throw DbException.getUnsupportedException("temp table");
}
db.renameSchemaObject(session, oldTable, newTableName);
return 0;
}
示例2: revokeRight
import org.h2.engine.Database; //导入方法依赖的package包/类
private void revokeRight() {
for (Table table : tables) {
Right right = grantee.getRightForTable(table);
if (right == null) {
continue;
}
int mask = right.getRightMask();
int newRight = mask & ~rightMask;
Database db = session.getDatabase();
if (newRight == 0) {
db.removeDatabaseObject(session, right);
} else {
right.setRightMask(newRight);
db.updateMeta(session, right);
}
}
}
示例3: update
import org.h2.engine.Database; //导入方法依赖的package包/类
@Override
public int update() {
session.commit(true);
Database db = session.getDatabase();
if (!oldSchema.canDrop()) {
throw DbException.get(ErrorCode.SCHEMA_CAN_NOT_BE_DROPPED_1,
oldSchema.getName());
}
if (db.findSchema(newSchemaName) != null ||
newSchemaName.equals(oldSchema.getName())) {
throw DbException.get(ErrorCode.SCHEMA_ALREADY_EXISTS_1,
newSchemaName);
}
session.getUser().checkSchemaAdmin();
db.renameDatabaseObject(session, oldSchema, newSchemaName);
ArrayList<SchemaObject> all = db.getAllSchemaObjects();
for (SchemaObject schemaObject : all) {
db.updateMeta(session, schemaObject);
}
return 0;
}
示例4: update
import org.h2.engine.Database; //导入方法依赖的package包/类
@Override
public int update() {
session.commit(true);
Database db = session.getDatabase();
session.getUser().checkRight(table, Right.ALL);
table.checkSupportAlter();
// we need to update CHECK constraint
// since it might reference the name of the column
Expression newCheckExpr = column.getCheckConstraint(session, newName);
table.renameColumn(column, newName);
column.removeCheckConstraint();
column.addCheckConstraint(session, newCheckExpr);
table.setModified();
db.updateMeta(session, table);
for (DbObject child : table.getChildren()) {
if (child.getCreateSQL() != null) {
db.updateMeta(session, child);
}
}
return 0;
}
示例5: update
import org.h2.engine.Database; //导入方法依赖的package包/类
@Override
public int update() {
session.commit(true);
Database db = session.getDatabase();
switch (type) {
case CommandInterface.ALTER_USER_SET_PASSWORD:
if (user != session.getUser()) {
session.getUser().checkAdmin();
}
if (hash != null && salt != null) {
user.setSaltAndHash(getByteArray(salt), getByteArray(hash));
} else {
String name = newName == null ? user.getName() : newName;
char[] passwordChars = getCharArray(password);
byte[] userPasswordHash = SHA256.getKeyPasswordHash(name, passwordChars);
user.setUserPasswordHash(userPasswordHash);
}
break;
case CommandInterface.ALTER_USER_RENAME:
session.getUser().checkAdmin();
if (db.findUser(newName) != null || newName.equals(user.getName())) {
throw DbException.get(ErrorCode.USER_ALREADY_EXISTS_1, newName);
}
db.renameDatabaseObject(session, user, newName);
break;
case CommandInterface.ALTER_USER_ADMIN:
session.getUser().checkAdmin();
if (!admin) {
user.checkOwnsNoSchemas();
}
user.setAdmin(admin);
break;
default:
DbException.throwInternalError("type=" + type);
}
db.updateMeta(session, user);
return 0;
}
示例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);
}
}
}
示例7: 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);
}
}
示例8: update
import org.h2.engine.Database; //导入方法依赖的package包/类
@Override
public int update() {
Database db = session.getDatabase();
if (table != null) {
session.getUser().checkRight(table, Right.ALL);
}
if (cycle != null) {
sequence.setCycle(cycle);
}
if (cacheSize != null) {
long size = cacheSize.optimize(session).getValue(session).getLong();
sequence.setCacheSize(size);
}
if (start != null || minValue != null ||
maxValue != null || increment != null) {
Long startValue = getLong(start);
Long min = getLong(minValue);
Long max = getLong(maxValue);
Long inc = getLong(increment);
sequence.modify(startValue, min, max, inc);
}
// need to use the system session, so that the update
// can be committed immediately - not committing it
// would keep other transactions from using the sequence
Session sysSession = db.getSystemSession();
synchronized (sysSession) {
synchronized (db) {
db.updateMeta(sysSession, sequence);
sysSession.commit(true);
}
}
return 0;
}
示例9: update
import org.h2.engine.Database; //导入方法依赖的package包/类
@Override
public int update() {
session.commit(true);
session.getUser().checkAdmin();
Database db = session.getDatabase();
TableView view = null;
Table old = getSchema().findTableOrView(session, viewName);
if (old != null) {
if (ifNotExists) {
return 0;
}
if (!orReplace || !Table.VIEW.equals(old.getTableType())) {
throw DbException.get(ErrorCode.VIEW_ALREADY_EXISTS_1, viewName);
}
view = (TableView) old;
}
int id = getObjectId();
String querySQL;
if (select == null) {
querySQL = selectSQL;
} else {
ArrayList<Parameter> params = select.getParameters();
if (params != null && params.size() > 0) {
throw DbException.getUnsupportedException("parameters in views");
}
querySQL = select.getPlanSQL();
}
// The view creates a Prepared command object, which belongs to a
// session, so we pass the system session down.
Session sysSession = db.getSystemSession();
try {
if (view == null) {
Schema schema = session.getDatabase().getSchema(session.getCurrentSchemaName());
sysSession.setCurrentSchema(schema);
view = new TableView(getSchema(), id, viewName, querySQL, null,
columnNames, sysSession, false);
} else {
view.replace(querySQL, columnNames, sysSession, false, force);
view.setModified();
}
} finally {
sysSession.setCurrentSchema(db.getSchema(Constants.SCHEMA_MAIN));
}
if (comment != null) {
view.setComment(comment);
}
if (old == null) {
db.addSchemaObject(session, view);
} else {
db.updateMeta(session, view);
}
return 0;
}