Search in sources :

Example 11 with DB

use of io.github.ihongs.db.DB in project HongsCORE by ihongs.

the class DBDeff method syncSlaver.

/**
 * 同步从数据库
 * @param slaver
 * @param tablePrefix 从库表前缀
 * @param tableSuffix 从库表后缀
 * @param delExtraTables 删除多余的表
 * @param delExtraFields 删除多余的字段
 * @throws io.github.ihongs.HongsException
 */
public void syncSlaver(DB slaver, String tablePrefix, String tableSuffix, boolean delExtraTables, boolean delExtraFields) throws HongsException {
    List<String> sqls = this.deffSlaver(slaver, tablePrefix, tableSuffix, delExtraTables, delExtraFields);
    DB sdb = slaver;
    sdb.begin();
    try {
        for (String sql : sqls) {
            sdb.execute(sql);
        }
        sdb.commit();
    } catch (HongsException ex) {
        sdb.revert();
        throw ex;
    }
}
Also used : HongsException(io.github.ihongs.HongsException) DB(io.github.ihongs.db.DB)

Example 12 with DB

use of io.github.ihongs.db.DB in project HongsCORE by ihongs.

the class TableDeff method syncSlaver.

/**
 * 同步从表结构
 * @param slaver
 * @param delExtraFields 删除多余的字段
 * @throws io.github.ihongs.HongsException
 */
public void syncSlaver(Table slaver, boolean delExtraFields) throws HongsException {
    List<String> sqls = this.deffSlaver(slaver, delExtraFields);
    DB sdb = slaver.db;
    sdb.begin();
    try {
        for (String sql : sqls) {
            sdb.execute(sql);
        }
        sdb.commit();
    } catch (HongsException ex) {
        sdb.revert();
        throw ex;
    }
}
Also used : HongsException(io.github.ihongs.HongsException) DB(io.github.ihongs.db.DB)

Aggregations

DB (io.github.ihongs.db.DB)12 Map (java.util.Map)8 HongsException (io.github.ihongs.HongsException)7 Table (io.github.ihongs.db.Table)6 HashMap (java.util.HashMap)4 FetchCase (io.github.ihongs.db.util.FetchCase)3 HashSet (java.util.HashSet)3 Set (java.util.Set)3 Matcher (java.util.regex.Matcher)3 Cmdlet (io.github.ihongs.cmdlet.anno.Cmdlet)2 Loop (io.github.ihongs.db.link.Loop)2 ArrayList (java.util.ArrayList)2 Pattern (java.util.regex.Pattern)2 CoreConfig (io.github.ihongs.CoreConfig)1 ActionHelper (io.github.ihongs.action.ActionHelper)1 VerifyHelper (io.github.ihongs.action.VerifyHelper)1 Action (io.github.ihongs.action.anno.Action)1 CommitSuccess (io.github.ihongs.action.anno.CommitSuccess)1 Verify (io.github.ihongs.action.anno.Verify)1 RoleSet (io.github.ihongs.serv.auth.RoleSet)1