Package com.bleujin.framework.db.procedure

Examples of com.bleujin.framework.db.procedure.UserProcedures


   * execUpdate�� ȣ���ϸ� �ش� MDL �������� �ڵ����� �ϳ��� Transaction���� ���ֵǸ�
   * ������ �ϳ��� �����Ұ�� �ڵ� ��ҵȴ�.
   */
 
  public void testUserProcedures() throws Exception {
    UserProcedures upts = dc.createUserProcedures("One Transaction") ;
   
    IUserCommand cmd = dc.createUserCommand("insert into update_sample values(?, ?)") ;
    cmd.addParam(1).addParam("abc") ;
   
    IUserCommand cmd2 = dc.createUserCommand("update update_sample set b = ? where a = ?") ;
    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


  }
 
 
  public void testSimpleTransaction() throws Exception {
   
    UserProcedures upts = dc.createUserProcedures("One Transaction") ;
   
    IUserCommand cmd = dc.createUserCommand("insert into update_sample values(?, ?)") ;
    cmd.addParam(1).addParam("abc") ;
   
    IUserCommand cmd2 = dc.createUserCommand("insert into update_sample values(?, ?)") ;
    cmd.addParam(1).addParam("abc") // unique index exception
   
    upts.add(cmd).add(cmd2) ;
   
    try {
      upts.execUpdate() ;
      fail() ;
    }catch(SQLException ignore){
    }
   
    Rows rows = dc.getRows("select count(*) from update_sample") ;
View Full Code Here

    }


    private long execProcedureArray(int limit, String longString) throws SQLException {
        UserProcedures case1 = dc.createUserProcedures("noneBatch") ;

        long start = System.currentTimeMillis() ;
        for (int i = 0, last = limit; i < last; i++) {
            IUserProcedure upt = dc.createUserProcedure("bleujin@lobTest(?,?,?)") ;
            upt.addParam(0, i); ;
            upt.addParam(1, "abcdefg"); ;
            upt.addClob(2, longString); ;
            case1.add(upt) ;
        }
        case1.execUpdate() ;
        long end = System.currentTimeMillis() ;
        return end - start ;
    }
View Full Code Here

        long end = System.currentTimeMillis() ;
        return end - start ;
    }

    private long execCommandArray(int limit, String longString) throws SQLException {
        UserProcedures case1 = dc.createUserProcedures("noneBatch") ;

        long start = System.currentTimeMillis() ;
        for (int i = 0, last = limit; i < last; i++) {
            IUserCommand command = dc.createUserCommand("insert into BLEU## values(?,?,?)") ;
            command.addParam(0, i); ;
            command.addParam(1, "abcdefg"); ;
            command.addClob(2, longString); ;
            case1.add(command) ;
        }
        case1.execUpdate() ;
        long end = System.currentTimeMillis() ;
        return end - start ;
    }
View Full Code Here

    return getQuery(this.query, idx) ;
  }
 
  private ParameterQueryable getQuery(IQueryable upt, int i) {
    if (upt.getQueryType() == QueryType.USER_PROCEDURES){
      UserProcedures upts = (UserProcedures)upt ;
      return getQuery(upts.getQuery(i), i) ;
    } else return (ParameterQueryable)upt ;
  }
View Full Code Here

 
  private IQueryable parseUserProcedures(JSONObject jo) {
   
    Object name = jo.getJSONObject(QUERY).get("name") ;
    String uptsName = StringUtil.defaultIfEmpty(String.valueOf(name), "not_defined") ;
    UserProcedures upts = dc.createUserProcedures(uptsName) ;
   
    JSONArray ja = jo.getJSONObject(QUERY).getJSONArray(COMMAND) ;
    for (int i = 0, last=ja.size(); i < last; i++) {
      upts.add(parse(ja.getJSONObject(i))) ;
    }
   
    return upts;
  }
View Full Code Here

import com.bleujin.framework.db.procedure.UserProcedures;

public class TestUserProcedures extends DBTestCase{

  public void testUserProceduresQuery() throws Exception {
    UserProcedures upts = dc.createUserProcedures("dual") ;
   
    IUserCommand cmd1 = dc.createUserCommand("select * from dual");
    IUserCommand cmd2 = dc.createUserCommand("select * from copy_tblc");
    upts.add(cmd1) ;
    upts.add(cmd2) ;
   
   
    Rows rows = upts.execQuery() ;
   
    assertEquals(1, rows.getRowCount()) ;
    assertEquals(true, 1 < rows.getNextRows().getRowCount()) ;
  }
View Full Code Here

 
  // create table framework_test_tblc# (a int, b varchar2(20))
  public void testUserProceduresUpdate() throws Exception {
    dc.execUpdate("truncate table framework_test_tblc#") ;
   
    UserProcedures upts = dc.createUserProcedures("dual") ;
   
    IUserCommand cmd1 = dc.createUserCommand("insert into framework_test_tblc# values(1, 'BlaBla')");
    IUserCommand cmd2 = dc.createUserCommand("insert into framework_test_tblc# values(2, 'alBalB')");
    upts.add(cmd1) ;
    upts.add(cmd2) ;
   
    int result = upts.execUpdate() ;
    assertEquals(2, result) ;
   
    assertEquals(2,  dc.getRows("select * from framework_test_tblc#").getRowCount()) ;
  }
View Full Code Here

  }
 
  public void testTransaction() throws Exception {
    dc.execUpdate("truncate table framework_test_tblc#") ;
   
    UserProcedures upts = dc.createUserProcedures("dual") ;
   
    IUserCommand cmd1 = dc.createUserCommand("insert into framework_test_tblc# values(1, 'BlaBla')");
    IUserCommand cmd2 = dc.createUserCommand("insert into framework_test_tblc# values(2, '012345678901234567890123456789')"); // over length
    upts.add(cmd1) ;
    upts.add(cmd2) ;
   
    try {
      int result = upts.execUpdate() ;
      fail() ;
    } catch(SQLException ignore) {
    }

    assertEquals(0,  dc.getRows("select * from framework_test_tblc#").getRowCount()) ;
View Full Code Here

    DBController dc = DBController.getTestInstance() ;
    dc.initSelf() ;
   
    String query = "Types@test(?,?,?,?,?, ?,?,?,?)" ;

    UserProcedures upts = dc.createUserProcedures("procedure batch") ;
    int max = 1000 ;
    for (int i = 0; i < max; i++) {
      IUserProcedure upt = dc.createUserProcedure(query) ;
      upt.addParam(0, RandomUtil.nextRandomString(25, RandomUtil.DOWNCASE_CHAR_TYPE)) ;
      upt.addParam(1, RandomUtil.nextRandomString(10, RandomUtil.DOWNCASE_CHAR_TYPE)) ;
      upt.addParam(2, RandomUtil.nextRandomString(10, RandomUtil.DOWNCASE_CHAR_TYPE)) ;
      upt.addParam(3, RandomUtil.nextRandomString(20, RandomUtil.DOWNCASE_CHAR_TYPE)) ;
      upt.addParam(4, "NORMAL") ;
      upt.addParam(5, RandomUtil.nextInt()) ;
      upt.addParam(6, RandomUtil.nextRandomString(12, RandomUtil.DOWNCASE_CHAR_TYPE)) ;
      upt.addParam(7, RandomUtil.nextRandomString(10, RandomUtil.DOWNCASE_CHAR_TYPE)) ;
      upt.addParam(8, RandomUtil.nextInt()) ;
      upts.add(upt) ;
    }
    upts.execUpdate() ;
    dc.destroySelf() ;
  }
View Full Code Here

TOP

Related Classes of com.bleujin.framework.db.procedure.UserProcedures

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.