org.jpos.ee.DB.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(5.3k)|赞(0)|评价(0)|浏览(184)

本文整理了Java中org.jpos.ee.DB.<init>()方法的一些代码示例,展示了DB.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DB.<init>()方法的具体详情如下:
包路径:org.jpos.ee.DB
类名称:DB
方法名:<init>

DB.<init>介绍

[英]Creates DB Object using default Hibernate instance
[中]使用默认Hibernate实例创建DB对象

代码示例

代码示例来源:origin: jpos/jPOS-EE

/**
 * create a SysLog object with auto commit on.
 * (open/begin/commit/close is not required).
 */
public SysLogManager () {
  super (new DB(),SysLog.class);
  autoCommit = true;
}

代码示例来源:origin: jpos/jPOS-EE

public static <T> T exec(String configModifier, DBAction<T> action) throws Exception {
  try (DB db = new DB(configModifier)) {
    db.open();
    return action.exec(db);
  }
}

代码示例来源:origin: jpos/jPOS-EE

public synchronized DB getDB (Context ctx) {
  DB db = (DB) ctx.get (DB);
  if (db == null) {
    ctx.put (DB, db = new DB ());
  }
  return db;
}
public void setResultCode (Context ctx, String rc) {

代码示例来源:origin: jpos/jPOS-EE

public static <T> T exec(DBAction<T> action) throws Exception {
  try (DB db = new DB()) {
    db.open();
    return action.exec(db);
  }
}

代码示例来源:origin: jpos/jPOS-EE

private void ensureOpen() {
  if (db == null) {
    db = new DB();
    db.open();
    mgr = new SysConfigManager(db);
  }
}
private void close() {

代码示例来源:origin: jpos/jPOS-EE

@Override
  public void exec(CLIContext cli, String[] args) throws Exception {
    String filename = "-";  // defaults to stdout     '
    String configModifier = null;
    boolean create = false;
    if (args.length > 1)
      filename = args[1];
    if (args.length > 2)
      create = "yes".equalsIgnoreCase(args[2]) || "true".equalsIgnoreCase(args[2]);
    if (args.length > 3)
      configModifier = args[3];

    try (DB db = new DB(configModifier)) {
      db.open();
      db.beginTransaction();
      db.createSchema(filename, create);
    }
  }
}

代码示例来源:origin: jpos/jPOS-EE

public void initService () {
  db = new DB();
  mgr = new StatusManager (db);
  timer = new Timer (true);
  Iterator iter = config.getChildren ("monitor").iterator();
  List handlers = new ArrayList();
  while (iter.hasNext()) {
    Element e = (Element) iter.next();
    try {
      registerTask (e);
    } catch (ConfigurationException ex) {
      getLog().error (ex);
    }
  }
}
public void destroyService() {

代码示例来源:origin: jpos/jPOS-EE

public void initService () throws Exception {
  db = new DB();
  mgr = new StatusManager (db);
  interval = cfg.getLong ("interval", 60000L);
  initStatus();
}
public void startService() {

代码示例来源:origin: jpos/jPOS-EE

private void create (String id) {
    try (DB db = new DB()) {
      db.open();
      db.beginTransaction();
      SeqNo seq = new SeqNo(id);
      db.session().save(seq);
      db.commit();
    } catch (Exception ignored) { }
  }
}

代码示例来源:origin: jpos/jPOS-EE

public static <T> T execWithTransaction(DBAction<T> action) throws Exception {
  try (DB db = new DB()) {
    db.open();
    db.beginTransaction();
    T obj = action.exec(db);
    db.commit();
    return obj;
  }
}

代码示例来源:origin: jpos/jPOS-EE

public static <T> T execWithTransaction(String configModifier, DBAction<T> action) throws Exception {
  try (DB db = new DB(configModifier)) {
    db.open();
    db.beginTransaction();
    T obj = action.exec(db);
    db.commit();
    return obj;
  }
}

代码示例来源:origin: jpos/jPOS-EE

private void createSchema () throws HibernateException, DocumentException {
  DB db = new DB();
  db.open();
  db.beginTransaction();
  db.createSchema(null, true);
  db.commit();
  db.close();
}

代码示例来源:origin: jpos/jPOS-EE

public void initService() throws Exception {
    super.initService();
    Space sp = SpaceFactory.getSpace("tspace:dbconfig");
    String cm = cfg.get("config-modifier", null);
    String dbprefix = (cm != null ? cm.split(":")[0] + ":" : "");
    sp.out(dbprefix + "connection.username", cfg.get("dbuser", "UNKNOWN"));
    sp.out(dbprefix + "connection.password", cfg.get("dbpass", "UNKNOWN"));
    new org.jpos.ee.DB(cm);
  }
}

代码示例来源:origin: jpos/jPOS-EE

@BeforeClass
public static void setUp() throws DocumentException {
  try (DB db = new DB()) {
    db.createSchema(null, true);
  }
}

代码示例来源:origin: jpos/jPOS-EE

private long nextAsync(long id, long delay) {
  SeqNoManager mgr = new SeqNoManager(new DB());
  long l = mgr.next("sync", id, 60000L, 60000L, 999999L);
  ISOUtil.sleep(delay);
  mgr.release("sync", id);
  return l;
}
private void reset() {

代码示例来源:origin: jpos/jPOS-EE

@Override
  public void exec(CLIContext cli, String[] args) throws Exception {
    try (DB db = new DB()) {
      db.open();
      RoleManager rm = new RoleManager(db);
      for (Role r : rm.getAll()) {
        cli.println (r.getName() + " " + r.getPermissions());
      }
    } catch (Exception e) {
      cli.println (e.getMessage());
    }
  }
}

代码示例来源:origin: jpos/jPOS-EE

public void testAddExportUser() throws Exception {     
  Session sess = new DB().open();
  try {
    GLUser user = getUser(sess,System.getProperty("user.name"));
  } catch (IllegalArgumentException e) {
    Transaction txn = sess.beginTransaction();
    GLUser user = new GLUser();
    user.setName(System.getProperty ("user.name"));
    user.setNick(System.getProperty ("user.name"));
    List<String> perms = Arrays.asList("read","write","grant");
    perms.forEach(p -> {sess.save (new GLPermission (p)); user.grant (new GLPermission (p));});
    sess.save (user);
    txn.commit();
  }
  sess.close ();
}

代码示例来源:origin: jpos/jPOS-EE

@Before
public void setUp() throws Exception {
  db = new DB();
  db.createSchema("schema.sql", true);
  db.open();
}

代码示例来源:origin: jpos/jPOS-EE

private void reset() {
    try (DB db = new DB()) {
      SeqNoManager mgr = new SeqNoManager(db);
      db.open();
      db.beginTransaction();
      mgr.reset("sync", 0L);
      db.commit();
    }
  }
}

代码示例来源:origin: jpos/jPOS-EE

private long next(long delay) {
  try (DB db = new DB()) {
    SeqNoManager mgr = new SeqNoManager(db);
    db.open();
    db.beginTransaction();
    long l = mgr.next("sync", 999999L);
    ISOUtil.sleep(delay);
    db.commit();
    return l;
  }
}

相关文章