Package com.bleujin.framework.db

Examples of com.bleujin.framework.db.Rows


 
 
  public void testParameter() throws Exception {
    IUserCommand cmd = dc.createUserCommand("select ? from copy_sample") ;
    cmd.addParam(0, "abc") ; // start index of param is 0 (zero)
    Rows rows = cmd.execQuery() ;
   
    rows.next() ;
    assertEquals("abc", rows.getString(1)) ;
  }
View Full Code Here


    assertEquals("abc", rows.getString(1)) ;
  }
 

  public void testFirstRow() throws Exception {
    Rows rows = dc.getRows(query1) ;
   
    assertEquals(1, rows.firstRow().getInt("no1")) ;
   
    try {
      rows = dc.getRows("select * from copy_sample where 1 = 2") ;
      rows.firstRow() ;
      fail() ;
    } catch (SQLException ignore){
     
    } catch (RepositoryException ignore){
     
View Full Code Here

    testProcedureUpdate() ;
   
    IUserProcedure upt = dc.createUserProcedure("Sample@selectBy(?)") ;
    upt.addParam(1);
   
    Rows rows = upt.execQuery() ;
   
    assertEquals(1, rows.getRowCount()) ;
    assertEquals("abc", rows.firstRow().getString("b")) ;
  }
View Full Code Here

    cmd2.addParam("___").addParam(1) // unique index exception
   
    int count = upts.add(cmd).add(cmd2).execUpdate() ;
    assertEquals(2, count) ;
   
    Rows rows = dc.getRows("select * from update_sample where a = 1") ;
    assertEquals("___", rows.firstRow().getString("b")) ;
  }
View Full Code Here

      upts.execUpdate() ;
      fail() ;
    }catch(SQLException ignore){
    }
   
    Rows rows = dc.getRows("select count(*) from update_sample") ;
    assertEquals(0, rows.firstRow().getInt(1)) ;
  }
View Full Code Here

    }

    @Override
    protected Rows myQuery(Connection conn) throws SQLException {

        Rows result = null;
        ResultSet rs = null ;
        String procSQL = (getProcSQL().replace('(', ' ')).replace(')', ' ');

        try {
            pstmt = conn.prepareStatement("Exec " + procSQL);
View Full Code Here

    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)) ;
    while(rows.next()) {
      writer.printf("%s\t\t", rows.getString(1)) ;
      writer.printf("%s", rows.getString(2)) ;
      writer.println() ;
    }
    writer.flush() ;
    writer.close() ;
  }
View Full Code Here

    super(dc, procSQL, queryType);
  }


  protected final Rows populate(ResultSet rs) throws SQLException {
    Rows result = RowsUtils.create(this);
    result.populate(rs, getPage().getStartLoc(), getPage().getListNum());
    return result;
  }
View Full Code Here

     
      JSONObject result = new JSONObject() ;
      result.put("RESULT", body) ;
     
      if ( (rs instanceof Rows&&  (((Rows)rs).getNextRows() != null) ){
        Rows nextRows = ((Rows)rs).getNextRows() ;
        JSONObject nextObj = (JSONObject) nextRows.toHandle(new JSONHandler()) ;
        result.put("NEXT", nextObj) ;
      }
     
      return result ;
  }
View Full Code Here

public class RowsFirstRow extends SampleTestBase{

  String query = "select * from copy_sample" ;

  public void testFirstRow() throws Exception {
    Rows rows  = dc.getRows(query) ;
   
    Row row = rows.firstRow() ;
   
   
    assertEquals("01", row.getString(2)) ;
    assertEquals("1", row.getString(1)) ;

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.