Exemple #1
0
        RsltCurs
        (
            DrvConn conn,
            AdvanStmt stmt,
            AdvanRSMD rsmd,
            long stmt_id,
            String cursor,
            int preFetch,
            bool do_preLoad) : base(conn, stmt, rsmd, stmt_id, preFetch)

        {
            this.cursor = cursor;
            tr_id       = "Curs[" + inst_id + "]";

            /*
            ** Pre-load row cache if requested.
            */
            if (do_preLoad && preLoad())
            {
                /*
                ** Close the statement when end-of-data detected.
                **
                ** Note that we don't call our closeCursor() method
                ** since it expects to handle the connection lock
                ** state.  Our caller is handling the lock state
                ** during initialization.
                */
                try { base.closeCursor(); }
                catch (SqlEx) {}
            }
            return;
        }         // RsltCurs
Exemple #2
0
        load(DrvConn conn)
        {
            MsgConn msg             = conn.msg;
            bool    isBlankDateNull = conn.isBlankDateNull;

            short     count = msg.readShort();
            AdvanRSMD rsmd  = new AdvanRSMD(count, conn.trace);

            for (short col = 0; col < count; col++)
            {
                ProviderType sql_type = (ProviderType)
                                        msg.readShort();
                short dbms_type = msg.readShort();
                short length    = msg.readShort();
                byte  precision = msg.readByte();
                byte  scale     = msg.readByte();
                byte  flags     = msg.readByte();
                if (isBlankDateNull && sql_type == ProviderType.DateTime)
                {
                    flags |= MSG_DSC_NULL;                      // return empty date as null
                }
                String name = msg.readString();

                switch (sql_type)
                {
                case ProviderType.DateTime:
                    if (dbms_type == 0)
                    {
                        dbms_type = DBMS_TYPE_IDATE;
                    }
                    break;

                case ProviderType.Interval:
                    /*
                    ** Intervals are not supported directly
                    */
                    if (dbms_type == DBMS_TYPE_INTDS)
                    {
                        sql_type = ProviderType.IntervalDayToSecond;
                    }
                    else
                    {
                        sql_type = ProviderType.VarChar;
                    }
                    length    = (short)((dbms_type == DBMS_TYPE_INTYM) ? 8 : 15);
                    precision = scale = 0;
                    break;
                }

                rsmd.desc[col].name      = name;
                rsmd.desc[col].sql_type  = sql_type;
                rsmd.desc[col].dbms_type = dbms_type;
                rsmd.desc[col].length    = length;
                rsmd.desc[col].precision = precision;
                rsmd.desc[col].scale     = scale;
                rsmd.desc[col].flags     = flags;
            }

            return(rsmd);
        }         // load
Exemple #3
0
        RsltSlct
        (
            DrvConn conn,
            AdvanStmt stmt,
            AdvanRSMD rsmd,
            long stmt_id,
            int preFetch,
            bool do_preLoad) : base(conn, stmt, rsmd, stmt_id, preFetch)
        {
            tr_id = "Slct[" + inst_id + "]";

            /*
            ** Pre-load row cache if requested.
            */
            if (do_preLoad && preLoad())
            {
                /*
                ** Close the statement when end-of-data detected.
                **
                ** Note that our caller only locks the connection,
                ** and expects the connection to be unlocked when
                ** data stream is done.  Our closeCursor() method
                ** will unlock the connection as needed.
                */
                try { closeCursor(); }
                catch (SqlEx) {}
            }

            return;
        }         // RsltSlct
Exemple #4
0
        /*
        ** GMT and Local timezone date formatters.
        ** Timezone is assigned in static initializer.
        */



        /*
        ** Name: DrvObj
        **
        ** Description:
        **	Class constructor.
        **
        ** Input:
        **	msg     Database connection.
        **	trace	Connection tracing.
        **
        ** Output:
        **	None.
        **
        ** Returns:
        **	None.
        **
        ** History:
        **	 8-Sep-99 (gordy)
        **	    Created.
        **	 4-Oct-00 (gordy)
        **	    Create unique tracing ID.
        **	28-Mar-01 (gordy)
        **	    Tracing added as parameter.
        */

        protected internal DrvObj(DrvConn conn)
        {
            set(conn);

            /*
            ** Default tracing identifiers.  Not very usefull,
            ** but better than nothing.
            */
            inst_id = inst_count++;
            title   = DrvConst.shortTitle + "[" + inst_id + "]";
            tr_id   = "Ingres[" + (inst_id) + "]";
        }          // DrvObj
Exemple #5
0
        }          // DrvObj

        /// <summary>
        /// Set the DrvConn server connection information.
        /// </summary>
        /// <param name="conn"></param>
        protected internal void set(DrvConn conn)
        {
            this.conn = conn;
            if (conn == null)
            {
                this.msg   = null;
                this.trace = null;
                return;
            }

            this.msg   = conn.msg;
            this.trace = conn.trace;
        }
Exemple #6
0
        RsltByref
        (
            DrvConn conn,
            AdvanCall stmt,
            AdvanRSMD rsmd,
            long stmt_id,
            bool do_preLoad
        ) : base(conn, stmt, rsmd, stmt_id, 1, false)

            /*
            ** BYREF parameters produce a single result row.
            ** Even if row may be pre-loaded, we don't want
            ** the super-class to do the loading.
            */
        {
            rs_max_rows = 1;
            tr_id       = "Byref[" + inst_id + "]";

            /*
            ** Pre-load the row if available, otherwise disable pre-
            ** fetching to better handle the single expected row
            ** (pre-loading requires pre-fetch to be enabled).
            */
            if (do_preLoad)
            {
                preLoad();
            }
            else
            {
                disablePreFetch();
            }

            /*
            ** Load the single expected row and close the
            ** server statement to unlock the connection.
            */
            try
            {
                if (!next())
                {
                    throw SqlEx.get(ERR_GC4002_PROTOCOL_ERR);
                }
            }
            catch (SqlEx) { throw; }
            finally
            {
                try { closeCursor(); }
                catch (SqlEx) {}
            }
            return;
        } // RsltByref
Exemple #7
0
 RsltUpd
 (
     DrvConn conn,
     AdvanStmt stmt,
     AdvanRSMD rsmd,
     long stmt_id,
     String cursor
 ) : base(conn, stmt, rsmd, stmt_id, cursor, 1, false)
 {
     /*
     ** Updatable cursors only permit a single row per fetch,
     ** so pre-fetching and pre-loading is disabled.
     */
     tr_id = "Upd[" + inst_id + "]";
     disablePreFetch();
     return;
 } // RsltUpd
Exemple #8
0
        /*
        ** Name: RsltUpd
        **
        ** Description:
        **	Class constructor.
        **
        ** Input:
        **	conn		Associated connection.
        **	stmt		Associated statement.
        **	rsmd		ResultSet meta-data.
        **	stmt_id		Statement ID.
        **	cursor		Cursor name.
        **
        ** Output:
        **	None.
        **
        ** Returns:
        **	None.
        **
        ** History:
        **	 4-Aug-03 (gordy)
        **	    Created.
        **	 6-Oct-03 (gordy)
        **	    Disable pre-loading in super-class.
        */
        public RsltUpd( 
			DrvConn  	conn,
			AdvanStmt	stmt,
			AdvanRSMD	rsmd,
			long     	stmt_id,
			String   	cursor
			)
            : base(conn, stmt, rsmd, stmt_id, cursor, 1, false)
        {
            /*
            ** Updatable cursors only permit a single row per fetch,
            ** so pre-fetching and pre-loading is disabled.
            */
            tr_id = "Upd[" + inst_id + "]";
            disablePreFetch();
            return;
        }
Exemple #9
0
        /*
        ** Name: ParamSet
        **
        ** Description:
        **	Class constructor.  Creates a parameter set of the
        **	requested size.  If the provided size is negative,
        **	a parameter set of the default size is created.  A
        **	date formatter is required for converting date/time
        **	objects into internal format and a CharSet for string
        **	conversions.
        **
        ** Input:
        **	size		Initial size.
        **	use_gmt		True to use GMT with date/time values.
        **	char_set	Connection CharSet.
        **
        ** Output:
        **	None.
        **
        ** Returns:
        **	None.
        **
        ** History:
        **	15-Nov-00 (gordy)
        **	    Created.
        **	31-Oct-02 (gordy)
        **	    Allow zero as valid initial size.
        **	25-Feb-03 (gordy)
        **	    Added char_set parameter.
        **	12-Sep-03 (gordy)
        **	    Date formatter replaced with GMT indicator.
        */
        public ParamSet(DrvConn conn, int size )
            : base(conn)
        {
            paramArray = new Param[ (size < 0) ? 0 : size ];

            title = trace.getTraceName() + "-ParamSet[" + inst_id + "]";
            tr_id = "Param[" + inst_id + "]";
        }
Exemple #10
0
 /*
 ** Name: ParamSet
 **
 ** Description:
 **	Class constructor.  Creates a parameter set of the
 **	default size.  A date formatter is required for
 **	converting date/time objects into internal format
 **	and a CharSet for string conversions.
 **
 ** Input:
 **	use_gmt		True to use GMT with date/time values.
 **	char_set	Connection CharSet
 **
 ** Output:
 **	None.
 **
 ** History:
 **	15-Nov-00 (gordy)
 **	    Created.
 **	31-Oct-02 (gordy)
 **	    Use negative value for default size.
 **	25-Feb-03 (gordy)
 **	    Added char_set parameter.
 **	12-Sep-03 (gordy)
 **	    Date formatter replaced with GMT indicator.
 */
 public ParamSet( DrvConn conn )
     : this(conn, EXPAND_SIZE)
 {
 }
Exemple #11
0
        private bool isNull = false; // Was last column NULL?

        #endregion Fields

        #region Constructors

        /*
        ** Name: AdvanRslt
        **
        ** Description:
        **	Class constructor.
        **
        ** Input:
        **	conn	    Associated connection.
        **	rsmd	    ResultSet meta-data.
        **
        ** Output:
        **	None.
        **
        ** Returns:
        **	None.
        **
        ** History:
        **      21-Mar-01 (gordy)
        **          Created.
        **	31-Oct-02 (gordy)
        **	    Adapted for generic GCF driver.  Replaced init() with constructor.
        **	 4-Aug-03 (gordy)
        **	    Removal of row cache allowed for simplification in constructors.
        */
        protected AdvanRslt( DrvConn conn, AdvanRSMD rsmd )
            : base(conn)
        {
            this.rsmd = rsmd;
            title = trace.getTraceName() + "-ResultSet[" + inst_id + "]";
            tr_id = "Rslt[" + inst_id + "]";
            return;
        }
Exemple #12
0
        /*
        ** Name: load
        **
        ** Description:
        **	Reads the result-set descriptor (MSG_DESC) from the server
        **	connection and builds an ResultSet meta-data object.
        **
        **
        ** Input:
        **	conn	    Database Connection
        **
        ** Output:
        **	None.
        **
        ** Returns:
        **	AdvanRSMD    Result-set Meta-data.
        **
        ** History:
        **	17-May-99 (gordy)
        **	    Created.
        **	25-Aug-00 (gordy)
        **	    Nullable byte converted to flags.
        **	 4-Oct-00 (gordy)
        **	    Create unique ID for standardized internal tracing.
        **	28-Mar-01 (gordy)
        **	    Tracing added as a parameter.
        **	16-Apr-01 (gordy)
        **	    Converted from constructor to factory method.
        **	31-Oct-02 (gordy)
        **	    Adapted for generic GCF driver.
        **	16-Jun-06 (gordy)
        **	    ANSI Date/Time data type support.  Map intervals to varchar.
        **	25-Aug-06 (gordy)
        **	    Save flags to make parameter modes available.
        */
        public static AdvanRSMD load(DrvConn conn)
        {
            MsgConn msg = conn.msg;
            bool isBlankDateNull = conn.isBlankDateNull;

            short count = msg.readShort();
            AdvanRSMD rsmd = new AdvanRSMD(count, conn.trace);

            for (short col = 0; col < count; col++)
            {
                ProviderType sql_type = (ProviderType)
                    msg.readShort();
                short dbms_type       = msg.readShort();
                short length          = msg.readShort();
                byte precision        = msg.readByte();
                byte scale            = msg.readByte();
                byte flags            = msg.readByte();
                if (isBlankDateNull && sql_type == ProviderType.DateTime)
                    flags |= MSG_DSC_NULL;  // return empty date as null
                String name           = msg.readString();

                switch (sql_type)
                {
                    case ProviderType.DateTime:
                        if (dbms_type == 0) dbms_type = DBMS_TYPE_IDATE;
                        break;

                    case ProviderType.Interval:
                        /*
                        ** Intervals are not supported directly
                        */
                        if (dbms_type == DBMS_TYPE_INTDS)
                            sql_type = ProviderType.IntervalDayToSecond;
                        else
                            sql_type = ProviderType.VarChar;
                        length = (short)((dbms_type == DBMS_TYPE_INTYM) ? 8 : 15);
                        precision = scale = 0;
                        break;
                }

                rsmd.desc[col].name = name;
                rsmd.desc[col].sql_type = sql_type;
                rsmd.desc[col].dbms_type = dbms_type;
                rsmd.desc[col].length = length;
                rsmd.desc[col].precision = precision;
                rsmd.desc[col].scale = scale;
                rsmd.desc[col].flags = flags;
            }

            return (rsmd);
        }
Exemple #13
0
        /*
        ** Name: RsltData
        **
        ** Description:
        **	Class constructor.
        **
        ** Input:
        **	conn		Associated connection.
        **	rsmd		ResultSet meta-data
        **	dataSet		Constant result set, may be null
        **
        ** Output:
        **	None.
        **
        ** Returns:
        **	None.
        **
        ** History:
        **	12-Nov-99 (rajus01)
        **	    Created.
        **	 4-Oct-00 (gordy)
        **	    Create unique ID for standardized internal tracing.
        **	28-Mar-01 (gordy)
        **	    Tracing added as a parameter.
        **	31-Oct-02 (gordy)
        **	    Adapted for generic GCF driver.
        **	26-Sep-03 (gordy)
        **	    Column values now stored as SQL data objects.
        **	26-Sep-03 (gordy)
        **	    Column data now stored as SqlData objects.
        */

        internal RsltData(DrvConn conn, AdvanRSMD rsmd, SqlData[][] dataSet) :
            base(conn, rsmd)
        {
            this.dataSet = (dataSet == null) ? empty : dataSet;
            tr_id        = "Data[" + inst_id + "]";
        }         // RsltData
Exemple #14
0
        /*
        ** Name: AdvanConnect
        **
        ** Description:
        **	Class constructor.  Send connection request to server
        **	containing connection parameters.  Throws SQLException
        **	if connection request fails.
        **
        ** Input:
        **	host	Target host and port.
        **	info	Property list.
        **	trace	Connection tracing.
        **	timeout	Connection timeout.
        **
        ** Output:
        **	None.
        **
        ** Returns:
        **	None.
        **
        ** History:
        **	 7-Jun-99 (gordy)
        **	    Created.
        **	17-Sep-99 (rajus01)
        **	    Added connection parameters.
        **	22-Sep-99 (gordy)
        **	    Convert user/password to server character set when encrypting.
        **	 2-Nov-99 (gordy)
        **	    Read DBMS information after establishing connection.
        **	 4-Nov-99 (gordy)
        **	    Send timeout connection parameter to server.
        **	17-Jan-00 (gordy)
        **	    Connection pool parameter sent as boolean value.  No longer
        **	    need to turn on autocommit since it is the default state for
        **	    the server.
        **	19-May-00 (gordy)
        **	    Check for select loops connection parameter (internal) and
        **	    set the DB connection state appropriatly.
        **	30-Aug-00 (gordy)
        **	    BUG #102472 - Fix the exception returned if user ID or
        **	    password are zero-length strings.  A zero-length string
        **	    was not being caught by the null test and was causing an
        **	    array exception during the password encoding.  This was
        **	    caught by intermediate code and turned into a 'character
        **	    encoding' exception.  Now, null and zero-length valued
        **	    parameters are skipped, which for user ID and password
        **	    result in a reasonably specific error from the server.
        **	 4-Oct-00 (gordy)
        **	    Create unique ID for standardized internal tracing.
        **	17-Oct-00 (gordy)
        **	    Added autocommit mode connection parameter.
        **	20-Jan-01 (gordy)
        **	    Autocommit mode only supported at protocol level 2 or higher.
        **	 7-Mar-01 (gordy)
        **	    Use new class to read DBMS capabilities.
        **	28-Mar-01 (gordy)
        **	    Moved server connection establishment into this class and
        **	    placed server and database connection code into separate
        **	    methods.  Replaced msg parameter with host.  Dropped URL
        **	    as a parameter and added tracing as a parameter.
        **	11-Apr-01 (gordy)
        **	    Added timeout parameter for dbms connection.
        **	18-Apr-01 (gordy)
        **	    Added support for Distributed Transaction Management Connections.*/
        internal AdvanConnect(IDbConnection providerConnection,
		                   String  host,
		                   IConfig config,
		                   ITrace  trace,
		                   int     timeout)
            : this(providerConnection, host, trace)
        {
            // connect to the Data Access Server
            conn = new DrvConn(host, config, trace, false);
            set(conn);  // set the DrvConn into this DrvObj.
            conn.advanConn = this;

            dbms_connect(config, timeout, null);
            conn.loadDbCaps();
        }
Exemple #15
0
 /*
 ** Name: AdvanPrep
 **
 ** Description:
 **	Class constructor.  Common functionality for this class
 **	and derived classes which don't actually prepare the
 **	SQL text.
 **
 ** Input:
 **	conn	    Associated connection.
 **	rs_type	    Default ResultSet type.
 **	rs_concur   Cursor concurrency.
 **	rs_hold	    Default ResultSet holdability.
 **
 ** Output:
 **	None.
 **
 ** History:
 **	13-Jun-00 (gordy)
 **	    Created.
 **	 1-Nov-00 (gordy)
 **	    Changed parameters for 2.0 extensions.
 **	 8-Jan-01 (gordy)
 **	    Set max varchar length in parameter set.
 **	31-Oct-02 (gordy)
 **	    Added max lengths for other column types.
 **	19-Feb-03 (gordy)
 **	    Added ResultSet holdability.  Pass CharSet to ParamSet.
 **	12-Sep-03 (gordy)
 **	    Replaced timezones with GMT indicator and SqlDates utility.
 **	 1-Nov-03 (gordy)
 **	    ParamSet funtionality extended.  Moved column lengths to DrvConn.
 */
 protected AdvanPrep( DrvConn conn, int rs_type, int rs_concur, int rs_hold )
     : base(conn, rs_type, rs_concur, rs_hold)
 {
     paramSet = new ParamSet(conn);
     parameterMarkers = new StringCollection();
     return;
 }
Exemple #16
0
 /*
 ** Name: RsltData
 **
 ** Description:
 **	Class constructor.
 **
 ** Input:
 **	conn		Associated connection.
 **	rsmd		ResultSet meta-data
 **	dataSet		Constant result set, may be null
 **
 ** Output:
 **	None.
 **
 ** Returns:
 **	None.
 **
 ** History:
 **	12-Nov-99 (rajus01)
 **	    Created.
 **	 4-Oct-00 (gordy)
 **	    Create unique ID for standardized internal tracing.
 **	28-Mar-01 (gordy)
 **	    Tracing added as a parameter.
 **	31-Oct-02 (gordy)
 **	    Adapted for generic GCF driver.
 **	26-Sep-03 (gordy)
 **	    Column values now stored as SQL data objects.
 **	26-Sep-03 (gordy)
 **	    Column data now stored as SqlData objects.
 */
 internal RsltData( DrvConn conn, AdvanRSMD rsmd, SqlData[][] dataSet )
     : base(conn, rsmd)
 {
     this.dataSet = (dataSet == null) ? empty : dataSet;
     tr_id = "Data[" + inst_id + "]";
 }
Exemple #17
0
        /*
        ** Name: AdvanPrep
        **
        ** Description:
        **	Class constructor.  Primary constructor for this class
        **	and derived classes which prepare the SQL text.
        **
        ** Input:
        **	conn	    Associated connection.
        **	query	    Query text.
        **	rs_type	    Default ResultSet type.
        **	rs_concur   Cursor concurrency.
        **	rs_hold	    Default ResultSet holdability.
        **
        ** Output:
        **	None.
        **
        ** History:
        **	19-May-99 (gordy)
        **	    Created.
        **	 8-Sep-99 (gordy)
        **	    Synchronize on DbConn.
        **	29-Sep-99 (gordy)
        **	    Use DbConn lock()/unlock() methods for
        **	    synchronization to support BLOB streams.
        **	26-Oct-99 (gordy)
        **	    Implemented ODBC escape processing.
        **	12-Nov-99 (gordy)
        **	    Use configured date formatter.
        **	17-Dec-99 (gordy)
        **	    Check DBMS max varch length.
        **	13-Jun-00 (gordy)
        **	    Extracted functionality for derived classes to
        **	    new protected constructor.
        **	 4-Oct-00 (gordy)
        **	    Create unique ID for standardized internal tracing.
        **	19-Oct-00 (gordy)
        **	    Query prepare code extracted to prepare().  Process
        **	    the query text then call new method to prepare query.
        **	 1-Nov-00 (gordy)
        **	    Changed parameters for 2.0 extensions.
        **	31-Oct-01 (gordy)
        **	    Timezone now passed to AdvanSQL.
        **	31-Oct-02 (gordy)
        **	    Adapted for generic GCF driver.
        **	19-Feb-03 (gordy)
        **	    Added ResultSet holdability.
        **	15-Apr-03 (gordy)
        **	    Added connection timezones separate from date formatters.
        **	 7-Jul-03 (gordy)
        **	    Added Ingres timezone config which affects date/time literals.
        **	12-Sep-03 (gordy)
        **	    Replaced timezones with GMT indicator and SqlDates utility.
        **	 1-Nov-03 (gordy)
        **	    Save updatable table name.
        */
        public AdvanPrep( DrvConn conn, String query, int rs_type, int rs_concur, int rs_hold )
            : this(conn, rs_type, rs_concur, rs_hold)
        {
            title = trace.getTraceName() + "-PreparedStatement[" + inst_id + "]";
            tr_id = "Prep[" + inst_id + "]";

            if ( trace.enabled() )  trace.log( title + ": '" + query + "'" );

            try
            {
                SqlParse sql = new SqlParse( query, conn );
                query_text = sql.parseSQL( parse_escapes, parameterMarkers );
                qry_concur = sql.getConcurrency();
            }
            catch( SqlEx ex )
            {
                if ( trace.enabled() )
                    trace.log( title + ": error parsing query text" );
                if ( trace.enabled( 1 ) )  ex.trace( trace );
                throw ex;
            }

            prepare();
            return;
        }
Exemple #18
0
 DbInfo(DrvConn conn) : base(conn)
 {
     title      = base.trace.getTraceName() + "-DbInfo[" + base.msg.ConnID + "]";
     base.tr_id = "DbInfo[" + base.msg.ConnID + "]";
     return;
 }
Exemple #19
0
        /*
        ** Name: RsltSlct
        **
        ** Description:
        **	Class constructor.
        **
        **	Initial row cache may be pre-loaded, but only if the
        **	message stream is active and DATA messages available.
        **
        ** Input:
        **	conn		Associated connection.
        **	stmt		Associated statement.
        **	rsmd		ResultSet meta-data.
        **	stmt_id		Statement ID.
        **	preFetch	Pre-fetch row count.
        **	preLoad		Load initial row cache.
        **
        ** Output:
        **	None.
        **
        ** Returns:
        **	None.
        **
        ** History:
        **	17-May-00 (gordy)
        **	    Created.
        **	 4-Oct-00 (gordy)
        **	    Create unique ID for standardized internal tracing.
        **	27-Oct-00 (gordy)
        **	    New super-class constructor doesn't take cursor name.
        **	15-Nov-00 (gordy)
        **	    Changed parameters for 2.0 support.
        **	23-Jan-01 (gordy)
        **	    Changed parameter type to AdvanStmt for backward compatibility.
        **	31-Oct-02 (gordy)
        **	    Adapted for generic GCF driver.
        **	 6-Oct-03 (gordy)
        **	    Added preLoad parameter to read initial row cache from server.
        */
        public RsltSlct( 
			DrvConn	conn,
			AdvanStmt	stmt, 
			AdvanRSMD	rsmd, 
			long	stmt_id,
			int		preFetch,
			bool	do_preLoad )
            : base(conn, stmt, rsmd, stmt_id, preFetch)
        {
            tr_id = "Slct[" + inst_id + "]";

            /*
            ** Pre-load row cache if requested.
            */
            if ( do_preLoad  &&  preLoad() )
            {
                /*
                ** Close the statement when end-of-data detected.
                **
                ** Note that our caller only locks the connection,
                ** and expects the connection to be unlocked when
                ** data stream is done.  Our closeCursor() method
                ** will unlock the connection as needed.
                */
                try { closeCursor(); }
                catch( SqlEx ) {}
            }

            return;
        }
Exemple #20
0
        reload(DrvConn conn)
        {
            MsgConn msg = conn.msg;

            bool isBlankDateNull = conn.isBlankDateNull;

            short new_count = msg.readShort();
            short common    = (short)System.Math.Min(new_count, count);

            if (new_count != count)
            {
                resize(new_count);
            }

            for (short col = 0; col < count; col++)
            {
                ProviderType sql_type  = (ProviderType)msg.readShort();
                short        dbms_type = msg.readShort();
                short        length    = msg.readShort();
                byte         precision = msg.readByte();
                byte         scale     = msg.readByte();
                byte         flags     = msg.readByte();
                if (isBlankDateNull && sql_type == ProviderType.DateTime)
                {
                    flags |= MSG_DSC_NULL;                      // return empty date as null
                }
                String name = msg.readString();

                switch (sql_type)
                {
                case ProviderType.DateTime:
                    if (dbms_type == 0)
                    {
                        dbms_type = DBMS_TYPE_IDATE;
                    }
                    break;

                case ProviderType.Interval:
                    /*
                    ** Intervals are not supported directly
                    */
                    if (dbms_type == DBMS_TYPE_INTDS)
                    {
                        sql_type = ProviderType.IntervalDayToSecond;
                    }
                    else
                    {
                        sql_type = ProviderType.VarChar;
                    }
                    length    = (short)((dbms_type == DBMS_TYPE_INTYM) ? 8 : 15);
                    precision = scale = 0;
                    break;
                }

                if (col < common && trace.enabled(5))
                {
                    if (sql_type != desc[col].sql_type)
                    {
                        trace.write(tr_id + ": reload[" + col + "] sql_type " +
                                    desc[col].sql_type + " => " + sql_type);
                    }


                    if (dbms_type != desc[col].dbms_type)
                    {
                        trace.write(tr_id + ": reload[" + col + "] dbms_type " +
                                    desc[col].dbms_type + " => " + dbms_type);
                    }


                    if (length != desc[col].length)
                    {
                        trace.write(tr_id + ": reload[" + col + "] length " +
                                    desc[col].length + " => " + length);
                    }


                    if (precision != desc[col].precision)
                    {
                        trace.write(tr_id + ": reload[" + col + "] precision " +
                                    desc[col].precision + " => " + precision);
                    }


                    if (scale != desc[col].scale)
                    {
                        trace.write(tr_id + ": reload[" + col + "] scale " +
                                    desc[col].scale + " => " + scale);
                    }


                    if (flags != desc[col].flags)
                    {
                        trace.write(tr_id + ": reload[" + col + "] flags " +
                                    desc[col].flags + " => " + flags);
                    }
                }

                desc[col].name      = name;
                desc[col].sql_type  = sql_type;
                desc[col].dbms_type = dbms_type;
                desc[col].length    = length;
                desc[col].precision = precision;
                desc[col].scale     = scale;
                desc[col].flags     = flags;
            }

            return;
        }
Exemple #21
0
 /*
 ** Name: SqlParse
 **
 ** Description:
 **	Class constructor.
 **
 ** Input:
 **	sql	    SQL query text.
 **	conn	Current connection.
 **
 ** Output:
 **	None.
 **
 ** Returns:
 **	None.
 **
 ** History:
 **	26-Oct-99 (gordy)
 **	    Created.
 **	12-Nov-99 (gordy)
 **	    Allow date formatter to be specified.
 **	31-Oct-01 (gordy)
 **	    Parameter changed to timezone to use with local date formatters.
 **	12-Sep-03 (gordy)
 **	    Replaced timezone with GMT indicator.
 **	19-Jun-06 (gordy)
 **	    I give up... just pass connection so all info is available.
 **	16-feb-10 (rajus01, ported by thoda04) Bug 123298
 **	    Added SendIngresDates support to send ingresdate functions
 **	    and literals rather than ANSI functions and literals
 **	    for escaped functions.
 */
 public SqlParse(String sql, DrvConn conn)
 {
     this.sql = sql;
     this.conn = conn;
     ansi_date_syntax = (conn.sqlLevel >= DBMS_SQL_LEVEL_ANSI_DT  &&
                         !conn.sendIngresDates);
     use_gmt = conn.timeLiteralsInGMT();
     text = sql.ToCharArray();
     txt_len = text.Length;
     return;
 }
Exemple #22
0
        private int current           = 0;      // parameter counter.


        /*
        ** Name: ProcInfo
        **
        ** Description:
        **	Class constructor.
        **
        ** Input:
        **	conn	Associated connection.
        **
        ** Output:
        **	None.
        **
        ** Returns:
        **	None.
        **
        ** History:
        **	13-Jun-00 (gordy)
        **	    Created.
        **	 4-Oct-00 (gordy)
        **	    Create unique ID for standardized internal tracing.
        **	28-Mar-01 (gordy)
        **	    Added database connection and tracing parameters.
        **	31-Oct-02 (gordy)
        **	    Adapted for generic GCF driver.
        */

        internal ProcInfo(DrvConn conn) : base(conn)
        {
            title = trace.getTraceName() + "-ProcInfo[" + inst_id + "]";
            tr_id = "ProcInfo[" + inst_id + "]";
            return;
        }         // ProcInfo
Exemple #23
0
        private String schema = null; // Procedure schema

        #endregion Fields

        #region Constructors

        /*
        ** Name: ProcInfo
        **
        ** Description:
        **	Class constructor.
        **
        ** Input:
        **	conn	Associated connection.
        **
        ** Output:
        **	None.
        **
        ** Returns:
        **	None.
        **
        ** History:
        **	13-Jun-00 (gordy)
        **	    Created.
        **	 4-Oct-00 (gordy)
        **	    Create unique ID for standardized internal tracing.
        **	28-Mar-01 (gordy)
        **	    Added database connection and tracing parameters.
        **	31-Oct-02 (gordy)
        **	    Adapted for generic GCF driver.
        */
        internal ProcInfo( DrvConn conn )
            : base(conn)
        {
            title = trace.getTraceName() + "-ProcInfo[" + inst_id + "]";
            tr_id = "ProcInfo[" + inst_id + "]";
            return;
        }
Exemple #24
0
			AdvanCall( DrvConn conn, String sql ) :
				// Initialize base class and override defaults.
					base(
						conn,
						DrvConst.TYPE_FORWARD_ONLY,
						DrvConst.DRV_CRSR_READONLY,
						DrvConst.CLOSE_CURSORS_AT_COMMIT )
		{
			title = trace.getTraceName() + "-CallableStatement[" + inst_id + "]";
			tr_id = "Call[" + inst_id + "]";

			/*
			** Flag all parameters as procedure parameters.
			*/
			paramSet.setDefaultFlags( ParamSet.PS_FLG_PROC_IN );
			bool native_proc = false;

			/*
			** Process the call procedure syntax.
			*/
			try
			{
				SqlParse parser = new SqlParse( sql, conn );
				procInfo = new ProcInfo( conn );
				parser.parseCall( procInfo );
				native_proc = (parser.getQueryType() == SqlParse.QT_NATIVE_PROC);
			}
			catch( SqlEx ex )
			{
				if ( trace.enabled() )  
					trace.log( title + ": error parsing query text" );
				if ( trace.enabled( 1 ) )  ex.trace( trace );
				throw ex;
			}

			/*
			** Count the number of dynamic parameters and allocate
			** the dynamic parameter mapping arrays. Clear the param
			** information if only default parameters.
			*/
			int	param_cnt = procInfo.getParamCount();
			int	dflt_cnt = 0;
			int	dynamic = 0; 

			for( int param = 0; param < param_cnt; param++ )
				switch( procInfo.getParamType( param ) )
				{
					case ProcInfo.PARAM_DYNAMIC :	dynamic++;	break;
					case ProcInfo.PARAM_DEFAULT :	dflt_cnt++;	break;
				}

			if ( param_cnt > 0 )  
				if ( param_cnt == dflt_cnt )
					procInfo.clearParams();	// No real parameters.
				else  if ( param_cnt != dynamic )
				{
					/*
					** Load meta-data parameter names to ensure
					** correct relationship between dynamic and
					** non-dynamic parameters.  See discussion
					** in class description for further details.
					*/
					if ( ! procInfo.paramNamesLoaded() )  procInfo.loadParamNames();
				}
    
    
			if ( procInfo.getReturn() )  
			{
				/*
				** The mapping arrays include an entry for the procedure 
				** result parameter to provide the correct offest for other 
				** parameters, but the entry can't be used for mapping.  
				*/
				dynamic++;

				/*
				** Native procedure syntax places the procedure result
				** parameter last.  Escape syntax places it first.
				*/
				procRsltIndex = (native_proc ? dynamic-1 : 0);
			}

			/*
			** The dynamic parameter map is used to map dynamic parameter 
			** ordinal indexes into internal parameter indexes.  Mapping
			** is required because the internal parameters include non-
			** dynamic parameters and the dynamic parameters may include
			** the procedure result.
			*/
			dpMap = (dynamic > 0) ? new int[ dynamic ] : noMap;
    
			/*
			** The output parameter map is used to map internal parameter
			** indexes (see above) into output result map indexes.  The
			** registered type/scale is saved in associated arrays (which
			** also provide space, in the last entry, for the procedure
			** result registration info).
			*/
			opMap = (param_cnt > 0) ? new int[ param_cnt ] : noMap;
			opType =  new ProviderType[ param_cnt + 1 ];	// Include procedure result
			opScale = new int[ param_cnt + 1 ];	// Include procedure result

			/*
			** Initialize the dynamic parameter mapping array 
			** and any static literal parameters.
			*/
			initParameters();
			return;
		} // AdvanCall
Exemple #25
0
        /*
        ** Name: reload
        **
        ** Description:
        **	Reads a result-set descriptor from a database connection
        **	and loads an existing RSMD with the info.
        **
        ** Input:
        **	conn	Database connection.
        **
        ** Output:
        **	rsmd	Result-set Meta-data.
        **
        ** Returns:
        **	void.
        **
        ** History:
        **	16-Apr-01 (gordy)
        **	    Created.
        **	31-Oct-02 (gordy)
        **	    Adapted for generic GCF driver.  Removed RSMD parameter and
        **	    changed to reload current object (instance method rather than
        **	    static).
        **	16-Jun-06 (gordy)
        **	    ANSI Date/Time data type support.  Map intervals to varchar.
        **	25-Aug-06 (gordy)
        **	    Save flags to make parameter modes available.
        */
        public void reload(DrvConn conn)
        {
            MsgConn msg = conn.msg;

            bool isBlankDateNull = conn.isBlankDateNull;

            short new_count = msg.readShort();
            short common = (short) System.Math.Min(new_count, count);

            if (new_count != count) resize(new_count);

            for (short col = 0; col < count; col++)
            {
                ProviderType sql_type = (ProviderType)msg.readShort();
                short dbms_type       = msg.readShort();
                short length          = msg.readShort();
                byte  precision       = msg.readByte();
                byte  scale           = msg.readByte();
                byte flags            = msg.readByte();
                if (isBlankDateNull && sql_type == ProviderType.DateTime)
                    flags |= MSG_DSC_NULL;  // return empty date as null
                String name = msg.readString();

                switch (sql_type)
                {
                    case ProviderType.DateTime:
                        if (dbms_type == 0) dbms_type = DBMS_TYPE_IDATE;
                        break;

                    case ProviderType.Interval:
                        /*
                        ** Intervals are not supported directly
                        */
                        if (dbms_type == DBMS_TYPE_INTDS)
                            sql_type = ProviderType.IntervalDayToSecond;
                        else
                            sql_type = ProviderType.VarChar;
                        length = (short)((dbms_type == DBMS_TYPE_INTYM) ? 8 : 15);
                        precision = scale = 0;
                        break;
                }

                if (col < common && trace.enabled(5))
                {
                    if (sql_type != desc[col].sql_type)
                        trace.write(tr_id + ": reload[" + col + "] sql_type " +
                            desc[col].sql_type + " => " + sql_type);

                    if (dbms_type != desc[col].dbms_type)
                        trace.write(tr_id + ": reload[" + col + "] dbms_type " +
                            desc[col].dbms_type + " => " + dbms_type);

                    if (length != desc[col].length)
                        trace.write(tr_id + ": reload[" + col + "] length " +
                            desc[col].length + " => " + length);

                    if (precision != desc[col].precision)
                        trace.write(tr_id + ": reload[" + col + "] precision " +
                            desc[col].precision + " => " + precision);

                    if (scale != desc[col].scale)
                        trace.write(tr_id + ": reload[" + col + "] scale " +
                            desc[col].scale + " => " + scale);

                    if (flags != desc[col].flags)
                        trace.write(tr_id + ": reload[" + col + "] flags " +
                                 desc[col].flags + " => " + flags);

                }

                desc[ col ].name = name;
                desc[ col ].sql_type = sql_type;
                desc[ col ].dbms_type = dbms_type;
                desc[ col ].length = length;
                desc[ col ].precision = precision;
                desc[ col ].scale = scale;
                desc[ col ].flags = flags;
            }

            return ;
        }
Exemple #26
0
 /*
 ** Name: AdvanXids
 **
 ** Description:
 **	Class constructor.
 **
 ** Input:
 **	msg	Database connection.
 **	trace	Connection tracing.
 **
 ** Output:
 **	None.
 **
 ** Returns:
 **	None.
 **
 ** History:
 **	18-Apr-01 (gordy)
 **	    Created.*/
 public AdvanXids(DrvConn conn)
     : base(conn)
 {
     xids = new System.Collections.ArrayList();
 }
Exemple #27
0
 /*
 ** Name: DbInfo
 **
 ** Description:
 **	Class constructor.
 **
 ** Input:
 **	conn	Database connection.
 **
 ** Output:
 **	None.
 **
 ** Returns:
 **	None.
 **
 ** History:
 **	 7-Mar-01 (gordy)
 **	    Created.
 **	28-Mar-01 (gordy)
 **	    Added tracing parameter.
 **	31-Oct-02 (gordy)
 **	    Adapted for generic GCF driver.
 */
 public DbInfo( DrvConn conn )
     : base(conn)
 {
     title = base.trace.getTraceName() + "-DbInfo[" + base.msg.ConnID + "]";
     base.tr_id = "DbInfo[" + base.msg.ConnID + "]";
     return;
 }
Exemple #28
0
        /*
        ** Name: AdvanConnect
        **
        ** Description:
        **	Class constructor.  Establish a distributed transaction
        **	management connection.  An XID may be provided, in which
        **	case the server will attempt to assign ownership of the
        **	transaction to the new connection.
        **
        ** Input:
        **	host	Target host and port.
        **	info	Property list.
        **	trace	Connection tracing.
        **	xid	Distributed transaction ID, may be NULL.
        **
        ** Output:
        **	None.
        **
        ** Returns:
        **	None.
        **
        ** History:
        **	18-Apr-01 (gordy)
        **	    Created.*/
        internal AdvanConnect(IDbConnection providerConnection,
		                   String   host,
		                   IConfig  config,
		                   ITrace   trace,
		                   AdvanXID xid)
            : this(providerConnection, host, trace)
        {
            if (xid != null)
                switch (xid.Type)
                {
                    case AdvanXID.XID_INGRES:
                    case AdvanXID.XID_XA:
                        // OK!
                        break;

                    default:
                        if (trace.enabled(1))
                            trace.write(tr_id + ": unknown XID type: " + xid.Type);
                        throw SqlEx.get( ERR_GC4019_UNSUPPORTED );

                }

            // connect to the Data Access Server
            DrvConn conn = new DrvConn(host, config, trace, true);
            set(conn);  // set the DrvConn into this DrvObj.
            conn.advanConn = this;

            if (conn.msg_protocol_level < MSG_PROTO_2)
            {
                if (trace.enabled(1))
                    trace.write(tr_id + ": 2PC protocol = " + conn.msg_protocol_level);
                conn.close();
                throw SqlEx.get( ERR_GC4019_UNSUPPORTED );
            }

            dbms_connect(config, 0, xid);
        }
Exemple #29
0
 /*
 ** Name: AdvanStmt
 **
 ** Description:
 **	Class constructor.
 **
 ** Input:
 **	conn	    Associated connection.
 **	rs_type	    Default ResultSet type.
 **	rs_concur   Cursor concurrency.
 **	rs_hold	    Default ResultSet holdability.
 **
 ** Output:
 **	None.
 **
 ** History:
 **	13-May-99 (gordy)
 **	    Created.
 **	13-Jun-00 (gordy)
 **	    Removed throws clause.
 **	 4-Oct-00 (gordy)
 **	    Create unique tracing ID for standardized internal tracing.
 **	31-Oct-00 (gordy)
 **	    Changed parameters for 2.0 extensions.
 **	28-Mar-01 (gordy)
 **	    Connection fields now have package access instead of methods.
 **	31-Oct-02 (gordy)
 **	    Adapted for generic GCF driver.
 **	19-Feb-03 (gordy)
 **	    Added default ResultSet holdability.
 */
 public AdvanStmt( DrvConn conn, int rs_type, int rs_concur, int rs_hold )
     : base(conn)
 {
     this.rs_type = rs_type;
     this.rs_concur = rs_concur;
     this.rs_hold = rs_hold;
     title = trace.getTraceName() + "-Statement[" + inst_id + "]";
     tr_id = "Stmt[" + inst_id + "]";
     return;
 }
Exemple #30
0
        private long stmt_id = 0; // Server statement ID.

        #endregion Fields

        #region Constructors

        /*
        ** Name: RsltFtch
        **
        ** Description:
        **	Class constructor.
        **
        ** Input:
        **	conn		Associated connection.
        **	stmt		Associated statement.
        **	rsmd		ResultSet meta-data.
        **	stmt_id		Statement ID.
        **	preFetch	Pre-fetch row count.
        **
        ** Output:
        **	None.
        **
        ** Returns:
        **	None.
        **
        ** History:
        **	14-May-99 (gordy)
        **	    Created.
        **	15-Nov-99 (gordy)
        **	    Added max row count and max column length.
        **	13-Dec-99 (gordy)
        **	    Added fetch limit and multi-row data set.
        **	 4-Oct-00 (gordy)
        **	    Create unique ID for standardized internal tracing.
        **	 3-Nov-00 (gordy)
        **	    Parameters changed for 2.0 extensions.
        **	23-Jan-01 (gordy)
        **	    Changed parameter type to AdvanStmt for backward compatibility.
        **	31-Oct-02 (gordy)
        **	    Adapted for generic GCF driver.  Statement info maintained here.
        **	 4-Aug-03 (gordy)
        **	    Pre-fetch handling moved entirely into this class.
        */
        public RsltFtch( 
			DrvConn	conn,
			AdvanStmt	stmt, 
			AdvanRSMD	rsmd, 
			long	stmt_id,
			int		preFetch
			)
            : base(conn, rsmd)
        {
            this.stmt = stmt;
            this.stmt_id = stmt_id;
            rs_max_len = stmt.rs_max_len;
            rs_fetch_dir = stmt.rs_fetch_dir;
            rs_max_rows = stmt.rs_max_rows;
            rs_fetch_size = (rs_max_rows > 0  &&  rs_max_rows < preFetch)
                ? rs_max_rows : preFetch;
            tr_id = "Ftch[" + inst_id + "]";

            /*
            ** Row pre-fetching must be disabled if there is a BLOB column.
            */
            for( int col = 0; col < rsmd.count; col++ )
                if ( ProviderTypeMgr.isLong(rsmd.desc[ col ].sql_type) )
                {
                    rowCacheEnabled = false;
                    break;
                }

            return;
        }
Exemple #31
0
        /*
            ** BYREF parameters produce a single result row.
            ** Even if row may be pre-loaded, we don't want
            ** the super-class to do the loading.
            */
        /*
        ** Name: RsltByref
        **
        ** Description:
        **	Class constructor for Database Procedure BYREF parameters.
        **	Extends procedure row handling to load the single expected
        **	result row and release the server side resources.  Initial
        **	row cache may be pre-loaded, but only if the message stream
        **	is active and DATA message available.
        **
        ** Input:
        **	conn		Associated connection.
        **	stmt		Associated call statement.
        **	rsmd		Result set Meta-Data.
        **	stmt_id		Statement ID.
        **	preLoad		Load initial row cache.
        **
        ** Output:
        **	None.
        **
        ** Returns:
        **	None.
        **
        ** History:
        **	 3-Aug-00 (gordy)
        **	    Created.
        **	 4-Oct-00 (gordy)
        **	    Create unique ID for standardized internal tracing.
        **	 3-Nov-00 (gordy)
        **	    Changed parameters for 2.0 extensions.
        **	23-Jan-01 (gordy)
        **	    Changed parameter type to AdvanStmt for backward compatibility.
        **	31-Oct-02 (gordy)
        **	    Extracted Byref specifics into separate sub-class.
        **	 4-Aug-03 (gordy)
        **	    Server will handle details of detecting EOD and cleaning
        **	    up the connection, so we disable pre-fetch since only one
        **	    row is expected.
        **	 6-Oct-03 (gordy)
        **	    Added preLoad parameter to read initial row cache from server.
        */
        public RsltByref( 
			DrvConn	conn, 
			AdvanCall	stmt,
			AdvanRSMD	rsmd,
			long	stmt_id,
			bool	do_preLoad
			)
            : base(conn, stmt, rsmd, stmt_id, 1, false)
        {
            rs_max_rows = 1;
            tr_id = "Byref[" + inst_id + "]";

            /*
            ** Pre-load the row if available, otherwise disable pre-
            ** fetching to better handle the single expected row
            ** (pre-loading requires pre-fetch to be enabled).
            */
            if ( do_preLoad )
                preLoad();
            else
                disablePreFetch();

            /*
            ** Load the single expected row and close the
            ** server statement to unlock the connection.
            */
            try
            {
                if ( ! next() )  throw SqlEx.get( ERR_GC4002_PROTOCOL_ERR );
            }
            catch( SqlEx ) { throw; }
            finally
            {
                try { closeCursor(); }
                catch( SqlEx ) {}
            }
            return;
        }