Ejemplo n.º 1
0
        public override object ExecuteScalar()
        {
            CheckConnection();
            EnsureStatment();
            object result = null;

            try
            {
                ResultSet set = statement.executeQuery();
                try
                {
                    if (set.next())
                    {
                        result = set.getObject(1);
                        if (result == null)
                        {
                            result = DBNull.Value;
                        }
                        else
                        {
                            result = H2Helper.ConverterToCLR(set.getMetaData().getColumnType(1))(result);
                        }
                    }
                }
                finally
                {
                    set.close();
                }
                return(result);
            }
            catch (org.h2.jdbc.JdbcSQLException ex)
            {
                throw new H2Exception(ex);
            }
        }
Ejemplo n.º 2
0
        public override object GetValue(int ordinal)
        {
            var    convOrd = ConvertOrdinal(ordinal);
            object result  = set.getObject(convOrd);

            if (result == null)
            {
                return(DBNull.Value);
            }

            if (converters == null)
            {
                converters = new H2Helper.Converter[Meta.getColumnCount()];
            }

            H2Helper.Converter converter = converters[ordinal];
            if (converter == null)
            {
                converters[ordinal] = converter = H2Helper.ConverterToCLR(Meta.getColumnType(convOrd));
            }

            return(converter(result));
        }