Package org.jugile.util

Examples of org.jugile.util.DBPool


    p1 = d.getPersons().q("==", "name", "jukka-pekka").unique();
    p1.setName("foo");
    d.commit();
   
    // check db directly
    DBPool db = DBPool.getPool();
    DBConnection c = db.getConnection();
    List<List> rows = c.select("select name_f,id_f,vers from person_t where id_f="+p1.id());
    c.free();
    assertEquals(1,rows.size());
    List row = rows.get(0);
    assertEquals("foo",row.get(0));
View Full Code Here


  /**
   * Read current version from db immediately.
   */
  public void refresh() {
    DBPool db = DBPool.getPool();
    DBConnection c = db.getConnection();
    DomainData dd = DomainCore.cd();
    try {
      c.prepare("select "+_getSelectFlds()+" from "+table() +" where id_f=?");
      c.param(id());
      List<List> rows = c.select();
View Full Code Here

 
  /**
   * Write to db immediately.
   */
  public void flush() {
    DBPool db = DBPool.getPool();
    DBConnection c = db.getConnection();   
    try {
      this._dbWriteFlds(c, bi());
      c.commit();
      modified = false; // not modified anymore
      // _modified Time still remains
View Full Code Here

  private void setArchived(boolean v) {
    isArchived = v;
    String a = "0";
    if (v) a = "1";
    String sql = "update " + table() + " set archived="+a+" where id_f="+getId();
    DBPool db = DBPool.getPool();
    DBConnection c = db.getConnection();
    try {
      c.update(sql);
      c.commit();
    } catch (Exception e) {
      log.error("dbread failed",e);
View Full Code Here

    nextid = nid;
  }
 
  public static long getNextIdHiFromDb(String obj) {   
    long nid = 0;
    DBPool pool = DBPool.getPool();
    DBConnection c = pool.getConnection();
    try {
      c.writeTx();
      c.prepare("select nextid from idpool where obj=?");
      c.param(obj);
      List<List> res = c.select();
View Full Code Here

 
  protected int saveAllToDB() {
    uow(); // starts readTx
    try {
      DBPool db = DBPool.getPool();
      DBConnection c = db.getConnection();
      try {
        int res = cd().saveToDB(c); // whole core domain cd()
        c.commit();
        return res;
      } catch (Exception e) {
View Full Code Here

 
 
  protected abstract Class<Bo>[] classes();
 
  private int doLoadFromDB() throws Exception {
    DBPool db = DBPool.getPool();
    DBConnection c = db.getConnection();
    int count = 0;
    try {
      //reset();
      count = cd().loadFromDB(c,classes());
    } catch (Exception e) {
View Full Code Here

  protected int readDeltasFromQueue(int max) throws Exception {
    return cd().readDeltasFromQueue(node(),max);
  }

  private int modifyDbAndSendMsg(String delta) {
    DBPool db = DBPool.getPool();
    DBConnection c = db.getConnection();
    try {
      int res = uow().writeToDB(c, classes());
      DBQueue.writeMessage(delta, node(), nodes(), c);
      c.commit();
      return res;
View Full Code Here

    Bo bo = getProto();
    if (sql == null) sql = "where " + q2.toSql();
    sql = "select " + bo._getSelectFlds() +" from " + bo.table() + " " + sql;

    List<E> res = new ArrayList<E>();
    DBPool db = DBPool.getPool();
    DBConnection c = db.getConnection();
    try {
      c.prepare(sql);
      for (List<Object> row : c.select()) {
        long id = (Integer)row.get(0);
        E o = (E)bo.createOld(bo.getClass(), id);
View Full Code Here

  public final static long DONE = 2L;
  public final static long ERROR = 3L;

  public static void writeMessage(String msg, String node, String nodes[]) {
    if (nodes == null) return;
    DBPool pool = DBPool.getPool();
    DBConnection c = pool.getConnection();
    try {
      writeMessage(msg,node,nodes,c);
      c.commit();
    } catch (java.sql.SQLNonTransientConnectionException se) {
      log.info("connection error in write. retrying in 30 sec: " + node);
View Full Code Here

TOP

Related Classes of org.jugile.util.DBPool

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.