示例#1
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public JDBCPreparedStatement(JDBCConnection conn, String sql, java.util.Calendar calendar, String statementName, String cursorName, int rpbID) throws SQLException
        public JDBCPreparedStatement(JDBCConnection conn, string sql, DateTime calendar, string statementName, string cursorName, int rpbID) : base(conn, statementName, cursorName, rpbID)
        {
            poolable_ = true;
            if (string.ReferenceEquals(sql, null))
            {
                JDBCError.throwSQLException(JDBCError.EXC_SYNTAX_ERROR);
                return;
            }
            rsmd_ = null;
            // Check for null statement

            DatabaseRequestAttributes dpa = new DatabaseRequestAttributes();

            //    dpa.setDescribeOption(0xD5); // Name/alias.
            //
            // Only set the statement name and cursor name in the RPB
            //
            sqlStatementType_ = JDBCStatement.getStatementType(sql);

            statementAttributes_.SQLStatementType = sqlStatementType_;

            dpa.SQLStatementType = sqlStatementType_;
            dpa.PrepareOption    = 0;      // Normal prepare.
            if (sqlStatementType_ == JDBCStatement.TYPE_SELECT)
            {                              // Only set for select statement
                dpa.OpenAttributes = 0x80; // Read only. Otherwise blocking doesn't work.
            }

            JDBCParameterMetaData pmd = new JDBCParameterMetaData(calendar);
            string catalog            = conn_.Catalog;
            // Getting the catalog may change the current rpb for the connection.
            // Reset it after getting back.  Otherwise the call to
            // prepareAndDescribe may fail with a PWS0001

            DatabaseConnection databaseConn = conn_.DatabaseConnection;

            databaseConn.CurrentRequestParameterBlockID = rpbID_;
            rsmd_ = new JDBCResultSetMetaData(conn.DatabaseInfo.ServerCCSID, calendar, catalog);

            dpa.ExtendedSQLStatementText = sql;
            conn.prepareAndDescribe(dpa, rsmd_, pmd);

            int handle = -1;
            // Only change the descriptor if there are parameters available
            DatabaseChangeDescriptorAttributes cda = (DatabaseChangeDescriptorAttributes)dpa;

            sbyte[] b = pmd.ExtendedSQLParameterMarkerDataFormat;
            cda.ExtendedSQLParameterMarkerDataFormat = b;
            handle = b == null ? -1 : conn.NextDescriptorHandle;
            if (handle >= 0)
            {
                conn.changeDescriptor(cda, handle);
            }


            pmd_              = pmd;
            pmd_.Statement    = this;
            descriptorHandle_ = handle;
        }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: void changeDescriptor(DatabaseChangeDescriptorAttributes cda, int handle) throws SQLException
        internal virtual void changeDescriptor(DatabaseChangeDescriptorAttributes cda, int handle)
        {
            try
            {
                conn_.changeDescriptor(cda, handle);
            }
            catch (IOException io)
            {
                throw convertException(io);
            }
        }