How to create unique hashcode?

Hi:
Object's hashCode() method can not provide unique hashcode, which I expected. If I want to use the hashCode as unique sessionID, what should I do?

Well, a Hashcode is per definition not unique (because limited to a length e.g. 128 Bit). If the Object.getHashcode() performs so poor for your application (becuse it was not designed for session ID's, more for sorting/storage), why not using some of the cryptographic Hashfunctions from the java.security package like java.security.MessageDigest
String login = loginname + password + egDate_to_String + whatever_eg_a_random_number;
byte[] bt = String.getBytes(login);
MessageDigest MD = java.security.MessageDigest.getInstance("SHA");
// MD2 or MD5 are also possible
MD.update(bt,0,bt.length);
String sesionID = MD.toString();This is untested, but should work.
Or you will try to do something with BigInteger whose Constructor accepts also a Random (generated with your own seed) and give also a high prime certainity ...

Similar Messages

  • How to create unique index on a View

    Hi All,
    11.2.0.1
    How do I create an index on a view or any workaround that my view wont get duplicates?
    SQL> create unique index indx01 on db_backup_details_vw(id);
    create unique index indx01 on db_backup_details_vw(id)
    ERROR at line 1:
    ORA-01702: a view is not appropriate here
    Thanks a lot,
    Kinz

    I'm thinking of using a distinct clause here.
    if i get 5 duplicate rows in my selection set because of the join condition, can't i discard the remaining 4 using a distinct clause.
    Observe this
    SQL> select * from a;
    T1 T2
    1 4
    2 4
    3 4
    SQL> select * from b;
    T1 T2
    1 4
    2 5
    in both a,b t1 is the primary key. so we'll write a join on t2 (non PK).
    SQL> select b.t1,b.t2 from a,b where a.t2=b.t2;
    T1 T2
    1 4
    1 4 -- duplicates
    1 4
    Now create view with distinct clause
    create view ab as select distinct b.t1,b.t2 from a,b where a.t2=b.t2;
    SQL> select * from ab;
    T1 T2
    ---------- ---------- -- no duplicates
    1 4
    CSM

  • How to create Unique Identifier and save it to identify user(device)

    I want to create unique identifier on iOS 5 and use it for identifying user (user device) every time app is started. I am able to create a unique identifier by following code 
    CFUUIDRef theUUID = CFUUIDCreate(NULL);
    CFStringRef string = CFUUIDCreateString(NULL, theUUID); CFRelease(theUUID);
    But unable to save it on user device so that particular identifier is not deleted even when app is uninstalled. I tried using SSKeychain approach but it gives Apple Mach-o Linker error.
    Please let me know the the way I can accomplish the same.
    Any help is appreciated.

    I want to create unique identifier on iOS 5 and use it for identifying user (user device) every time app is started. I am able to create a unique identifier by following code 
    CFUUIDRef theUUID = CFUUIDCreate(NULL);
    CFStringRef string = CFUUIDCreateString(NULL, theUUID); CFRelease(theUUID);
    But unable to save it on user device so that particular identifier is not deleted even when app is uninstalled. I tried using SSKeychain approach but it gives Apple Mach-o Linker error.
    Please let me know the the way I can accomplish the same.
    Any help is appreciated.

  • How to create unique constraint in ODI

    Hi
    I have view at source side, I want to store source data to target interface table.
    For that I need to create UNIQUE constraint at source side to identify the unique records.
    I have composite primary key example as follow
    desc Test_V;
    orderID NUMBER,
    itemNumber NUMBER,
    productId NUMBER,
    quantity NUMBER,
    lot_number varchar2(80)
    where
    PRIMARY KEY (orderID, itemNumber,lot_number);
    Some times, lot_number can be null, So, I can't use lot_number in composite key (as per requirement)
    Please any body can help me on it
    Thanks
    Phani

    Hi
    Hope this may help
    http://mhimu.wordpress.com/2009/05/04/odi-incremental-update-and-surrogate-key-using-database-sequence/
    but some cases it is not working
    Thanks
    Phani

  • How to create unique objects in class and store

    Hi, I have a class that opens a text file and reads in the
    lines. each line holds an ip address. i need to create x amount of
    objects, and each object is assigned a unique ip address from the file.
    and here i am stuck. the class reads in the file, then i think it should create an object for each line read in and assign that object the ip address. i want to store the objects in some sort of array or collection, and i guess each object will need a unique name, but i dont know how many objects until i read in the file and count the number of lines. can anyone give me any pointers as to how i should create/store the objects
    many thanx
    ness

    You could use your own object:
    public class Test {
      public class IPNumber {
        public int ip;
        public IPNumber(int ip) {
          this.ip = ip;
      public Test() {
        int numberOfIPs = 5; // this is your number of lines
        IPNumber[] ips = new IPNumber[numberOfIPs];
        for (int i = 0; i < numberOfIPs; i++) ips[i] = new IPNumber(i); // assign ip address from file
      public static void main(String args[]){
        new Test();
    }or you could store the ips as strings:
    public class Test {
      public Test() {
        final int numberOfIPs = 5; // this is your number of lines
        final java.util.ArrayList al = new java.util.ArrayList(numberOfIPs);
        for (int i = 0; i < numberOfIPs; i++) al.add(""+i); // assign ip address from file   
      public static void main(String args[]){
        new Test();
    }p.s Objects don't have names

  • How to create unique constraint on a col which has duplicate values

    Hi all,
    how can i create a unique constraint on a field which have duplicate vaules with no validate clause.
    My table name is "ACCT"
    Regards
    Message was edited by:
    53637

    Check out following
    SQL>DROP TABLE TEST;
    Table dropped.
    SQL>CREATE TABLE TEST
      2  (
      3     ID          NUMBER
      4    ,NAME        VARCHAR2(30)
      5    ,CITY        VARCHAR2(30)
      6  );
    Table created.
    SQL>INSERT INTO TEST VALUES(1,'Rajesh','Gurgaon');
    1 row created.
    SQL>INSERT INTO TEST VALUES(1,'Rajesh','Gurgaon');
    1 row created.
    SQL>INSERT INTO TEST VALUES(2,'Dinesh','Delhi');
    1 row created.
    SQL>INSERT INTO TEST VALUES(1,'Rajan','Pune');
    1 row created.
    SQL>INSERT INTO TEST VALUES(1,'Rajan','Pune');
    1 row created.
    SQL>COMMIT;
    Commit complete.
    SQL>ALTER TABLE test ADD CONSTRAINTS uk_on_test UNIQUE(ID,NAME,CITY) DEFERRABLE NOVALIDATE ;
    Table altered.
    SQL>ALTER TABLE test
      2  ENABLE NOVALIDATE CONSTRAINT uk_on_test;
    Table altered.
    SQL>INSERT INTO TEST VALUES(1,'Rajesh','Gurgaon');
    INSERT INTO TEST VALUES(1,'Rajesh','Gurgaon')
    ERROR at line 1:
    ORA-00001: unique constraint (AIP.UK_ON_TEST) violatedRegards
    Arun

  • How to create unique sequence number

    Hello,
    I'm new to ODI and trying to learn. Below is the requirement. Please advise.
    I'm trying to load data from one database (oracle) to another database table (AS400). But when i load the data into AS400, I need to create a unique ID for each record and write this unique ID to one of the fields in AS400.
    I don't have any issues loading the data from oracle to AS400. But I'm unable to generate a unique ID for each record. Can any share your thoughts how to get this.
    Thanks for your help.

    Hi ,
    First, on the DB2/400 instance, create a table containing an Identity column:
    CREATE TABLE THE_IDENTITY_TAB
    (THE_IDENTITY_COL DECIMAL(31,0) GENERATED ALWAYS AS IDENTITY
    START WITH 1000,
    INCREMENT BY 1);
    Second, in the same DB2/400 instance, create a function that returns an incremented number from the Identity column:
    CREATE FUNCTION NEXT_IDENTITY_COL () RETURNS DECIMAL(31,0)
    LANGUAGE SQL
    MODIFIES SQL DATA
    BEGIN
    INSERT INTO THE_IDENTITY_TAB VALUES (DEFAULT);
    DELETE FROM THE_IDENTITY_TAB;
    RETURN (SELECT identity_val_local() FROM QSYS2.QSQPTABL);
    END
    Finally, in Designer, use the snpRef.getObjectName() substitution method to refer to the DB2/400 function in the interface's mapping for the appropriate field:
    <%=snpRef.getObjectName("L","NEXT_IDENTITY_COL","<LOGICAL_SCHEMA_NAME>","D")%>()
    Thanks,
    Sutirtha

  • How to create Unique constraint

    Hi,
    How can I create a unique constraint on a column in a table which has already been created.
    Thanks

    ALTER TABLE your_table ADD CONSTRAINT yrt_uk UNIQUE (some_col)
    /You may find it illuminating to read the online documentation.
    Cheers, APC

  • How to create Unique Number.

    I need to create a Unique Request Number for System.
    how Can i create this in Oracle.
    Regards,
    Agrawal's

    I have One table Says PRINT_MGMT_LOG & in this table there are more than 10 columns, so can i create SEQUENCE in this table or should i make a new table having one column to store these running number.
    Which one will be better considering performance issues.

  • How to create unique notification sounds for email on Droid Incredible 4G LTE

    I have three separate email accounts pushed to my Droid Incredible 4G LTE.  I can't for the life of me figure out how to set up unique notification sounds for each email account.  It was a snap to do on my old Blackberry.
    Same question for flagging individuals within my contact list.  (E.g., if my wife calls it makes one sound, if a client calls it makes a different sound.)
    Does anyone know how to do this, or, as they say, is there an app for that???
    Thanks in advance!

    I don't think you can on the email but got to each contact and edit them for different sounds, I'm not sure if it works on that new phone that way but as they don't have a dedicated room yet for it you had nowhere else to ask htc has good forums also

  • How to create unique key column in ROLAP fact table?

    Hi all,
    Is there a way to create a single column primary key (or unique index) on my ROLAP cube (and fact tables) in OWB? if so, what I should do in my mappings?
    Thanks!
    - Andrew

    Have you all conformed dimensions between the two facts?

  • How to create unique shapes in Illustrator CS4

    First off....
    I am new to the Adobe suite of applications and also new to owning a Macbook Pro. I have been using a design program for Windows for many years.
    I would like to master the creation and manipulation of shapes using Illustrator CS4.
    As one example, how would I create the following:
    I want to end up with a shape that is similar to one-quarter of a full moon.
    Using my Windows program (not an Adobe product), I would create a line using a line tool, and then I would be able to convert that line to a curve using a shape tool, which would enable me to drag from the midpoint of the line and have it become an arc. Then, while still using the shape tool, I could click once to select one of the endpoint nodes to then click on an "auto-close" option which would add a straight-line edge to close the shape for outline and fill purposes (so one side of the shape is straight at this point and the other side is curved). Using the shape tool, I would double-click near the midpoint of the straight edge to add a new node to the shape, and then I would use the "convert to curve" option from within the shape tool to be able to drag this straight side towards the curved side to end up with the quarter-moon shape as desired.
    How would I make this sort of shape using Illustrator, and as a general question for learning, how can I learn all about how to put lines in the design space for purposes of joining these lines, curving any part of one or more lines and then filling or outlining the finished shape made from joined lines?

    > and as a general question for learning, how can I learn all about how to put lines in the design space for purposes of joining these lines, curving any part of one or more lines and then filling or outlining the finished shape made from joined lines?
    Well, you can read the documentation. That will be much more thorough and methodical than asking a random series of "how do I..." questions in a user forum. And it will take you
    a lot less time.
    > Using my Windows program (not an Adobe product)
    You can say the name. If there's actually anyone here who doesn't know other drawing programs exist, well, they
    need to. Your description sounds like Xara Xtreme.
    > I want to end up with a shape that is similar to one-quarter of a full moon..create a line...convert that line to a curve...drag from the midpoint of the line and have it become an arc...select one of the endpoint nodes... "auto-close"...double-click near the midpoint of the straight edge to add a new node..."convert to curve"...drag...
    A similar procedure could be used in just about any vector drawing program that draws cubic Bezier curves. A much quicker procedure could also be used in just about any program, by leveraging the geometric shape tools and path combination commands that are just as ubiquitous:
    1. Draw a circle.
    2. Duplicate the circle.
    3. Overlap the circles partially.
    4. Use one circle to "punch" the other, leaving the difference (the crescent shape).
    Here are two AI-specific differences I note in your description:
    Illustrator can't bend a straght segment by dragging its middle if the straight segment has both its associated curve handles retracted. Dragging such a segment in AI just moves the segment (and its associated anchorPoints).
    Illustrator displays fills on open paths. There is no option to turn off that often unwanted behavior.
    Again, read the manual (the online Help files). It will take you decades to learn the program by asking random questions on the basic use of the tools, location of commands, organization (well, disorganization) scheme of the program, etc., etc.
    JET

  • How to create unique object for dynamically created jTextFields

    Hello to all forum members
    According to my requirement , i have created a number of jpanels(containing textfield,comboboxes etc) and added them to a jScrollPane.
    But my requirement is after adding the jPanels to the JScrollPanel, i want to add some logic to that jpanels; like
    1) i want to sort the panels according to some condition when a sort button is clicked
    2)and the text field which are in the panel should be sorted according to the integer value inside the text field.
    3) and after a buton clicked the value what are in the jText field should store in the data base etc.....
    For the above logic to apply i need the instance variable(i.e object reference ) should be difference, so that when i want to get a value from any component ( text from jtextfield ) i can get the value through its instance variable name.for example
    JTextField textField1=new JTextField("aaa");
    JTextField textField2=new JTextField("cccc");
    JTextField textField3=new JTextField("eee");then
    textField1.getText();
    textField2.getText();
    textField3.getText();But the problem is when i am creating the number of panels the name of the instance variables (of all the components i.e textfield ,panels)are same so i can't add the logic to any particular component.
    I have tried to solve this problem , but not getting any idea .Please help me to find out the solution. I hope i explained my problem clearly if not
    tell me i will explain it again.
    I have given here with the code in which i have created 100 jpanels , each jpanels consisting of 1label and 1text field but the instance variable for each component is same.
    Plese help me to solve this problem,Thanks in advance.
    import javax.swing.*;
    public class NestedPanels extends JFrame
      private static final int NO_OF_NESTED_PANELS = 100;
      public NestedPanels()
        super("Nested Panels");
        setSize(200, 200);
        JPanel mainPanel = new JPanel();
        mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
         for ( int i=1; i<=NO_OF_NESTED_PANELS; i++)
             mainPanel.add(createChildPanel(i));
         javax.swing.JScrollPane jScrollPane = new javax.swing.JScrollPane();
         jScrollPane.setViewportView(mainPanel);
        getContentPane().add(jScrollPane);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setVisible(true);
      private JPanel createChildPanel(int intChildPanelNumber)
        JPanel childPanel = new JPanel();
        childPanel.setLayout(new BoxLayout(childPanel, BoxLayout.X_AXIS));
        childPanel.add(new JLabel("" + intChildPanelNumber));
        childPanel.add(new JTextField());
        return childPanel;
      public static void main(String[] argv)
        javax.swing.SwingUtilities.invokeLater(new Runnable()
          public void run()
            NestedPanels example = new NestedPanels();
    }Thanks & Regards
    Mahendra

    Hi to all forum members,
    Thanks for all your help.
    JayDS, as you have told i have tried with
    return Integer.valueOf( getText() ).compareTo( Integer.valueOf( mp.getText() ) );but it is giving
    java.lang .NumberFormatException.forInputString(unknown source)
    sorry i could not get what is SSCE?
    I am sending the code here with my requirement.
    My requirement is to sort the panels.
    i.e.
    when I will click on to the sortC1 button , the whole panels should be sorted according to the integer value inside the textfield1 (but here in my code it is sorting string wise,if u enter 1,2 ,1111111,3 ,222 the output should be 1,2,3, ,222 ,1111111 but it is actually giving the output as 1, 1111111,2,222,3 which is wrong )
    Arrays.sort(NestedPanelSorting); => this method is used for sorting
    return getText().compareTo(mp.getText());=> method is used for the text comparision in the example ( NestedPanelSorting.java)
    sortC2 also same.
    When I will click sortC3 ,the panel will be sorted according to the string values in the dropdown of combo boxes. Here how to access the instance of combobox to sort or the panel or through array of objects how can i sort?
    import java.awt.BorderLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.util.Arrays;
    import javax.swing.*;
    public class NestedPanelSorting extends JFrame
        private static final int NO_OF_NESTED_PANELS = 10;
        private MyPanel[] NestedPanelSorting = new MyPanel[NO_OF_NESTED_PANELS];
        //MyPanel[] is a array of MyPanel objects declared below
         private JPanel mainPanel;
        private JScrollPane jScrollPane;
         public NestedPanelSorting()
            super("Nested Panels Sorting");
            setSize(400, 200);
            mainPanel = new JPanel();
            mainPanel.setLayout(new BoxLayout(mainPanel,BoxLayout.Y_AXIS));
            //in the for loop below MyPanel(i) is called through NestedPanelSorting[i]
              for (int i = 0; i < NestedPanelSorting.length; i++)
                NestedPanelSorting[i] = new MyPanel(i);
                mainPanel.add(NestedPanelSorting);
    jScrollPane = new javax.swing.JScrollPane();
    jScrollPane.setViewportView(mainPanel);
    getContentPane().add(jScrollPane, BorderLayout.CENTER);
    JButton myBtn1 = new JButton("sortC1");
              JButton myBtn2 = new JButton("sortC2");
              JButton myBtn3 = new JButton("sortC3");
    getContentPane().add(myBtn1, BorderLayout.EAST);
    getContentPane().add(myBtn2, BorderLayout.WEST);
    getContentPane().add(myBtn3, BorderLayout.SOUTH);
              myBtn1.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent arg0)
    myButtonAction(arg0);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setVisible(true);
    private void myButtonAction(ActionEvent arg0)
              //this Array.sort() method is for sorting the array -
              // accordig to string value but i need to sort integer value wise
    Arrays.sort(NestedPanelSorting);
              mainPanel = new JPanel();
    mainPanel.setLayout(new BoxLayout(mainPanel,
    BoxLayout.Y_AXIS));
    for (int i = 0; i < NestedPanelSorting.length; i++)
    mainPanel.add(NestedPanelSorting[i]);
    jScrollPane.setViewportView(mainPanel);
         public static void main(String[] argv)
    javax.swing.SwingUtilities.invokeLater(new Runnable()
    public void run()
    new NestedPanelSorting();
    //declaring of MyPanel class where textfield1,txtField2,comboBox1 are added
         class MyPanel extends JPanel implements Comparable<MyPanel>
    private int number;
    private JTextField txtField1;
              private JTextField txtField2;
    private JComboBox comboBox1;
    public MyPanel(int number)
                   super();
    this.number = number;
    setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
    add(new JLabel(String.valueOf(number)));
    txtField1 = new JTextField();
    add(txtField1);
                   txtField2 = new JTextField();
    add(txtField2);
                   comboBox1=new JComboBox();
                   comboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "ITEM  1 ", "ITEM  2 ", "ITEM  3 ", "ITEM  4 ","ITEM  5 " }));
                   add(comboBox1);
    public int getNumber()
    return number;
              public String getText()
                   if (txtField1.getText() == null)
    return "";
                   return txtField1.getText();
         public int compareTo(MyPanel mp)
              return getText().compareTo(mp.getText());
              //return Integer.valueOf( getText() ).compareTo( Integer.valueOf( mp.getText() ) );

  • How to create unique combined fields in Qual table

    Furhther clarification of my prev question:
    Can I make a unique combined field for a Qualified table. If so how?
    How  the unique field option for combine fields in Main table can be enabled?
    This is for MDM5.5 sp4
    Thanks in advance for the help
    -reo

    Hi,
    Please go through this link,
    http://wiki.sdn.sap.com/wiki/display/ABAP/CreationofView+Cluster
    Hope it helps you,
    Regards,
    Abhijit G. Borkar

  • How can I create unique partnerships to deal with like EDI messages?

    I have an EDI to Application partnership setup currently that deals with translating MEDRUC type EDIFACT messages to a mainframe format. The setup is
    Sender = PARTNERA,
    Receiver = PARTNERB
    DocType = MEDRUC.
    In the Input EDI tab the
    Sender Qualifier ID = ZZ:PARTNERA
    Receiver Qualifier ID = ZZ:PARTNERB
    Standard = EDIFACT
    Version = D
    Release Number = 97B.
    Use UNG to locate partnerships = No
    EDIFACT messages contain all this information in their UNB and UNH segments which is where SunONE IS B2B looks to then match against the relevant partnership. My problem is this does not go to enough granularity for me to distinguish uniqueness for the second partnership I need to create.
    The problem is the "Association assigned code" field in the UNH for EDIFACT messages is not catered for anywhere in the partnership details area. This means then that whilst my existing partnership deals with Simplified Billing Claim MEDRUC's which is Association assigned code = SBC20, I can't create an EDI to Application partnership for PARTNERA and PARTNER B to cater for Two Way Gap Claiming MEDRUC's which are Association assigned code = TWC10, ie the two messages are D97B MEDRUC type messages only distinguished from each other by this Association assigned code.
    Any ideas how can I then create a unique EDI to Application partnership for this TWC10 MEDRUC message?
    What I am thinking I will have to do is make this second partnership Application to Application and create a custom service to wrap the MEDRUC message with a HREC/TREC and use the parameters in the HREC to dictate the DocType rather than use the UNB/UNH segments in the MEDRUC?

    Hmmm. It looks like way back when the decision was made on how specific the keys had to be, they didn't get quite specific enough for your case. I'm not super experienced with EDIFACT but I'll throw out some suggestions based on my HREC and X12 knowledge.
    A. Could you handle both instnaces through the same partnership, but alter the map to create unique outputs based on the two different types? At least of the cards would need to be handled through Route, but you could have that picked up by a simple Outprep / Gateway Service list that put the data where you wanted it.
    B. Before Parse, run a custom service that is capable of inspecting for which type of data it is, then modify one of the key fields in place to find the Second partnership. Really getting adventurous, maybe you could alter keys in the UNG to make the distinction. This assumes that you don't have both types of documents in the same interchange.
    C. Your idea may be workable. Can you give some more detail on the make-up of the Service list and the destination/processing of the two differnt types of MEDRUC?
    Thanks.

Maybe you are looking for

  • Error trying to restore from iCloud

    I'm trying to restore a new iPhone from the Cloud but keep getting the following error message - Could Not Sign In - There was a problem connecting to the server. Wi-fi connection is good and Apple ID and password are all correct. What does this mean

  • SQL Server 2012 Report Server mode is blank?

    Hi, I have configured SharePoint 2013 with SQL Server 2012 on Windows Server 2012 with complete features on the same server. But when I checked Report Server mode under Report Service Configuration Manager it's showing blank means Report Server mode

  • Substring and instring

    Dear all, I am very new to oracle. I am learning oracle now. I have small doubt could any one can help me. I have a string like 'robert alias: 09-047 position now:     CLARK' now i need to store the word '09-047' in to a variable x and clark in to a

  • Attachment to email does not stay attached when email is forwarded - HELP

    I recieved an email that had a pdf attachment and when I forwarded the email, the attachment was no longer there? Is there something I need to do to keep the pdf attachment with the forwarded email - I also have to do this with tiff attachments. Plea

  • Windows XP stops recognizing the iPod Nano

    hi I bought my Nano in Dec 2006. Assuming it is 2nd generation. Not sure how to verify. Until now I was able to copy files from Real Player to my Nano. Now the Nano battery charges when I connect the USB cable to the Windows XP Pro system but Real an