예제 #1
0
  /**
   * protected Hashtable[] doJDBC(String dbname_, String sql_, // Connection con, boolean goNative_,
   * long offset_, int maxsize_, boolean robotquery_, Connection con) throws SQLException
   */
  public void init() throws Exception {

    try {
      if (!outcon) {
        tx = TransactionManager.getTransaction();
        if (tx == null) {
          con = SQLUtil.getSQLManager().requestConnection(dbname); // 事务无处理,批处理的默认事务处理需要设定
          if (needTransaction) {
            this.oldautocommit = con.getAutoCommit();
            con.setAutoCommit(false);
          }
        } else {
          try {
            con = tx.getConnection(dbname);
          } catch (TransactionException e) {
            try {
              tx.setRollbackOnly();
            } catch (Exception ei) {

            }
            throw e;
          }
        }
      } else {
        if (this.con != null && this.con instanceof TXConnection) {
          tx = TransactionManager.getTransaction();
        }
      }
    } catch (Exception e) {
      throw e;
    }
  }
예제 #2
0
  public int getScrollType(String dbname) {
    try {
      //            JDBCPool pool = ((JDBCPool)SQLUtil.getSQLManager().getPool(dbname));

      return this.dbadapter.getSCROLLType(pool.getDriver());
    } catch (Exception e) {
      log.error(dbname, e);
      JDBCPool pool = ((JDBCPool) SQLUtil.getSQLManager().getPool(null));
      return pool.getDbAdapter().getSCROLLType(pool.getDriver());
    }
  }
예제 #3
0
        public SchemaType getSchemaType(int clindex)
        {
           if(meta == null)
           {
               throw new RowHandlerException("源数据对象[meta]未初始化,无法进行行处理.");
           }
            try {
                int sqltype = meta.getColumnType(clindex);
                SchemaType schemaType = SQLUtil.getSchemaType(dbname, sqltype); 
                return schemaType;
            } catch (Exception e) {
                
//                e.printStackTrace();
                throw new RowHandlerException(e);
            }
            
        }
예제 #4
0
 public StatementInfo(
     String dbname_,
     NewSQLInfo sql_,
     boolean goNative_,
     Connection con_,
     boolean needTransaction) {
   this(
       dbname_,
       sql_,
       goNative_,
       -1,
       -1,
       SQLUtil.isRobotQuery(dbname_),
       con_,
       needTransaction,
       null,
       false);
 }
예제 #5
0
  public StatementInfo(
      String dbname_,
      NewSQLInfo sql_,
      boolean goNative_,
      long offset_,
      int maxsize_,
      boolean robotquery_,
      Connection con_,
      boolean needTransaction,
      String rownum,
      boolean prepared) {
    this.dbname = dbname_;
    if (this.dbname == null) this.dbname = SQLManager.getInstance().getDefaultDBName();
    newsqlinfo = sql_;
    /** must be removed. */
    pool = SQLUtil.getSQLManager().getPool(dbname);
    interceptorInf = pool.getInterceptor();
    dbadapter = pool.getDbAdapter();
    if (sql_ != null)
      sql = interceptorInf.convertSQL(sql_.getNewsql(), dbadapter.getDBTYPE(), dbname_);
    //		this.sql = sql_;

    this.goNative = goNative_;
    this.offset = offset_;
    this.maxsize = maxsize_;
    this.robotquery = robotquery_;
    this.con = con_;
    this.outcon = con_ == null ? false : true;
    statements = new ArrayList();
    this.rownum = rownum;
    this.prepared = prepared;
    resultSets = new ArrayList();

    //		neadGetGenerateKeys = DBUtil.getJDBCPoolMetaData(dbname).isNeadGetGenerateKeys();
    //		if (dbname == null)
    //			this.dbname = SQLManager.getInstance().getDefaultDBName();
    this.needTransaction = needTransaction;
  }