dcsimg
how to solve this error "reference to Date is ambiguous, both class java.sql.Date in java.sql and class java.util.Date in java.util match"
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Friday, August 10, 2001 06:25 AM

hi,

i always came across this error

"reference to Date is ambiguous, both class java.sql.Date in java.sql and class java.util.Date in java.util match"

whenever i import java.util and java.sql .So i am wandering if anyone could solve this error

Re: how to solve this error "reference to Date is ambiguous, both class java.sql.Date in java.sql and class java.util.Date in java.util match"

Posted By:   Bozidar_Dangubic  
Posted On:   Friday, August 10, 2001 06:43 AM

well, it is simple to solve. import only classes you need instead of importing the entire package. then, a reference to Date will not be ambiquous. if you need both java.sql.Date and java.util.Date then you will need to reference them by their fully qualified class name as I did above.

Re: how to solve this error "reference to Date is ambiguous, both class java.sql.Date in java.sql and class java.util.Date in java.util match"

Posted By:   Dermot_Hennessy  
Posted On:   Friday, August 10, 2001 06:42 AM

It is generally bad practice, from the point of view of code maintainability, to import, e.g. java.util.*. What you should import is only those classes from the package which you are using in your class. That's point 1.


If you are using both java.util.Date and java.sql.Date, the easiest thing to do is to import one of them and to explicitly refer to the full package structure of the other every time you use it, i.e.

import java.util.Date;
.....
... Date d = new Date(); // returns a java.util.Date
java.sql.Date d = new java.sql.Date(); speaks for itself

Dermot
About | Sitemap | Contact