Package com.bleujin.framework.db

Examples of com.bleujin.framework.db.Rows


    this.dc = new DBController(dc.getDBManager()) ; // none servant
    this.cmd = cmd ;
  }

  public void printPlan(OutputStream output) throws SQLException {
    Rows rows = execQuery();
   
    PrintWriter writer = new PrintWriter(new OutputStreamWriter(output)) ;
    ResultSetMetaData meta = rows.getMetaData() ;
    int cols = meta.getColumnCount() ;
   
    for(int i = 1 ; i <= cols ; i++){
      writer.printf("%s\t\t", meta.getColumnName(i)) ;
    }
    writer.println() ;
   
   
    while(rows.next()) {
      for(int i = 1 ; i <= cols ; i++){
        writer.printf("%s\t\t", rows.getString(i)) ;
      }
      writer.println() ;
    }
    writer.flush() ;
    writer.close() ;
View Full Code Here


      Connection conn = getConnection() ;
      long start = System.currentTimeMillis();
        conn.setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED);

        //
      Rows rows = myQuery(conn) ;

      long end = System.currentTimeMillis();
      getDBManager().freeConnection(conn) ;
      getDBController().handleServant(start, end, this, IQueryable.QUERY_COMMAND);
      return rows ;
View Full Code Here

    cmd.addParam("e", "12345") ;
    int result = cmd.execUpdate() ;
   
    assertEquals(1, result) ;
   
    Rows rows = dc.getRows("select a, b, c, d, e from lob_sample where a = 1") ;
   
    rows.next() ;
   
    long fileSize = k100File.length();
    assertEquals(true, fileSize == rows.getString("c").length()) ;
    assertEquals(true, fileSize == rows.firstRow().getString("c").length()) ;
   
    InputStream input = rows.getBinaryStream("d") ;
    int bcount = 0;
    while(input.read() != -1) bcount++ ;
    assertEquals(true, fileSize == bcount) ;
    input.close() ;
  }
View Full Code Here

 
  public void testNamedParameter() throws Exception {
    IUserCommand cmd = dc.createUserCommand("select * from copy_sample where no1 >= :no1 and no1 <= :no1") ;
    cmd.addParam("no1", 20) ;
   
    Rows rows = cmd.execQuery() ;
    assertEquals(1, rows.getRowCount()) ;
 
  }
View Full Code Here

    } catch (IllegalArgumentException ignore){}

    IUserCommand cmd = dc.createUserCommand("select 'a:1' from copy_sample where no1 >= :no1 and no1 <= :no1") ;
    cmd.addParam("no1", 20) ;

    Rows rows = cmd.execQuery() ;
    assertEquals(1, rows.getRowCount()) ;
  }
View Full Code Here

  public void testNamedParameter2() throws Exception {
    IUserCommand cmd = dc.createUserCommand("select * from copy_sample where no1 >= ? and no1 <= :no1") ;
    cmd.addParam(0, 19) ;
    cmd.addParam("no1", 20) ;
   
    Rows rows = cmd.execQuery() ;
    assertEquals(2, rows.getRowCount()) ;
  }
View Full Code Here

    IUserProcedure upt = dc.createUserProcedure("sample@insertWith(:a, :b)") ;
    upt.addParam("a", 1) ;
    upt.addParam("b", "abc") ;
    upt.execUpdate() ;
   
    Rows rows = dc.getRows("select * from update_sample") ;
    assertEquals(1, rows.getRowCount()) ;
  }
View Full Code Here

import com.bleujin.framework.db.sample.SampleTestBase;

public class CachedRows extends SampleTestBase{

  public void testUseCache() throws Exception {
    Rows rows = dc.getRows("select * from copy_tblc") ;
   
    assertEquals(false, rows == rows.refreshRows(false)) ;
    assertEquals(true, rows == rows.refreshRows(true)) ;
   
   
    dc.execUpdate("insert into update_sample values(1, 'aa')");
   
    assertEquals(false, rows == rows.refreshRows(true)) ;
   
    Rows cached = rows.refreshRows(true) ;
    assertEquals(true, cached == cached.refreshRows(true)) ;
  }
View Full Code Here

    upts.execUpdate() ;
   
    Map result = upts.getResultMap() ; // for access sel'result
   
    int rowcount = (Integer)result.get("ins") ;
    Rows rows = (Rows)result.get("sel") ;
   
    assertEquals(1, rowcount) ;
    assertEquals("abc", rows.firstRow().getString("b")) ;
  }
View Full Code Here

    upts.execUpdate() ;
   
    Map result = upts.getResultMap() ; // for access sel'result
   
    int inscount = (Integer)result.get("ins") ;
    Rows rows = (Rows)result.get("sel") ;
    int delcount = (Integer)result.get("del") ;
   
    assertEquals(1, inscount) ;
    assertEquals("abc", rows.firstRow().getString("b")) ;
    assertEquals(1, delcount) ;
   
   
    Rows crows = dc.createUserCommand("select * from update_sample where a = ?").addParam(1).execQuery() ;
    assertEquals(false, crows.next()) ;
   
  }
View Full Code Here

TOP

Related Classes of com.bleujin.framework.db.Rows

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.