Overloading ambiguity errors

Any suggestions on how to resolve the error below?
"/opt/SUNWspro/current-compiler/include/CC/Cstd/./vector", line 1131: Error: Overloading ambiguity between
"std::distance<std::vector<bool, std::allocator<bool>>::const_iterator, unsigned>(std::vector<bool,
std::allocator<bool>>::const_iterator, std::vector<bool, std::allocator<bool>>::const_iterator, unsigned&)"
and "distance<std::vector<bool, std::allocator<bool>>::const_iterator, unsigned>(std::vector<bool,
std::allocator<bool>>::const_iterator, std::vector<bool, std::allocator<bool>>::const_iterator, unsigned&)".
Sometimes the subsequent "Where: While instantiating ...." helps locate the ambiguity.
(None in this case. ) If this error were coming from user code, specifying '::' or 'std::' helps.
But when it is in one of the CC include files, is there a recommended approach?
Any input is appreciated.
% CC -V
CC: Sun WorkShop 6 update 1 C++ 5.2 2000/09/11
Thanks.

If you have copied the error message correctly, it appears you have declared your own "distance"function template outside namespace std, which is causing the ambiguity.
If you haven't done that, you might have run into a compiler bug. C++ 5.2 is obsolete and is no longer supported, but you can download the most recent patches for it here
http://wwws.sun.com/software/products/studio/patches/index.html
and see if that fixes the problem. (In your case, select the link for Forte Developer 6 update 1. The most recent patches are from about 2002.)
If patches don't help, see if you can post a small compilable code sample that shows the problem.

Similar Messages

  • Wrong overloading ambiguity error

    Hi,
    The following compiles on Studio 7, but not on Studio 11, where an error is reported:
    Error: Overloading ambiguity between "myString::operator char*&()" and "myString::operator char*()"
    However, when myStr is defined const, then the code compiles.
    Why this difference in the behaviour of the compilers? Is it intended? Should unaccesible operators be checked for ambiguity? Why does the compiler check for ambiguity of methods which it obviously should not select in this case?
    #include <string.h>
    class myString {
      private:
         char * content;
      public:
         myString(const char * str) { content = new char[strlen(str)+1]; strcpy(content,str);};
         operator char*&() { char * cpy = new char[strlen(content)+1]; strcpy(cpy,content); return cpy;};
         operator const char* () const {return content;};
      private:
         operator char*() { char * cpy = new char[strlen(content)+1]; strcpy(cpy,content); return cpy;};
    int main() {
         myString myStr = "MyString Test String"; // COMPILE ERROR HERE
         const char * str = myStr;
         return 0;
    };

    The error is not on the marked line, but on the next
    line:
    const char * str = myStr;Yes, you are right, I marked the wrong line.
    >
    The rule for resolving overloaded functions is that
    all visible functions that can be called with the
    given arguments ("viable functions" in the
    terminology of the standard) are checked, and the
    best match is looked for.
    If there is no single best match, the call is
    ambiguous, an error.
    Only if there is a best match is accessibility
    checked. If the best match is not accessible, the
    call is in error.In this case, wouldn't the const operator be the best match?
    >
    The reason for checking accessibility last is to
    prevent changes in accessibility from changing the
    result of operator overload resoution. One can
    imagine different rules, but that is the C++ rule.
    (C++ Standard, section 13.3)This should only apply here if the compiler decided not to select the constant operator over the other operators. That would mean that doing two conversions (MyString -> char*/& -> const char*) would be preferred over doing one conversion (MyString -> const char *).
    Does this conform to the C++ standard rules?

  • Non-existent overloading ambiguity error on valid code

    $ cat >test.cxx
    #include <string>
    template <typename C, typename X>
    void
    f (std::basic_string<C> const&, X& );
    template <typename C>
    void
    f (std::basic_string<C> const&, unsigned char& );
    template<typename X>
    struct S
      template <typename C>
      S (std::basic_string<C> const& str)
        f (str, x_); // Error
      X x_;
    void
    g ()
      std::string str;
      unsigned char uc;
      f (str, uc); // Ok
      S<unsigned char> s (str);
    $ CC -V
    CC: Sun C++ 5.8 2005/10/13
    $ CC -c test.cxx
    "test.cxx", line 17: Error: Overloading ambiguity between "f<char, unsigned char>(const std::string &, unsigned char&)" and "f<char>(const std::string &, unsigned char&)".BTW, is there a no-nonsense (like paying Sun to report bugs in Sun's products) bug-tracking system where I can report things like this directly?
    hth,
    -boris

    Yes, it's a compiler bug. I have filed bug report 6370669 for you.
    If you have a service contract with Sun, you can monitor progress on fixing the bug and get early access to a fix before a patch is released. Otherwise, you can check the Sun Studio patch page from time to time to see if a new patch is available that fixes the bug.
    http://developers.sun.com/prodtech/cc/downloads/patches/
    We do not currently have a mechanism to allow customers to file or track Sun Studio bug reports directly.

  • Error: Overloading ambiguity between "operator+(const RWCString&, const RWC

    We always get the following error when we are compiling our source codes:
    Error: Overloading ambiguity between "operator+(const RWCString&, const RWCString&)" and "RWCString::operator const char*() const"
    Our compiler is Workshop 6 update 1. We can compile the same source codes in Workshop 5.0. We found out that we can solve this problem if we explicitly cast the const strings to RWCString. However, since we are building on previous source codes and modules, we find this solution close to impossible. Is there other solution for this problem? Are there any patch which we can use?
    Thanks!

    The code really does have an ambiguity in it.
    The RWCString class operator() member function, which you invoke as str1(...) with an integer value, returns a char. You then have the operation
            RWCString + char
    The RWCString class does not have an associated operator+ that takes a RWCString and a character. The compiler could convert the string to a char* via "operator const char*" and add the value of the char to it, or it could convert the char to a RWCString via a constructor and use the operator+ that takes two RCWCstrings.
    The compiler has no way to prefer one choice over the other.
    You can write an explicit cast, or you can store the result of the str1(...) operation in an explicit RWCString temp, or you could use the += operator:
    str2 = str2 + RWCString(str1(str1.length()-1));
    RWCString temp = str1(str1.length()-1);
    str2 = str2 + temp;
    str2 += str1(str1.length()-1);
    BTW, this problem illustrates why it's usually a bad idea to have multiple constructors and also type conversion operators in a class. It's hard to write code that doesn't lead to ambiguities.

  • Bug? Ambiguous error on overloaded varargs

    Hi!
    I don't understand why the following code throws an ambigous error.
    I simply create two same-named methods using varargs, one time for int, one time for float.
    If I call it I would suppose that it is resolved in the same way as always on overloaded methods, i.e. the first example should call the int... - version, the third the float...
    But Java throws an ambiguous error at compile-time, though an implicite cast from int to float is not neccessary if all parameters are pure int. Further no error is thrown when passing an int[]-array.
    This seems to me like a kind of bug. I'm using version 1.5.0_06
    public class TempTest {
         public static int getFirst(int... A) {
              return A[0];
         public static float getFirst(float... A) {
              return A[0];
         public static void main(String args[]) throws Exception
              System.out.println(getFirst(1,2,3)); // throws ambiguous-error during compilation
              System.out.println(getFirst(new int[]{1, 2, 3})); // works as suspected for int
              System.out.println(getFirst(1f,2,3)); // works as suspected for float
              System.out.println(getFirst(new float[]{1, 2, 3})); // works as suspected for float
    }

    Ok, I read the chapter but I don't see the reason for this behaviour. Let's assume another more clear example:
    There are simply two methods for finding the maximum of the passed parameters, either passed as int or float
    public class TempTest {     
         public static int max(int... a) {
              int max=a[0];
              // find the max of all
              return max;
         public static float max(float... a) {
              float max=a[0];
              // find the max of all
              return max;
         public static void main(String args[]) throws Exception
              max(1,2,3,4,5); // ambiguous, though calling int[] suspected
    }I understood the section 15.12 as follows:
    1. find accessible and applicable methods, here both max(int...a) and max(float...a) will do it
    2. try to find a most specific of them:
    Assuming that an implicite cast is handled as e.g. int <: float in 15.12.2.5 it is that int[] <: float[] but NOT that float[] <: int[].
    Therefore max(int...a) is strictly more specific and maximally specific, so it should be used, and no ambiguous error thrown.
    So it seems that my assumption that implicite type-casting is handled in the same manner as e.g. int <: float is wrong, though I don't know why.
    In my opinion the whole varargs-concept is more or less useless, if you cannot overload a method with them like e.g. max(int... a) and max(float... a), though intuitively it is absolutely clear, that calling max(1,2,3,4) or e.g. explicitely max((int) 1, (int) 2, (int) 3) should call the int-version or any other that is nearest in implicite type-casting.
    So at least pragmatically I cannot be reasonable as long as I don't see any clear reason for that methodcall being ambiguous.
    [EDIT]
    I think I got the problem now:
    Though int <: float it is NOT true that int[] <: float[]. Simple because:
    int i = 3;
    float f = i; // ok
    int[] iarr = new int[4];
    float[] farr = (float[]) iarr; // not possibleThis seems to be the problem when finding the most specific method, because it is neither int[] <: float[] nor float[] <: int[], so ambiguous.
    I see the problem now:
    It is (nearly) impossible to convert between arrays of primitives when passing them by reference. Imagine: changes to the converted referenced array should have to be written back to original array of other primitive type!
    But then there >should< have be done any other trick when implementing varargs, because as mentioned before it is just a silly feature if it is not possible to overload in such a simple manner as max(int... a) with max(float... a)
    [EDIT]
    Message was edited by:
    wagalaweia

  • Overloading ambiguity between "std::pow(double, int)" and "std::pow(long do

    hello all,
    we have a problem with sources coming from visual c++, i can reproduce the problem with the small code:
    $ cat test.cc
    #include <math.h>
    int main()
    double kk;
    int j11;
    j11=4;
    kk=pow(2,j11);
    $ CC test.cc
    "test.cc", line 8: Error: Overloading ambiguity between "std::pow(double, int)" and "std::pow(long double, int)".
    1 Error(s) detected.we are on linux, with sun studio 12u1
    thanks in advance for help,
    gerard

    The issue is whether the standard headers associated with the compiler have the overloads required by the standard. If the required overloads are present, the original call of std::pow is ambiguous, and the compiler will report it.
    If you have a recent version of Visual C++, I'd be very surprised if the function overloads were not available. Possibly you are using a compiler option, perhaps a default option, that hides the overloaded declarations. In that case, some C++ code that conforms to the standard would not behave correctly when used with the compiler in that mode.
    The correct approach is to use the compiler in standard-conforming mode so that code you write will be accepted by other standard-conforming compilers. That is, after all, the purpose of the standard.

  • Overloading ambiguity when compile with stlport

    I am trying to compile code with sun compiler 5.3 with stlport 4.5.3 with sun standard iostream.
    Got the following error. Is this a bug in compiler ?
    "/opt/local/STLport-4.5.3/stlport/stl/_vector.c", line 76: Error: Overloading ambiguity between "_STL::uninitialized_fill_n<_STL::basic_string<char, std::char_traits<char>, _STL::allocator<char>>*, unsigned, _STL::basic_string<char, std::char_traits<char>, _STL::allocator<char>>>(_STL::basic_string<char, std::char_traits<char>, _STL::allocator<char>>*, unsigned, const _STL::basic_string<char, std::char_traits<char>, _STL::allocator<char>>&)" and "std::uninitialized_fill_n<_STL::basic_string<char, std::char_traits<char>, _STL::allocator<char>>*, unsigned, _STL::basic_string<char, std::char_traits<char>, _STL::allocator<char>>>(_STL::basic_string<char, std::char_traits<char>, _STL::allocator<char>>*, unsigned, const _STL::basic_string<char, std::char_traits<char>, _STL::allocator<char>>&)".
    "/opt/local/STLport-4.5.3/stlport/stl/_vector.h", line 460: Where: While instantiating "_STL::vector<_STL::basic_string<char, std::char_traits<char>, _STL::allocator<char>>, _STL::allocator<_STL::basic_string<char, std::char_traits<char>, _STL::allocator<char>>>>::_M_fill_insert(_STL::basic_string<char, std::char_traits<char>, _STL::allocator<char>>*, unsigned, const _STL::basic_string<char, std::char_traits<char>, _STL::allocator<char>>&)".
    "/opt/local/STLport-4.5.3/stlport/stl/_vector.h", line 460: Where: Instantiated from non-template code.

    It's impossible to say whether the problem is in your code, the compiler, or in the STLport files without seeing the source code that you are trying to compile. Can you post a small example that illustrates the problem?
    But we do not support STLport with C++ 5.3. If you have problems with that combination, you are on your own. If you can identify a compiler bug, we can try to fix it, but C++ 5.3 has been declared End Of Life, and only limited support is available.
    Our recent compilers include a supported version of STLport. The current release is Sun Studio 10, but Studio 11 will be released within two weeks. Watch this space for details.
    http://www.sun.com/software/products/studio/index.xml

  • Annoying Overloading ambiguity

    If the following code is compiled with Studio 12u1 or express 0610, the following compilation error is reported:
    CC /tmp/bug.cc
    "/tmp/bug.cc", line 32: Error: Overloading ambiguity between "built-in operator[](int, const char*)" and "Object::ValueProxy::operator[](const std::string &)".
    gcc is happy with the code and I think it is valid (what is "built-in operator[](int, const char*)"?).
    Removing the template operator T() gets rid of the error.
    #include <string>
    struct Value
    struct BaseHolder {};
    template <typename T> struct Holder : BaseHolder {};
    template <typename T> operator const T() const; // <-- this line
    Value operator[]( unsigned n );
    Value( const Value& ) {}
    struct Object
    struct ValueProxy : Value
    operator Value();
    ValueProxy operator[](const std::string& );
    ValueProxy operator[](const std::string& s);
    int main()
    Object o;
    o["a"]["b"][0];
    }

    1. Please always put code examples, scripts, and compiler messages in "code" brackets, to ensure they are displayed correctly. In particular, some punctuation characters are otherwise taken as formatting directives and not displayed.
    2. Class Value has a user-defined copy constructor, so the compiler will not generate a the default no-argument constructor.
    The fragment struct ValueProxy : Value { ... }is not valid because no constructor for Value is available. (CC does not catch this error, but gcc does.) I removed the copy constructor to avoid this error.
    3. The operator Value() conversion function in class ValueProxy would convert a ValueProxy to its base class, which is an implicit conversion. The conversion function will never be called for an explicit or implicit conversion. Perhaps this code does not work as you expect. (You could call the function explicitly by name, but then you might wind up with two different results for a conversion.)
    4. I think the last line really is ambiguous, as indicated by CC. I think gcc is wrong to accept the code.

  • Time Machine - ambiguous error message, cannot backup

    I've been without use of Time Machine for sometime (months) now.  I've been getting the following error:
    My backup drive (Seagate FreeAgent GoFlex - 320GB) was a attached to my Airport Extreme, but in desperation I moved it to being directly attached to my MBP.  I've also excluded large number of files from the back up (reduced the full backup size to half the size of the backup disk).  Also, I've erased and reformatted the back up disk - twice.  No errors on it either.
    What would be really helpful, was if there was some indication as to WHAT the problem actually is.  This is a rather ambiguous error message, which does little to help a person to troubleshooot.  It seems like the backup is being hung up on a file or files...but I'm just guessing.
    Has anybody out there run into this?  If so, what was your solution?

    [edit] is just that....
    May 14 14:48:17 [edit]-MacBook-Pro com.apple.backupd[1764]: Starting standard backup
    May 14 14:48:17 [edit]-MacBook-Pro com.apple.backupd[1764]: Backing up to: /Volumes/ExternalDrive/Backups.backupdb
    May 14 14:48:17 [edit]-MacBook-Pro com.apple.backupd[1764]: Ownership is disabled on the backup destination volume.  Enabling.
    May 14 14:51:04 [edit]-MacBook-Pro com.apple.backupd[1764]: Backup content size: 245.6 GB excluded items size: 137.7 GB for volume Macintosh HD
    May 14 14:51:04 [edit]-MacBook-Pro com.apple.backupd[1764]: 129.53 GB required (including padding), 297.57 GB available
    May 14 14:51:04 [edit]-MacBook-Pro com.apple.backupd[1764]: Waiting for index to be ready (101)
    May 14 15:02:46 [edit]-MacBook-Pro com.apple.backupd[1764]: Error: (-36) SrcErr:YES Copying /Library/Printers/EPSON/EPSON PIC Folder/EPPICPattern126.dat to (null)
    May 14 15:31:49 [edit]-MacBook-Pro com.apple.backupd[1764]: Error: (-36) SrcErr:YES Copying /Users/[edit]/Library/Application Support/MobileSync/Backup/68a48479fa6e73fdbacc33daf3c003dcbfab9c3e-20120509-095 758/7b8a42966b914320a4db3ac5eddaa32064d29fcc to (null)
    May 14 15:32:04 [edit]-MacBook-Pro com.apple.backupd[1764]: Error: (-36) SrcErr:YES Copying /Users/[edit]/Library/Application Support/MobileSync/Backup/68a48479fa6e73fdbacc33daf3c003dcbfab9c3e-20120509-095 758/86871b8b230c5a0ca23ec5789cac825a1e7026ee to (null)
    May 14 15:32:15 [edit]-MacBook-Pro com.apple.backupd[1764]: Error: (-36) SrcErr:YES Copying /Users/[edit]/Library/Application Support/MobileSync/Backup/68a48479fa6e73fdbacc33daf3c003dcbfab9c3e-20120509-095 758/86d83f36949ec4330f43bc2af1adddfd19e52056 to (null)
    May 14 15:32:27 [edit]-MacBook-Pro com.apple.backupd[1764]: Error: (-36) SrcErr:YES Copying /Users/[edit]/Library/Application Support/MobileSync/Backup/68a48479fa6e73fdbacc33daf3c003dcbfab9c3e-20120509-095 758/86f96503cca926e69f0c2f8cf372171727749536 to (null)
    May 14 15:32:38 [edit]-MacBook-Pro com.apple.backupd[1764]: Error: (-36) SrcErr:YES Copying /Users/[edit]/Library/Application Support/MobileSync/Backup/68a48479fa6e73fdbacc33daf3c003dcbfab9c3e-20120509-095 758/873122ebefa3dd47cffcb054df63bd3a35791916 to (null)
    May 14 15:32:50 [edit]-MacBook-Pro com.apple.backupd[1764]: Error: (-36) SrcErr:YES Copying /Users/[edit]/Library/Application Support/MobileSync/Backup/68a48479fa6e73fdbacc33daf3c003dcbfab9c3e-20120509-095 758/87510b15fb7fc3d3e7032b143d3de4e5e87c05ff to (null)
    May 14 15:33:01 [edit]-MacBook-Pro com.apple.backupd[1764]: Error: (-36) SrcErr:YES Copying /Users/[edit]/Library/Application Support/MobileSync/Backup/68a48479fa6e73fdbacc33daf3c003dcbfab9c3e-20120509-095 758/876fb2d3a73264a6c081b320e7f47071da0637b2 to (null)
    May 14 15:33:13 [edit]-MacBook-Pro com.apple.backupd[1764]: Error: (-36) SrcErr:YES Copying /Users/[edit]/Library/Application Support/MobileSync/Backup/68a48479fa6e73fdbacc33daf3c003dcbfab9c3e-20120509-095 758/87843f0b63a7e5c3538844828dc4536b56b10e54 to (null)
    May 14 15:33:25 [edit]-MacBook-Pro com.apple.backupd[1764]: Error: (-36) SrcErr:YES Copying /Users/[edit]/Library/Application Support/MobileSync/Backup/68a48479fa6e73fdbacc33daf3c003dcbfab9c3e-20120509-095 758/878ad7fc28317553ffc49b4a08c8e514019700b0 to (null)
    May 14 15:33:37 [edit]-MacBook-Pro com.apple.backupd[1764]: Error: (-36) SrcErr:YES Copying /Users/[edit]/Library/Application Support/MobileSync/Backup/68a48479fa6e73fdbacc33daf3c003dcbfab9c3e-20120509-095 758/87d14e27e2f738ff1a6e39c08e064e5dbcc3e26f to (null)
    May 14 15:33:48 [edit]-MacBook-Pro com.apple.backupd[1764]: Error: (-36) SrcErr:YES Copying /Users/[edit]/Library/Application Support/MobileSync/Backup/68a48479fa6e73fdbacc33daf3c003dcbfab9c3e-20120509-095 758/88dd812d4e95170a8a5fcaac47af473556b51e1f to (null)
    May 14 15:34:00 [edit]-MacBook-Pro com.apple.backupd[1764]: Error: (-36) SrcErr:YES Copying /Users/[edit]/Library/Application Support/MobileSync/Backup/68a48479fa6e73fdbacc33daf3c003dcbfab9c3e-20120509-095 758/8999862e4421fe066253d175b6026b16f03b1657 to (null)
    May 14 15:34:12 [edit]-MacBook-Pro com.apple.backupd[1764]: Error: (-36) SrcErr:YES Copying /Users/[edit]/Library/Application Support/MobileSync/Backup/68a48479fa6e73fdbacc33daf3c003dcbfab9c3e-20120509-095 758/89bcb0705dc484e7bcd2e7bdebe3fd66357d27a5 to (null)
    May 14 15:34:32 [edit]-MacBook-Pro com.apple.backupd[1764]: Error: (-36) SrcErr:YES Copying /Users/[edit]/Library/Application Support/MobileSync/Backup/68a48479fa6e73fdbacc33daf3c003dcbfab9c3e-20120509-095 758/ae530ff4961a820911be360b64d8300327d01bae to (null)
    May 14 15:34:43 [edit]-MacBook-Pro com.apple.backupd[1764]: Error: (-36) SrcErr:YES Copying /Users/[edit]/Library/Application Support/MobileSync/Backup/68a48479fa6e73fdbacc33daf3c003dcbfab9c3e-20120509-095 758/ae767b8458cc53ed334e27a0100d1172ceff1272 to (null)
    May 14 15:34:55 [edit]-MacBook-Pro com.apple.backupd[1764]: Error: (-36) SrcErr:YES Copying /Users/[edit]/Library/Application Support/MobileSync/Backup/68a48479fa6e73fdbacc33daf3c003dcbfab9c3e-20120509-095 758/ae79df406dc5da5e53f72ce7816f7f654507b294 to (null)
    May 14 15:35:06 [edit]-MacBook-Pro com.apple.backupd[1764]: Error: (-36) SrcErr:YES Copying /Users/[edit]/Library/Application Support/MobileSync/Backup/68a48479fa6e73fdbacc33daf3c003dcbfab9c3e-20120509-095 758/aefea7b028355af5ade04018c304884413d7d12c to (null)
    May 14 15:35:18 [edit]-MacBook-Pro com.apple.backupd[1764]: Error: (-36) SrcErr:YES Copying /Users/[edit]/Library/Application Support/MobileSync/Backup/68a48479fa6e73fdbacc33daf3c003dcbfab9c3e-20120509-095 758/af0536e1b8ba4cfa4ec3353e41bbdf803fbde764 to (null)
    May 14 15:35:29 [edit]-MacBook-Pro com.apple.backupd[1764]: Error: (-36) SrcErr:YES Copying /Users/[edit]/Library/Application Support/MobileSync/Backup/68a48479fa6e73fdbacc33daf3c003dcbfab9c3e-20120509-095 758/af2dea9017f80796663317a0daa77aa72f243315 to (null)
    May 14 15:35:41 [edit]-MacBook-Pro com.apple.backupd[1764]: Stopping backup.
    May 14 15:35:41 [edit]-MacBook-Pro com.apple.backupd[1764]: Error: (-36) SrcErr:YES Copying /Users/[edit]/Library/Application Support/MobileSync/Backup/68a48479fa6e73fdbacc33daf3c003dcbfab9c3e-20120509-095 758/af59c8a32e747af22d90fdf3b108745b1d99fef1 to (null)
    May 14 15:35:42 [edit]-MacBook-Pro com.apple.backupd[1764]: Copied 411032 files (19.7 GB) from volume Macintosh HD.
    May 14 15:35:42 [edit]-MacBook-Pro com.apple.backupd[1764]: Copy stage failed with error:11
    May 14 15:35:52 [edit]-MacBook-Pro com.apple.backupd[1764]: Backup failed with error: 11
    ...so, what's up with the "Error: (-36)" on all the "MobileSync" entries...???
    Message was edited by: CalgaryRyan

  • Ambiguous Error

    Hi i m getting Ambiguous Error in my program, can ne one tel me plz wats that mean?
    Error:
    java.beans.Statement > Ambiguous Error

    it is because ur program is earlier in 1.3 n now ur running in 1.4 or higher..............
    In 1.4 java.bean.Statement class is introduced where as java.sql.Statement Interface was earlier there, so the compiler is confused about which statement object to take.
    Just write java.sql.Statement where u r using Statement n write me if still problem wil come
    Sumit

  • Column in field list is ambiguous error

    i am using jdbc in my program with a query statement that retrieve holdingsID by querying different tables. when i run the program it has an error saying
    Column HoldingsID in field list is ambiguous, what does this mean? How can i solve it?
    here is my code, included is my sql select statement please check it.
            String key=request.getParameter("key");  
              Connection conn = null;
              String[][] a=new String[10][3];          
              int r=0;
              String qstr="";
              ResultSet rs=null;          
              try{     
              Class.forName("com.mysql.jdbc.Driver").newInstance();
              conn = DriverManager.getConnection("jdbc:mysql://localhost/scitemp?user=scinetadmin&password=A1kl@taN");
              Statement stmt=conn.createStatement();
                qstr="SELECT DISTINCT HoldingsID FROM tblHoldings, tblHoldingsAuthorName," +
                         "tblHoldingsSubject, tblHoldingsPublisherName"+
                      " WHERE (tblHoldings.Title LIKE "+"'"+"%"+key+"%"+"'"+")"+" OR "+
                     "(tblHoldings.Contents LIKE "+"'"+"%"+key+"%"+"'"+")"+" OR " +
                     "(tblHoldingsAuthorName.AuthorName LIKE "+"'"+"%"+key+"%"+"'"+")"+" OR " +
                    "(tblHoldingsSubject.SubjectHeadings LIKE "+"'"+"%"+key+"%"+"'"+")"+" OR " +
                   "(tblHoldingsPublisherName.PublicationDate = "+"'"+key+"'"+")"+
                         " ORDER BY HoldingsID";                              
              rs  = stmt.executeQuery(qstr);
              while ( rs.next() && r <10) {                     
                        a[r][0]=rs.getString("HoldingsID");     
                        a[r][1]="1";
                        a[r][2]="SILMS";  
                        r++;      
              }catch(Exception e){out.println("error:"+e.getMessage());}-----
    thanks in advance for your help

    Actually, this is probably going to be a bit more efficient on large scale data. (I'm guessing, if it matters then test...)
    SELECT DISTINCT HoldingsID FROM
      SELECT HoldingsID
      FROM tblHoldings
      WHERE tblHoldings.Title LIKE '%key%'
           OR tblHoldings.Contents LIKE '%key%'
    UNION ALL
      SELECT HoldingsID
      FROM tblHoldingsAuthorName
      WHERE tblHoldingsAuthorName.AuthorName LIKE '%key%'
    UNION ALL
      SELECT HoldingsID
      FROM tblHoldingsSubject
      WHERE tblHoldingsSubject.SubjectHeadings LIKE  '%key%'
    UNION ALL
      SELECT HoldingsID
      FROM tblHoldingsPublisherName
      WHERE tblHoldingsPublisherName.PublicationDate = 'key'
    ORDER BY HoldingsIDThe diffence is when the sort(s) to create distinct rows is done. In the first version, UNION must produce only distinct values, so three sorts must be performed, one to create each UNION intermediate result. In the 2nd version, UNION ALL doesn't produce
    distinct values, we delay the sorting until the last minute and sort all candidates once, instead of one sub-set once, one sub-set twice and two sub-sets 3 times. If this is a school project, the difference probably doesn't matter.
    By the way, many databases implement the DISTINCT keyword in such a way that it creates sorted result sets, sorted by the resulting column values. As far as I know, this is not guaranteed by the SQL standard, so the additional ORDER BY clause is still needed for rigourous portability to databases that don't work that way. If that's not a concern and speed is, in many situations you can drop the ORDER BY; however for small result sets the difference is nearly invisible, and even for moderately large result sets, sorting an already sorted result set is usually an Order(n) in-memory operation. For really big results, the database will be swapping results to disk as it sorts and this sort of optimization matters then. This also applies to the use of GROUP BY.

  • Ambiguous error messages ??

    Hi,
    I'm having a problem trying to implement a progressMonitor
    for my application, and have used the classes provided in the Java Tutorial, i'm getting the following error messages:
    "Visual.java": Error #: 304 : reference to Timer is ambiguous; both class java.util.Timer in package java.util and class javax.swing.Timer in package javax.swing match at line 46, column 15
    "Visual.java": Error #: 304 : reference to Timer is ambiguous; both class java.util.Timer in package java.util and class javax.swing.Timer in package javax.swing match at line 52, column 25
    where the first error message refers to the following line of code:
    private Timer timer;                                                       and the second error message refers to the following line of code:
    timer = new Timer(ONE_SECOND, new TimerListener());I was hoping someone could help me out and tell me what these errors actually mean??
    Thanks very much for any help

    The problem is you imported 2 timer classes, one in javax.swing.Timer and one in java.util.Timer
    The way to get around this is to use the exact classes you want to import in your import statements as opposed to using the '*' .
    Hi,
    I'm having a problem trying to implement a
    progressMonitor
    for my application, and have used the classes provided
    in the Java Tutorial, i'm getting the following error
    messages:
    "Visual.java": Error #: 304 : reference to Timer is
    ambiguous; both class java.util.Timer in package
    java.util and class javax.swing.Timer in package
    javax.swing match at line 46, column 15
    "Visual.java": Error #: 304 : reference to Timer is
    ambiguous; both class java.util.Timer in package
    java.util and class javax.swing.Timer in package
    javax.swing match at line 52, column 25
    where the first error message refers to the following
    line of code:
    private Timer timer;and the second error message refers to the following
    line of code:
    timer = new Timer(ONE_SECOND, new TimerListener());I was hoping someone could help me out and tell me
    what these errors actually mean??
    Thanks very much for any help

  • Overload methods error in web services

    Hi Experts,
    We want to invoke a DotNet web service. The dotnet web service contains overload methods. When I try to invoke this web service from WSNavigator, it shows "WSDL Operation with name search is overloaded (defined twice). Operation overloading is not supported by proxy generator" error. How to solve this issue?
    Best Regards
    Tom

    Hi Tom,
    TO use overloaded methods u have to specify Message Name property.Find the example.
    Here method say() is overloaded
    [webMethod]
    public string say()
        return "hello";
    [web Method]
    public string say(string p_Name)
        return "Hello " + p_Name + "!";
    Adding the Message name property.
    [WebMethod]public string say()
        return "hello";
    [WebMethod (MessageName="WithOneString")]
    public string say(string p_Name)
        return "Hello" + p_Name + "!";
    Regards,
    Sri.
    Edited by: Srikanth Thatipally on Feb 27, 2009 3:33 PM

  • System overload (-10011) error????

    Okay, so I know VERY little about Logic. Last night I had my guitar plugged into the mic-in and was trying to record some stuff through guitar rig r whatever the plug-in is called. I kept getting some latency issues, so I played with the buffer sizes with mixed results. At any rate, my MBP is only 2 months old! I am definitely under the impression I shouldn't be getting these errors. Here are my basic specs:
    Intel Core 2 Duo
    2.2 GHz
    Memory: 2 GB
    HD 120GB
    GeForce 8600M GT 128 MB
    Resolution: 1440 x 900
    Newest OS and current Logic updates
    Any ideas/suggestions?

    No it's a users forum...
    But there are many things to consider regarding Latency and System Overload errors.
    This doc may help...
    http://docs.info.apple.com/article.html?artnum=304970
    Also although an old post I noticed a couple of things in the OP's post. There is a distinction between mic, line and instrument level and the type of guitar one has.
    The notebook employs a 'line' level input.
    It's hard to ascertain without specific's, but a passive pick up equipped guitar ( your typical electric guitar) into a line-in is not ideal. Not only a level mismatch but an impedance mismatch also. Although active pick ups will have better luck and I don't know if Apple still employs combi converters with a small pre. Regardless, less then ideal.
    AFAIK and in my experience, a FW interface with good drivers will have less latency then going directly through a Mac's line level input and converters.
    And another thing in notebooks, a typical 5400 rpm internal HD can and usually will have a hard time keeping up with audio and video. And Guitar Rig itself places a load on the CPU also.
    Now it's also possible something else is going on. But I would look at optimizing and considering the info in the link first before assuming Apple has fallen down.

  • Capacity overload check-error

    Hi Experts,
    I have a query. When i create different production orders for a single material on the same dates( assume qty as 100,200.300) on 2 nd march 2012. Now as per the inhouse production time, the work centers are overloaded. But , while doing capacity availability check, system says capacity available at all work centers.
    Any help in this regard

    6346,
    One way to dispatch is in the planning table.  CM21 > select the orders > F5.
    It may be that you would benefit by downloading and reading the old SAP printfile for cap leveling at
    http://help.sap.com/printdocu/core/Print46c/en/data/pdf/PPCRPLVL/PPCRP_LVL.pdf
    It is a little dated, but mostly Cap Leveling hasn't changed that much since 4.6C.  It contains most of the information found in SAP online help.
    If you have a detailed question about a specific step, please post it.  However, I am afraid that all the details and the ramifications of capacity leveling are not something you can understand by reading a 150 word online post.  If you are having difficulty figuring out how all this fits together, I think you should consult with a local Capacity Planning expert.  If one is not available, and the online help docs are inadequate, you could consider one of the excellent SAP classes, such as https://training.sap.com/us/en/course/scm365-capacity-evaluation-leveling-in-ecc-classroom-095-us-en/ or a similar class held in your country.
    Best Regards,
    DB49

Maybe you are looking for