Example #1
0
/*
 *  public RubyValue rb_execute(RubyValue v, RubyValue batch, RubyValue arg)
 *  {
 *      RubyArray res = new RubyArray();
 *      try{
 *              String strSql = v.toStr();
 *              if ( batch == RubyConstant.QTRUE )
 *              {
 *                      //LOG.INFO("batch execute:" + strSql);
 *
 *                      executeBatchSQL( strSql );
 *              }
 *              else
 *              {
 *                      Object[] values = null;
 *                      if ( arg != null )
 *                      {
 *                              RubyArray args1 = arg.toAry();
 *                              RubyArray args = args1;
 *                              if ( args.size() > 0 && args.get(0) instanceof RubyArray )
 *                                      args = (RubyArray)args.get(0);
 *
 *                              values = new Object[args.size()];
 *                              for ( int i = 0; i < args.size(); i++ )
 *                              {
 *                                      RubyValue val = args.get(i);
 *                                      if ( val == RubyConstant.QNIL )
 *                                              values[i] = null;
 *                                      else if ( val instanceof RubyInteger )
 *                                              values[i] = new Long( ((RubyInteger)val).toLong() );
 *                                      else if ( val instanceof RubyFloat )
 *                                              values[i] = new Double( ((RubyFloat)val).toFloat() );
 *                                      else if ( val instanceof RubyString )
 *                                              values[i] = new String( ((RubyString)val).toStr() );
 *                                      else if  ( val == RubyConstant.QTRUE )
 *                                              values[i] = new String( "true" );
 *                                      else if  ( val == RubyConstant.QFALSE )
 *                                              values[i] = new String( "false" );
 *                                      else
 *                                              values[i] = val.toStr();
 *                              }
 *                      }
 *
 *                      IDBResult rows = executeSQL( strSql, values);
 *                      RubyString[] colNames = null;
 *
 *                      for( ; !rows.isEnd(); rows.next() )
 *                      {
 *                              RubyHash row = ObjectFactory.createHash();
 *                              for ( int nCol = 0; nCol < rows.getColCount(); nCol ++ )
 *                              {
 *                                      if ( colNames == null )
 *                                              colNames = getOrigColNames(rows);
 *
 *                                      row.add( colNames[nCol], rows.getRubyValueByIdx(nCol) );
 *                              }
 *
 *                              res.add( row );
 *                      }
 *              }
 *              }catch(Exception e)
 *              {
 *              LOG.ERROR("execute failed.", e);
 *                      throw (e instanceof RubyException ? (RubyException)e : new RubyException(e.getMessage()));
 *              }
 *
 *      return res;
 *  }
 *
 *  //@RubyAllocMethod
 *  private static RubyValue alloc(RubyValue receiver) {
 *      return new DBAdapter((RubyClass) receiver);
 *  }*/

        public static void closeAll()
        {
            Hashtable <String, DBAdapter> .Enumerator hashEnum = m_mapDBPartitions.GetEnumerator();
            while (hashEnum.MoveNext())
            {
                DBAdapter db = hashEnum.Current.Value;
                db.close();
            }
        }