コード例 #1
0
ファイル: drvconn.cs プロジェクト: JordanChin/Ingres
        /*
        ** Name: loadDbCaps
        **
        ** Description:
        **	Requests DBMS capabilities from the server and
        **	initialize dbmsinfo() access.
        **
        ** Input:
        **	None.
        **
        ** Output:
        **	None.
        **
        ** Returns:
        **	void
        **
        ** History:
        **	12-Nov-99 (gordy)
        **	    If OPEN_SQL_DATES, use local time rather than gmt.
        **	 3-Nov-00 (gordy)
        **	    Timezone stuff removed from DbConn.  Replaced with a public
        **	    boolean indicating which timezone to use for the connection.
        **	 7-Mar-01 (gordy)
        **	    Use new class to read DBMS capabilities.
        **	10-May-01 (gordy)
        **	    Check DBMS capabilities relevant to driver configuration.
        **	20-Feb-02 (gordy)
        **	    Added dbmsInfo checks for DBMS type and protocol level.
        **	31-Oct-02 (gordy)
        **	    Adapted for generic GCF driver.
        **	23-Dec-02 (gordy)
        **	    Connection level ID changed at protocol level 3.
        */
        public void loadDbCaps()
        {
            String  value;
            int     ivalue;

            /*
            ** Initialize helper classes and load DB capabilities.
            */
            dbInfo = new DbInfo( this );
            dbCaps = new DbCaps( this );
            dbCaps.loadDbCaps();

            /*
            ** Check DB capabilties.
            */
            ;
            if ( (value = dbCaps.getDbCap( (msg_protocol_level < MSG_PROTO_3)
                ? DrvConst.DRV_DBCAP_CONNECT_LVL0
                : DrvConst.DRV_DBCAP_CONNECT_LVL1 )) != null )
                try { db_protocol_level = Byte.Parse( value ); }
                catch( Exception ) {}

            if ( (value = dbCaps.getDbCap( DBMS_DBCAP_DBMS_TYPE )) != null )
                is_ingres = ToInvariantUpper(value).Equals( DBMS_TYPE_INGRES );

            if ((value = dbCaps.getDbCap(DBMS_DBCAP_ING_SQL_LVL)) != null)
                try { sqlLevel = Int32.Parse(value); }
                catch (Exception) { }

            // How the native timestamp type reacts to timezones,
            // lack of it indicates an Ingres DBMS
            if ((value = dbCaps.getDbCap(DBMS_DBCAP_OSQL_DATES)) != null)
                osql_dates = true;	// TODO: check for 'LEVEL 1'

            if ( (value = dbCaps.getDbCap( DBMS_DBCAP_UCS2_TYPES )) != null  &&
                value.Length >= 1 )
                ucs2_supported = (value[0] == 'Y' || value[0] == 'y');

            if ((value = dbCaps.getDbCap(DBMS_DBCAP_MAX_CHR_COL)) != null)
                try { max_char_len = Int32.Parse(value); }
                catch (Exception) { }

            if ((value = dbCaps.getDbCap(DBMS_DBCAP_MAX_VCH_COL)) != null)
                try { max_vchr_len = Int32.Parse(value); }
                catch (Exception) { }

            if ((value = dbCaps.getDbCap(DBMS_DBCAP_MAX_BYT_COL)) != null)
                try { max_byte_len = Int32.Parse(value); }
                catch (Exception) { }

            if ((value = dbCaps.getDbCap(DBMS_DBCAP_MAX_VBY_COL)) != null)
                try { max_vbyt_len = Int32.Parse(value); }
                catch (Exception) { }

            /*
            ** The NCS max column lengths default to half (two bytes per char)
            ** the max for regular columns to match prior behaviour.
            */
            if ((value = dbCaps.getDbCap(DBMS_DBCAP_MAX_NCHR_COL)) == null)
                max_nchr_len = max_char_len / 2;
            else
                try { max_nchr_len = Int32.Parse(value); }
                catch (Exception)  { }

            if ((value = dbCaps.getDbCap(DBMS_DBCAP_MAX_NVCH_COL)) == null)
                max_nvch_len = max_vchr_len / 2;
            else
                try { max_nvch_len = Int32.Parse(value); }
                catch (Exception) { }

            if ((value = dbCaps.getDbCap(DBMS_DBCAP_MAX_DEC_PREC)) != null)
                if (Int32.TryParse(value, out ivalue))  // convert value to int ivalue
                    max_dec_prec = ivalue;

            return;
        }
コード例 #2
0
        loadDbCaps()
        {
            String value;
            int    ivalue;

            /*
            ** Initialize helper classes and load DB capabilities.
            */
            dbInfo = new DbInfo(this);
            dbCaps = new DbCaps(this);
            dbCaps.loadDbCaps();

            /*
            ** Check DB capabilties.
            */
            ;
            if ((value = dbCaps.getDbCap((msg_protocol_level < MSG_PROTO_3)
                                ? DrvConst.DRV_DBCAP_CONNECT_LVL0
                                : DrvConst.DRV_DBCAP_CONNECT_LVL1)) != null)
            {
                try { db_protocol_level = Byte.Parse(value); }
                catch (Exception) {}
            }

            if ((value = dbCaps.getDbCap(DBMS_DBCAP_DBMS_TYPE)) != null)
            {
                is_ingres = ToInvariantUpper(value).Equals(DBMS_TYPE_INGRES);
            }

            if ((value = dbCaps.getDbCap(DBMS_DBCAP_ING_SQL_LVL)) != null)
            {
                try { sqlLevel = Int32.Parse(value); }
                catch (Exception) { }
            }

            // How the native timestamp type reacts to timezones,
            // lack of it indicates an Ingres DBMS
            if ((value = dbCaps.getDbCap(DBMS_DBCAP_OSQL_DATES)) != null)
            {
                osql_dates = true;                      // TODO: check for 'LEVEL 1'
            }
            if ((value = dbCaps.getDbCap(DBMS_DBCAP_UCS2_TYPES)) != null &&
                value.Length >= 1)
            {
                ucs2_supported = (value[0] == 'Y' || value[0] == 'y');
            }

            if ((value = dbCaps.getDbCap(DBMS_DBCAP_MAX_CHR_COL)) != null)
            {
                try { max_char_len = Int32.Parse(value); }
                catch (Exception) { }
            }

            if ((value = dbCaps.getDbCap(DBMS_DBCAP_MAX_VCH_COL)) != null)
            {
                try { max_vchr_len = Int32.Parse(value); }
                catch (Exception) { }
            }

            if ((value = dbCaps.getDbCap(DBMS_DBCAP_MAX_BYT_COL)) != null)
            {
                try { max_byte_len = Int32.Parse(value); }
                catch (Exception) { }
            }

            if ((value = dbCaps.getDbCap(DBMS_DBCAP_MAX_VBY_COL)) != null)
            {
                try { max_vbyt_len = Int32.Parse(value); }
                catch (Exception) { }
            }

            /*
            ** The NCS max column lengths default to half (two bytes per char)
            ** the max for regular columns to match prior behaviour.
            */
            if ((value = dbCaps.getDbCap(DBMS_DBCAP_MAX_NCHR_COL)) == null)
            {
                max_nchr_len = max_char_len / 2;
            }
            else
            {
                try { max_nchr_len = Int32.Parse(value); }
                catch (Exception)  { }
            }

            if ((value = dbCaps.getDbCap(DBMS_DBCAP_MAX_NVCH_COL)) == null)
            {
                max_nvch_len = max_vchr_len / 2;
            }
            else
            {
                try { max_nvch_len = Int32.Parse(value); }
                catch (Exception) { }
            }

            if ((value = dbCaps.getDbCap(DBMS_DBCAP_MAX_DEC_PREC)) != null)
            {
                if (Int32.TryParse(value, out ivalue))                  // convert value to int ivalue
                {
                    max_dec_prec = ivalue;
                }
            }

            return;
        }         // loadDbCaps()