Comparable help

Hi
I am trying to get rid of an "unchecked" warning, but I guess I have problems understanding how generics work.
I have an enum defined in the following way:
public enum Domain {
     INT(Number.class) {
          public Integer parse(Token token) {
               return Integer.decode(token.getValue());
     KEY(String.class) {
          public String parse(Token token) {
               return token.getValue();
     TEXT(String.class)  {
          public String parse(Token token) {
               return token.getValue();
     OCTET(String.class)  {
          public String parse(Token token) {
               return token.getValue();
     OCTETS(String.class)  {
          public String parse(Token token) {
               return token.getValue();
     DATE(java.sql.Timestamp.class) {
          public java.util.Date parse(Token token) {
               return new Timestamp(Long.parseLong(token.getValue()) * 1000);
     INT8(Number.class) {
          public Short parse(Token token) {
               return Short.decode(token.getValue());
     INT64(Number.class) {
          public Long parse(Token token) {
               return Long.decode(token.getValue());
     final Class sqlType;
     Domain(Class sqlType) {
          this.sqlType = sqlType;
     public Class getSqlType() {
          return sqlType;
     abstract public Comparable<? extends Comparable<?>> parse(Token token);
}When I want to use it, I get the value using
Comparable<Object> value = domain.parse(token)which gives me the unchecked error. Later I want to compare to values:
value1.compareTo(value2)Any declaration of "value" other than Comparable<Object> fails to compile the compareTo() call.
Any ideas how I need to declare "value" ?

Here's a version that compiles warning-free and allows you to compare arbitrary Domain instances mutually.
The catch: you can't leverage the added typesafety that the covariant return type provided. OTOH, this would only kick in if you used one of the enum constants directly. I guess you can't have it both ways...
public enum Domain {
     INT(Number.class) {
          public Comparable<Object> parse(Token token) {
               return wrap(Integer.decode(token.getValue()), Integer.class);
     KEY(String.class) {
          public Comparable<Object> parse(Token token) {
               return wrap(token.getValue(), String.class);
     final Class sqlType;
     Domain(Class sqlType) {
          this.sqlType = sqlType;
     public Class getSqlType() {
          return sqlType;
     abstract public Comparable<Object> parse(Token token);
     static <T extends Comparable<T>> Comparable<Object> wrap(final T value, final Class<T> cl) {
          return new Comparable<Object>() {
               public int compareTo(Object o) {
                    return value.compareTo(cl.cast(o));
}

Similar Messages

  • Using Comparator-Help

    Hi,
    Below is my code.It compare values and print the results.When i input five values,out of which two are same(ABCD) .So the output i get is:
    ABCD:1234.0
    ABCDE:1234.0
    NJKIOP:1234.0
    WASD:1234.0
    But i want all the five values i want results to be like this:
    ABCD:1234.0
    ABCD:1234.0
    ABCDE:1234.0
    NJKIOP:1234.0
    WASD:1234.0
    So what change should i make in my code .Please help
    import java.util.*;
    class TComp implements Comparator
    public int compare(Object a,Object b)
    int i,j,k;
    String aStr,bStr;
    aStr=(String)a;
    bStr=(String)b;
    return aStr.compareTo(bStr);
    class Ordering1
    public static void main(String a[])
    TreeMap tm=new TreeMap(new TComp());
    tm.put("ABCD",new Double(1234));
    tm.put("ABCDE",new Double(1234));
    tm.put("ABCD",new Double(1234));
    tm.put("WASD",new Double(1234));
    tm.put("NJKIOP",new Double(1234));
    Set set=tm.entrySet();
    Iterator itr=set.iterator();
    while(itr.hasNext())
    Map.Entry me=(Map.Entry)itr.next();
    System.out.println(me.getKey()+":"+me.getValue());
    Thanks in advance for any help.
    Vineet

    A tree does only hold unique values.A Map holds unique key values only. You cannot store many "ABCD" keys in a TreaMap or HashMap.
    What you'll can do is to store a list of items for a specific key using for example a LinkedList to handle collisions. What you get is a HashMap with two type of items. On item is a plain String, and the other is a LinkedList of Strings.

  • General Comparator help?

    I'm creating an "OrderedList<E>" (class name) which is like an arraylist but inside has an array of Objects to add, remove, get, etc. from and I would like to know if there is a link to a general comparator i could look at? because I can't really get the list in order without making my own general comparator for the general OrderedList. Thanks =].

    Not sure what you mean by "general comparator," but maybe these will help:
    [http://www.onjava.com/lpt/a/3286]
    [http://java.sun.com/docs/books/tutorial/collections/interfaces/order.html]
    [http://www.javaworld.com/javaworld/jw-12-2002/jw-1227-sort.html]

  • Comparing, help please

    I have a program that is supposed to compare an array of 3 characters and determine if that set of characters is good or bad, a good set being a char of R and Y and the third char not being B, but i cant figure it out, seems to not like me. could i get some pointers on what i did wrong?
    char[] toxic;
              boolean doorIsToxic = false;
              for(int i=0;i<door;i++){
                   toxic = new char[3];
                   for(int c=0;c<3;c++){
                        if(rightDoor[2] == 'B')
                             toxic[2] = 'B';
                        else
                             toxic[2] = 'N';
                        if(rightDoor[i][2] == 'R')
                             toxic[2] = 'R';
                        else
                             toxic[2] = 'N';
                        if(rightDoor[i][2] == 'Y')
                             toxic[2] = 'Y';
                        else
                             toxic[2] = 'N';
                        if(rightDoor[i][1] == 'R')
                             toxic[1] = 'R';
                        else
                             toxic[2] = 'N';
                        if(rightDoor[i][1] == 'Y')
                             toxic[1] = 'Y';
                        else
                             toxic[2] = 'N';
                        if(rightDoor[i][0] == 'R')
                             toxic[0] = 'R';
                        else
                             toxic[2] = 'N';
                        if(rightDoor[i][0] == 'Y')
                             toxic[0] = 'Y';
                        else
                             toxic[2] = 'N';
                   if(toxic[2] == 'B')
                        doorIsToxic = false;
                   else{
                        doorIsToxic = false;
                        if(toxic[2] == 'R' && toxic[1] == 'Y')
                             doorIsToxic = true;
                        if(toxic[2] == 'Y' && toxic[1] == 'R')
                             doorIsToxic = true;
                        if(toxic[2] == 'R' && toxic[0] == 'Y')
                             doorIsToxic = true;
                        if(toxic[2] == 'Y' && toxic[0] == 'R')
                             doorIsToxic = true;
                        if(toxic[1] == 'R' && toxic[2] == 'Y')
                             doorIsToxic = true;
                        if(toxic[1] == 'Y' && toxic[2] == 'R')
                             doorIsToxic = true;
                        if(toxic[1] == 'R' && toxic[0] == 'Y')
                             doorIsToxic = true;
                        if(toxic[1] == 'Y' && toxic[0] == 'R')
                             doorIsToxic = true;
                        if(toxic[0] == 'R' && toxic[2] == 'Y')
                             doorIsToxic = true;
                        if(toxic[0] == 'Y' && toxic[2] == 'R')
                             doorIsToxic = true;
                        if(toxic[0] == 'R' && toxic[1] == 'Y')
                             doorIsToxic = true;
                        if(toxic[0] == 'Y' && toxic[1] == 'R')
                             doorIsToxic = true;
                   if(doorIsToxic == true){
                        System.out.println("Door "+i+" is Toxic: "+toxic[0]+toxic[1]+toxic[2]);

    I think this is the logic to code.
    1. If array[2] is 'B' then the result is false.
    2. Otherwise, loop through the array. Use variables to track whether any of the characters are R and whether any of them are Y.
    3. When the loop is complete, if both variables indicate that at least one R and at least one Y was found, then the result is true. Otherwise the result is false.

  • Sort an object by different fields

    Hello!
    Sorry for the (maybe) bad englisch but I'm a German.
    If I have an object fith different fields for example field1, field2, field3.
    To write a method which sorts an array of this objects by a given field?
    I mean something like this
    sort(String field, object[] o) {
    //sort by field
    instead of this
    sortbyfield1(object o){
    //sort by "field1"
    sortbyfield2(object[] o){
    //sort by "field2"
    hope you understood
    thanks
    Stefan

    When faced with this problem I usually use a Comparator helper class. Depending on whether the Comparator can be re-used I'll create a separate class or if not an inner or anonymous inner class. For example:
    import java.util.Comparator;
    import java.util.Arrays;
    import java.util.List;
    import java.util.Collections;
    public class Main {
      // Compares Fields.f1 ascending
      public Comparator c1 = new Comparator() {
        public int compare(Object o1,
                           Object o2) {
          return ((Main.Fields)o1).f1.compareTo(((Main.Fields)o2).f1);
      public void sortem() {
        // Create our array of objects
        Object[] array = new Object[] {
          new Fields(new Integer(1),3,"3"),
          new Fields(new Integer(2),2,"1"),
          new Fields(new Integer(3),1,"2")
        // Sort on Field.f1 using reusable comparator
        Arrays.sort(array,c1);
        System.out.println(Arrays.asList(array));
        // Sort on Field.f2 using inner class
        Arrays.sort(array,new C2());
        System.out.println(Arrays.asList(array));
        // Sort on f3 using an anonymous inner class
        Arrays.sort(array, new Comparator(){
          public int compare(Object o1,
                           Object o2) {
            return((Main.Fields)o1).f3.compareTo(((Main.Fields)o2).f3);
        System.out.println(Arrays.asList(array));
      public static void main(String[] args) {
        Main m = new Main();
        m.sortem();
      // Class with many fields of different types
      class Fields {
        public Integer f1;
        public int     f2;
        public String  f3;
        public Fields(Integer f1, int f2, String f3) {
          this.f1 = f1;
          this.f2 = f2;
          this.f3 = f3;
        public String toString() {
          return ""+f1+" "+f2+" "+f3;
      // Inner class comparator on Field.f2
      class C2 implements Comparator {
        public int compare(Object o1,
                           Object o2) {
          int result = 0;
          int i1 = ((Main.Fields)o1).f2;
          int i2 = ((Main.Fields)o2).f2;
          if (i1==i1) result = 0;
          if(i1<i2) result = -1;
          else if (i1>i2) result = 1;
          return result;

  • Kernel Panics often - can anyone decipher error message?

    Hi, I am running a MacBook Pro 17" mid 2009 with Yosemite (connected to an Cinema Display)
    2.8GHz Intel Core 2 Duo
    8gb 1333 MHz DDR3
    SSD Drive
    NVIDIA GeForce 9400M 256mb
    I work often in Adobe software, and I typically keep iTunes running playing music connected via Airplay to external speakers.
    Lately I have been getting the black screen and the resulting error report. I am not tech-savvy enough to be able to decipher this report.
    Does anyone know what this report is telling me? Looks like something with iTunes possiibly?
    Any advice? I really don't even know where to begin looking for help - and I live hours away from the closest Apple store. There is a BestBuy with an Apple section and rep, but I don't think they offer comparable help.
    Thanks so much!
    Here is report:
    Anonymous UUID:       D63C7B21-59E6-7DA8-D5BA-C0431EECC9CC
    Fri Jan 30 10:53:25 2015
    *** Panic Report ***
    panic(cpu 1 caller 0xffffff801381e80a): Kernel trap at 0xffffff80139a62e7, type 14=page fault, registers:
    CR0: 0x0000000080010033, CR2: 0x0000000000000010, CR3: 0x00000001011f3000, CR4: 0x0000000000002660
    RAX: 0x0000000000000000, RBX: 0xffffff80139b1f00, RCX: 0xffffff80265e5e00, RDX: 0x0000000000000002
    RSP: 0xffffff8113f13730, RBP: 0xffffff8113f13860, RSI: 0x0000000000000002, RDI: 0xffffff80265e5ab0
    R8:  0xffffff802580f500, R9:  0xffffff810fca5200, R10: 0x0000000000007017, R11: 0xffffff8113f13d9c
    R12: 0x0000000000000000, R13: 0x0000000000000000, R14: 0x0000000000000000, R15: 0xffffff80253f2d90
    RFL: 0x0000000000010202, RIP: 0xffffff80139a62e7, CS:  0x0000000000000008, SS:  0x0000000000000010
    Fault CR2: 0x0000000000000010, Error code: 0x0000000000000000, Fault CPU: 0x1
    Backtrace (CPU 1), Frame : Return Address
    0xffffff8113f133e0 : 0xffffff801373a811
    0xffffff8113f13460 : 0xffffff801381e80a
    0xffffff8113f13620 : 0xffffff801383a443
    0xffffff8113f13640 : 0xffffff80139a62e7
    0xffffff8113f13860 : 0xffffff8013a7748d
    0xffffff8113f13be0 : 0xffffff8013a980db
    0xffffff8113f13cf0 : 0xffffff8013c17740
    0xffffff8113f13de0 : 0xffffff8013c29654
    0xffffff8113f13ee0 : 0xffffff8013c2641b
    0xffffff8113f13f50 : 0xffffff8013c4dcb2
    0xffffff8113f13fb0 : 0xffffff801383ac46
    BSD process name corresponding to current thread: iTunes
    Mac OS version:
    14B25
    Kernel version:
    Darwin Kernel Version 14.0.0: Fri Sep 19 00:26:44 PDT 2014; root:xnu-2782.1.97~2/RELEASE_X86_64
    Kernel UUID: 89E10306-BC78-3A3B-955C-7C4922577E61
    Kernel slide:     0x0000000013400000
    Kernel text base: 0xffffff8013600000
    __HIB  text base: 0xffffff8013500000
    System model name: MacBookPro5,2 (Mac-F2268EC8)
    System uptime in nanoseconds: 38035728524704
    last loaded kext at 37453447842204: com.apple.driver.AppleUSBCDC 4.2.2b5 (addr 0xffffff7f95cfd000, size 20480)
    last unloaded kext at 37513626116216: com.apple.driver.AppleUSBCDC 4.2.2b5 (addr 0xffffff7f95cfd000, size 16384)
    loaded kexts:
    com.apple.driver.AppleBluetoothMultitouch 85.3
    com.apple.driver.AppleHWSensor 1.9.5d0
    com.apple.driver.AGPM 100.14.37
    com.apple.filesystems.autofs 3.0
    com.apple.iokit.IOBluetoothSerialManager 4.3.1f2
    com.apple.driver.AppleOSXWatchdog 1
    com.apple.driver.AppleMikeyHIDDriver 124
    com.apple.driver.AppleMikeyDriver 267.0
    com.apple.driver.AppleHDA 267.0
    com.apple.iokit.IOUserEthernet 1.0.1
    com.apple.Dont_Steal_Mac_OS_X 7.0.0
    com.apple.driver.AppleHWAccess 1
    com.apple.driver.AppleHV 1
    com.apple.driver.ACPI_SMC_PlatformPlugin 1.0.0
    com.apple.driver.AudioAUUC 1.70
    com.apple.GeForceTesla 10.0.0
    com.apple.iokit.BroadcomBluetoothHostControllerUSBTransport 4.3.1f2
    com.apple.driver.AppleSMCLMU 2.0.4d1
    com.apple.driver.AppleLPC 1.7.3
    com.apple.driver.AppleMuxControl 3.7.21
    com.apple.driver.AppleUpstreamUserClient 3.6.1
    com.apple.driver.AppleMCCSControl 1.2.10
    com.apple.driver.SMCMotionSensor 3.0.4d1
    com.apple.driver.AppleUSBTCButtons 240.2
    com.apple.driver.AppleUSBDisplays 372.1
    com.apple.driver.AppleUSBTCKeyboard 240.2
    com.apple.driver.AppleIRController 327.5
    com.apple.AppleFSCompression.AppleFSCompressionTypeDataless 1.0.0d1
    com.apple.AppleFSCompression.AppleFSCompressionTypeZlib 1.0.0d1
    com.apple.BootCache 35
    com.apple.iokit.SCSITaskUserClient 3.7.0
    com.apple.driver.XsanFilter 404
    com.apple.iokit.IOAHCIBlockStorage 2.6.5
    com.apple.driver.AirPort.Brcm4331 800.20.24
    com.apple.driver.AppleUSBHub 705.4.1
    com.apple.driver.AppleSmartBatteryManager 161.0.0
    com.apple.driver.AppleFWOHCI 5.5.2
    com.apple.driver.AppleUSBEHCI 705.4.14
    com.apple.nvenet 2.0.22
    com.apple.driver.AppleUSBOHCI 656.4.1
    com.apple.driver.AppleAHCIPort 3.0.7
    com.apple.driver.AppleRTC 2.0
    com.apple.driver.AppleHPET 1.8
    com.apple.driver.AppleACPIButtons 3.1
    com.apple.driver.AppleSMBIOS 2.1
    com.apple.driver.AppleACPIEC 3.1
    com.apple.driver.AppleAPIC 1.7
    com.apple.driver.AppleIntelCPUPowerManagementClient 218.0.0
    com.apple.nke.applicationfirewall 161
    com.apple.security.quarantine 3
    com.apple.security.TMSafetyNet 8
    com.apple.driver.AppleIntelCPUPowerManagement 218.0.0
    com.apple.driver.IOBluetoothHIDDriver 4.3.1f2
    com.apple.driver.AppleMultitouchDriver 260.30
    com.apple.AppleGraphicsDeviceControl 3.7.21
    com.apple.kext.triggers 1.0
    com.apple.iokit.IOSerialFamily 11
    com.apple.driver.DspFuncLib 267.0
    com.apple.kext.OSvKernDSPLib 1.15
    com.apple.iokit.IOSurface 97
    com.apple.driver.AppleSMBusPCI 1.0.12d1
    com.apple.driver.IOPlatformPluginLegacy 1.0.0
    com.apple.nvidia.classic.NVDANV50HalTesla 10.0.0
    com.apple.iokit.IOUSBUserClient 705.4.0
    com.apple.iokit.IOBluetoothHostControllerUSBTransport 4.3.1f2
    com.apple.iokit.IOBluetoothFamily 4.3.1f2
    com.apple.iokit.IOFireWireIP 2.2.6
    com.apple.driver.AppleHDAController 267.0
    com.apple.iokit.IOHDAFamily 267.0
    com.apple.driver.IOPlatformPluginFamily 5.8.0d49
    com.apple.driver.AppleGraphicsControl 3.7.21
    com.apple.driver.AppleBacklightExpert 1.1.0
    com.apple.driver.AppleSMBusController 1.0.13d1
    com.apple.nvidia.classic.NVDAResmanTesla 10.0.0
    com.apple.iokit.IONDRVSupport 2.4.1
    com.apple.iokit.IOGraphicsFamily 2.4.1
    com.apple.driver.AppleSMC 3.1.9
    com.apple.driver.AppleUSBAudio 295.22
    com.apple.iokit.IOAudioFamily 200.6
    com.apple.vecLib.kext 1.2.0
    com.apple.iokit.IOUSBHIDDriverPM 705.4.5
    com.apple.driver.AppleUSBMultitouch 245.2
    com.apple.iokit.IOUSBHIDDriver 705.4.0
    com.apple.driver.AppleUSBMergeNub 705.4.0
    com.apple.driver.AppleUSBComposite 705.4.9
    com.apple.iokit.IOSCSIMultimediaCommandsDevice 3.7.0
    com.apple.iokit.IOBDStorageFamily 1.7
    com.apple.iokit.IODVDStorageFamily 1.7.1
    com.apple.iokit.IOCDStorageFamily 1.7.1
    com.apple.iokit.IOAHCISerialATAPI 2.6.1
    com.apple.iokit.IOSCSIArchitectureModelFamily 3.7.0
    com.apple.iokit.IO80211Family 700.52
    com.apple.iokit.IOFireWireFamily 4.5.6
    com.apple.iokit.IONetworkingFamily 3.2
    com.apple.iokit.IOUSBFamily 705.4.14
    com.apple.driver.NVSMU 2.2.9
    com.apple.iokit.IOAHCIFamily 2.7.0
    com.apple.driver.AppleEFINVRAM 2.0
    com.apple.driver.AppleEFIRuntime 2.0
    com.apple.iokit.IOHIDFamily 2.0.0
    com.apple.iokit.IOSMBusFamily 1.1
    com.apple.security.sandbox 300.0
    com.apple.kext.AppleMatch 1.0.0d1
    com.apple.driver.AppleKeyStore 2
    com.apple.driver.AppleMobileFileIntegrity 1.0.5
    com.apple.driver.AppleCredentialManager 1.0
    com.apple.driver.DiskImages 389.1
    com.apple.iokit.IOStorageFamily 2.0
    com.apple.iokit.IOReportFamily 31
    com.apple.driver.AppleFDEKeyStore 28.30
    com.apple.driver.AppleACPIPlatform 3.1
    com.apple.iokit.IOPCIFamily 2.9
    com.apple.iokit.IOACPIFamily 1.4
    com.apple.kec.corecrypto 1.0
    com.apple.kec.Libm 1
    com.apple.kec.pthread 1
    Model: MacBookPro5,2, BootROM MBP52.008E.B05, 2 processors, Intel Core 2 Duo, 2.8 GHz, 8 GB, SMC 1.42f4
    Graphics: NVIDIA GeForce 9400M, NVIDIA GeForce 9400M, PCI, 256 MB
    Graphics: NVIDIA GeForce 9600M GT, NVIDIA GeForce 9600M GT, PCIe, 512 MB
    Memory Module: BANK 0/DIMM0, 4 GB, DDR3, 1333 MHz, 0x0000, 0x344742444E41554344424120202020202020
    Memory Module: BANK 1/DIMM0, 4 GB, DDR3, 1333 MHz, 0x0000, 0x344742444E41554344424120202020202020
    AirPort: spairport_wireless_card_type_airport_extreme (0x14E4, 0x8D), Broadcom BCM43xx 1.0 (5.106.98.100.24)
    Bluetooth: Version 4.3.1f2 15015, 3 services, 27 devices, 1 incoming serial ports
    Network Service: AirPort, AirPort, en1
    Serial ATA Device: OWC Mercury Electra 3G SSD, 480.1 GB
    Serial ATA Device: HL-DT-ST DVDRW  GS21N
    USB Device: Hub
    USB Device: Display iSight
    USB Device: Display Audio
    USB Device: Apple LED Cinema Display
    USB Device: Built-in iSight
    USB Device: BRCM2046 Hub
    USB Device: Bluetooth USB Host Controller
    USB Device: IR Receiver
    USB Device: Apple Internal Keyboard / Trackpad
    Thunderbolt Bus:

    Ok, thanks again! I am confused why my Mac tells me I can use 1333 Mhz DDR3 memory, when you are telling me I need to use 1067 MHx SDRAM?
    Is there something I am missing or doing wrong here? Could the RAM I have in there now have gone "bad" somehow?
    Sorry for confusion - I do appreciate your help - I'm just trying to understand and make sure this is the issue before I spend more money.
    I also realized this morning that I had less than 10% free space on my hard drive, so I fixed that ... I know sometimes that causes issues.
    Thanks again!

  • On my mac how do I send an attachement from Firefox to a 3rd party? I have been unable to locat the proper icon.

    trying to send from firefox an attachment to a 3rd party and unable to locate the proper icon.

    Firefox doesn't have a built-in emailer, so I'm guessing you are using your provider's webmail site. Each site has different buttons for adding attachments. Do you want to indicate which one you're using to see whether anyone can provide specific comments?
    Also, your browser reported to the forum that you are running Forefox 3.6.13, which is a very old version with numerous publicly disclosed security vulnerabilities. Is that version number correct? (You can compare Help > About Firefox)

  • Need help in using Comparator

    hi,
    I have a list of objects in that there is a field called lastModifiedDate.
    I have to sort the list on the basis of this filed.
    I m trying to sort the list using Comparator, also converting the date field in long. But I m getting back the list, in that entries are sorted but duplicates though the original list is having unique values.
    I have used the code as follows:
    public int compare(Object arg0, Object arg1) {
    if (((((ComparatorEntity) arg0).getDate()) - (((ComparatorEntity) arg1).getDate())) < 0) {
         return 1 ;
    else {
         return 0 ;
    please help me
    Thanx in advance.
    Abhishek

    Well, your Comparator is wrong because it never returns -1. That won't cause it to insert additional elements though. I'd suggest you print both the list and its size, both before and after sorting.
    Also, if you put the -1 return value in following the pattern you've started, the list will be sorted in reverse order. That may be what you want, but I thought I'd point it out in case it's not.
    When you post code, please use [code] and [/code] tags as described in Formatting Help on the message entry page. It makes it much easier to read.

  • Need help in using SQL in a jsp file to compare date and time

    hi every one,
    Actually I am doing a project using JSP. I need to compare a date field in the database (MS Acess) to the current system date and time. I have to do this in a select statement.
    I have alredy defined a variable of type Date in the JSP file and I am comparing this variable to the date in the database through a select statemant.
    Here is what I am doing
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss");
              java.util.Date today = new java.util.Date();
              String myDate=sdf.format(today);
    query = "SELECT Car_ID, Model_ID, Year, Ext_Color, Price from Cars where EDate <= "+myDate+" ;";
    EDate is the feild in the database and it's format is (5/12/2008 5:29:47 PM) it is of type Date/Time in MS Acess.
    when I execute the query it gives the following error
    SQL error:java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing operator) in query expression 'EDate <= 2008-10-16 08:10:07'.
    I hope any one can help me with that error and answer my question, I've tried too many things but nothing helps
    Thanks in advance :-)

    Hi,
    When the comparision is needed to be done with the current date , we don't need to send in Java
    Date then format it and compare with MS Acess Date.
    In MS Access we have Date() function which will give you the current date.
    So you can try rewriting your query as following :
    query = "SELECT Car_ID, Model_ID, Year, Ext_Color, Price from Cars where EDate <= Date() ;"; ---------------------
    Hope this helps.
    Thanks

  • Need help to compare and replace

    Hi All,
    I have a cumulative file that is appended at the end of the month. The Table holds customer information, like:
    customer_id, name, address, phone, notes, DATE_STAMP
    In addition to this, I have other Tables that are split up into monthly Tables and information for these monthly Tables is gotten from this one cumulative Table. When I collect information at the end of the month (which is appended into the cumulative Table that grows in size), I put the name of the MONTH into the DATE_STAMP column. MARCH, APRIL, MAY< JUNE, etc......
    So I select all of MARCH (from the cumulative Table) and then that is put into the MARCH Table. These monthly Tables are compared with other control Tables for analysis purposes.
    So, the challenge is that say in APRIL or in MAY, an important column value changes in the cumulative Table and I need to update the Monthly Tables to reflect that.
    So.... I will concentrate on the key columns.
    customer_id, DATE_STAMP, Sales_Person_Assigned
    From the cumulative Table (which has many months), say I select all of MARCH and move those customers to a MARCH_TABLE. I will use one customer as Example:
    customer_id, DATE_STAMP, Sales_Person_Assigned
    12345, MARCH, NULL
    Then in APRIL, more data goes into the cumulative file, and those are stamped APRIL for the DATE_STAMP column.
    So, when I check the customer that was in MARCH, now in this file, they might be like this: (sales person updated the record)
    customer_id, DATE_STAMP, Sales_Person_Assigned
    12345, MARCH, Frank Smith
    I need a way to take the CUMULATIVE Table and compare it with the corresponding MONTH_Table and update that Null to Frank Smith.
    So say it is: September now and we have 9 separate Tables Jan - September and the ONE cumulative Tables that has Jan - September, I need that one cumulative Table to check all the individual Tables and based on:
    customer_id AND DATE_STAMP - do a JOIN match there and if the value was null before in the Sales_Person_assigned field, if that is no longer null, update that to the new value from the cumulative to the monthly tables.
    Any help would be appreciated, sorry if this sounds too complicated.

    Thanks Sean and Frank for replying.
    This problem is a little bit more complicated, I didn't want to post all the little details, no body would read my post (I am afraid). The Sales people update their Store data in a Excel sheet, they have no access to a Database or know anything about databases, they can barely use Excel as it is. I know this sounds bad, but that's the way it is, I have no control over that.
    So in their sheet, the customer_id stays constant, and DATE_STAMP (once that is stamped) also stays constant, they might manually go in and change a NULL value under the Sales_Person_Assigned cell to the name of the Sales person.
    So when I bring in new records, and (2) the manual changes to records that are already there, I need to update that change from the CUMULATIVE into the MONTHLY.
    so:
    WAS
    customer_id: 12345
    DATE_STAMP: MARCH
    Sales_Person_Assigned: NULL
    NEXT MONTH IT NOW IS:
    customer_id: 12345
    DATE_STAMP: MARCH
    Sales_Person_Assigned: Frank Smith
    I need a query that will look into all the MONTHLY_TABLES and sync the change of that Sales_Person_Assigned.
    Because the entire Analysis (done by a different person and department) is based on the idea that a customer will shop more and spend more when they have a dedicated Sales_Associate to help them vs. no body.
    I hope this make it clear. Sean's Query is close to what I need.
    I was thinking if there is a way to this: If there is a change that makes it into the MONTHLY_TABLE to also maybe create a new column in the MONTHLY_TABLE so indicate a change and put a Date in there, so I know which rows were updated and which were not.
    Hope this is more clear.

  • HT201272 How do i see a list of the apps that have been downloaded and the dates and times and amounts?  Tried to follow the on-line thing but i want to compare what has been downloaded with my visa bill.  HELP!!

    How do i see a list of the apps that have been downloaded and the dates and times and amounts?  Tried to follow the on-line thing but i want to compare what has been downloaded with my visa bill.  HELP!!

    See this -> http://support.apple.com/kb/HT2727

  • Please help, cannot compare images in full screen mode

    I am not able to compare 2 images in full screen mode. I am using a MBP and a ACD 23". The main image will remain in the ACD while the image being compare is being shown in the MBP.
    I am able to compare images in the viewer mode.
    My main display is the ACD 23 which I selected using the display preferences under 'Arrangement' with the menu bar located on the ACD. In Aperture, Secondary Viewer is set to Blank.
    I had also tried different combinations of Main Viewer and Secondary Viewer settings but was not successful.
    Am I missing something? Anyone have the solution?Thanks in advance for any help.
    norheng

    Anyone have any suggestions to using Aperture to edit images using a MBP and ACD so that it best utilize Aperture full screen mode in comparing and narrowing down to the pick.
    I am now trying to use the MBP as the main display and ACD as the secondary. This way I am able to compare images with the MBP in the Browser mode and the ACD display the compare images full screen. It work with the secondary display - ACD set to mirror, span and alternate mode.
    It would be best if only one screen is use and hence save energy consumption (reducing global warming and bill, if it help).
    Thanks in advance for any suggestions or and solutions.
    norheng

  • In testing 9 and X, "Compare Docs" we have a critical issue and really need help!

    For years we have used Acrobat 7 to do PDF compares and we love it!  However, the company recently advised we must upgrade to 9 and then eventually to X.  In testing 9 and X, Compare Docs we have a critical issue and really need help.  Our PDFs are produced by IT in a batch process and one of our main, critical functions is to compare previous PDFs to current PDFs;  however, in using 9 the Compare screen automatically sets the Doc Description for our PDFs to "Scanned Doc" and does not produce any differences! If you try to change the setting to Reports --it totally shuts down both documents without running!  Version 7 runs the compare of the same PDFs  beautifully, pointing out all the differences, as usual!  Has this every happen to anyone?  Do you know what we can do to our PDFs to allow version 9 to do the compare and produce results?  Why is 9 treating these non-scanned PDF docs as such?  Thanks so much for any help or insight you can give me on this issue! 

    (Moved the discussion to the correct forum)

  • Help comparing the value of a button using the Property Node (I get a variant)

    Dear Sirs:
    (I'm using LabView 6. I guess the solution is different for 6.1)
    Currently I have created an array of Boolean RefNums (which point to many, many buttons). When I need to know when any (and which) of the buttons was pressed I just compare every element on the array with the constant TRUE. It fact, as the array is built from RefNums, I should compare the VALUE from the Property Node.
    The problem here is that the Property Node for this type of Boolean is a LV Variant, and I need to compare this with a TRUE/FALSE value.
    I tried to convert the TRUE constant to a LV variant and visc. But nothing works... I always get that none of the buttons was pressed.
    Here it co
    mes the question: "How can I compare the value of a Property Node for a Boolean (Button) with a TRUE (or False) constant?"
    BTW, maybe I should explain why I'm using RefNums instead of the direct values: As my project requires tons of buttons, I would preffer using RefNums to refer to them. (I.E. I could use a single VI that takes the RefNum and formats the button to hide it for certain users).
    I have enclosed a VI that contains what I've achieved until now, which is nothing
    I appreciate your time and help.
    Best regards,
    JAVIER VIDAL
    Attachments:
    Other_Main_Menu.vi ‏103 KB

    Javier,
    There is another problem in your code: the booleans are not polled by the main loop so they will remain false until the user presses them again. This renders the boolean latch action useless.
    What you can do is to change the mechanical action of the booleans to non-latch. When you detect a "true" in the polling loop, set the boolean to false again. One added benefit is that once all boolean are non-latch, the value property won't be a variant but a boolean so conversion is no longer needed.
    LabVIEW, C'est LabVIEW

  • Acrobat X Pro - Compare Documents - Need Help

    I'm running X Pro as a trial to determine if it is right to purchase for my company.  The main feature I am interested in is the "compare documents".  I am in the construction industry and part of my business is to provide estimates for projects.  We use acrobat 9 to view and comment on these documents and specialized software for the estimating portion.  Anyway, construction documents (aka blueprints) are commonly used in a pdf format.  As pricing develops, it is not uncommon for blueprints to change as the design of the building progresses.  Hence the allure of the compare document function.  Repeated attempts at comparing documents has proved unsuccesful.  I keep getting the message "unable to find matching document".  I have used both the "image" setting and the "scanned document" setting.  Any help would be greatly appreciated.

    I have a PC.  I’m running windows 8  64 bit, but this problem occurred on Windows Vista as well.  There are no error codes it just won’t open.  You can use the program that morning to convert or combine files into a pdf. then 2 hours later you go to repeat the process and nothing.  The icon for it will appear on your desktop for 5 sec. and then disappear.   That’s it nothing else happens.  The same results will occur no matter how you try to open the program, restart your computer, or check for updates.
    The only way to make the program work is to uninstall and reinstall it.  The first time this occurred the adobe rep told me to reinstall the whole suite.  It took 8 hours.  I have now found were I stored the suites setup files to reinstall the individual application verses the entire suite, but it is still annoying to have to re install it ever 30 days or so.  When I do re-install it all the serial numbers are in place and it says I have 36,XXX days left in my trail.
    I don’t know what else you would want, but this is all I can give you because that’s what happens.  I’m currently taking online classes and we are all required to have this exact same suite and I know at least 2 other students who have mentioned this requiring problem.  One was so tired of it the purchased a different program to do it’s job.

Maybe you are looking for