Searching a vector

Ok, second post. I gave up on the whole array idea and moved to vectors. I got it reading the text file and adding to the vector succesfully. Now I need to search that vector. The text file looks like this:
9876543 9876543 Y
0612207 0612207 N
0123456 0123456 N
1234567 1234567 Y
Here's my code so far:
import java.*;
import java.awt.*;
import java.io.*;
import java.util.*;
import java.awt.event.*;
import javax.swing.*;
public class EmailForms extends JFrame implements ActionListener {
     private JTextField jtfUserName;
     private JPasswordField jpfPassword;
     private JButton jbtLogin;
     private JButton jbtCancel;
     Vector LoginData = new Vector();
     public static void main (String[] args) {     
          EmailForms LoginFrame = new EmailForms();
          LoginFrame.setSize(200, 100);
          Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
          int screenWidth = screenSize.width;
          int screenHeight = screenSize.height;
          Dimension frameSize = LoginFrame.getSize();
          int x = (screenWidth - frameSize.width)/2;
          int y = (screenHeight - frameSize.height)/2;
          LoginFrame.setLocation(x, y);
          LoginFrame.pack();
          LoginFrame.setVisible(true);     
     public EmailForms () {     
          try {     
               String UP1Line;
               FileInputStream fis = new FileInputStream("UP1.txt");
              BufferedReader br = new BufferedReader(new InputStreamReader(fis));
              while ((UP1Line = br.readLine()) != null) {
                    StringTokenizer st = new StringTokenizer(UP1Line, " ");
                    while (st.hasMoreTokens()) {
                      LoginData.addElement(st.nextToken());
                br.close();
                fis.close();
          catch (IOException ex){
               JOptionPane.showMessageDialog(this, "Fatal Systems Error", "Email Forms: File Error 1",
               JOptionPane.INFORMATION_MESSAGE);
               System.exit(0);     
          catch (NullPointerException ex){
               JOptionPane.showMessageDialog(this, "Fatal Systems Error", "Email Forms: File Error 2",
               JOptionPane.INFORMATION_MESSAGE);
               System.exit(0);     
          setTitle("E-Forms: Login");
          JPanel jpLoginLabels = new JPanel();
          jpLoginLabels.setLayout(new GridLayout(2, 1));
          jpLoginLabels.add(new JLabel("Username:"));
          jpLoginLabels.add(new JLabel("Password:"));
          JPanel jpLoginText = new JPanel();
          jpLoginText.setLayout(new GridLayout(2, 1));
          jpLoginText.add(jtfUserName = new JTextField(10));
          jpLoginText.add(jpfPassword = new JPasswordField(10));
          JPanel p1 = new JPanel();
          p1.setLayout(new BorderLayout());     
          p1.add(jpLoginLabels, BorderLayout.WEST);
          p1.add(jpLoginText, BorderLayout.CENTER);
          JPanel p2 = new JPanel();
          p2.setLayout(new FlowLayout(FlowLayout.CENTER));     
          p2.add(jbtLogin = new JButton("Login"));
          p2.add(jbtCancel = new JButton("Cancel"));     
          getContentPane().setLayout(new BorderLayout());
          getContentPane().add(p1, BorderLayout.CENTER);
          getContentPane().add(p2, BorderLayout.SOUTH);
          jbtLogin.addActionListener(this);
          jbtCancel.addActionListener(this);
     public void actionPerformed(ActionEvent e) {
          String arg = e.getActionCommand();
          int index = find(jtfUserName.getText().trim(), new String(jpfPassword.getPassword()));
          if (arg == "Cancel") {
               System.exit(0);
               arg = "";
          if (arg == "Login") {
               if (index == -1) {
                    JOptionPane.showMessageDialog(this, "Username/Password Not Found", "Email Forms: Login Error",
                    JOptionPane.INFORMATION_MESSAGE);
               else {
                    if (index == 1 ){
                         JOptionPane.showMessageDialog(this, "Username and Password Found: Admin", "Email Forms: Good",
                         JOptionPane.INFORMATION_MESSAGE);
                    else {
                         JOptionPane.showMessageDialog(this, "Username and Password Found: User", "Email Forms: Good",
                         JOptionPane.INFORMATION_MESSAGE);          
          arg = "";
     public int find(String UName, String PWord) {
          for (int i = 0; i < LoginData.size(); i++) {                                        
               // if ((first.element.of.first.line.UName  == LoginData.elementAt(i)) && (second.element.of.first.line.PWord == LoginData(i))) {
               //          if (third.element.of.first.line.yes or no admin == "Y") {
               //               goto adminside;
               //               return 1; }
               //          else {
               //               goto userside;
               //               return 2;
          return -1;
}Essentially this is a login method. The standard username and password. The kicker is the third entry in each line of the vector "Y" or "No". This entry denotes whether or not the user is an admin. If he/she is an admin, they go to an admin program else he/she is a regular user and goes to the user program. I've done some reading on searching vectors in this forum as well as others, but none have I have read have tackled this third entry. Can someone have a look and give me their opinion.
Thanks in advance,
Colin

Here you go:
1. Use a HashMap to look up credentials.
2. Use regular expressions to check for certain values
The code does what you need (just checked it), but you probably wouldn't save the credentials as a "String[]" array. So there's room for improvement ;)
import java.awt.*;
import java.io.*;
import java.util.*;
import java.awt.event.*;
import javax.swing.*;
public class EmailForms extends JFrame implements ActionListener {
     private static final long serialVersionUID = -6409081110711705001L;
     private JTextField jtfUserName;
     private JPasswordField jpfPassword;
     private JButton jbtLogin;
     private JButton jbtCancel;
     private HashMap<String, String[]> users;
     public static void main (String[] args) {     
          EmailForms LoginFrame = new EmailForms();
          LoginFrame.setSize(200, 100);
          Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
          int screenWidth = screenSize.width;
          int screenHeight = screenSize.height;
          Dimension frameSize = LoginFrame.getSize();
          int x = (screenWidth - frameSize.width)/2;
          int y = (screenHeight - frameSize.height)/2;
          LoginFrame.setLocation(x, y);
          LoginFrame.pack();
          LoginFrame.setVisible(true);     
     public EmailForms () {     
          users = new HashMap<String, String[]>();
          try {     
               String UP1Line;
               FileInputStream fis = new FileInputStream("UP1.txt");
              BufferedReader br = new BufferedReader(new InputStreamReader(fis));
              while ((UP1Line = br.readLine()) != null) {
                   String [] items = UP1Line.split(" ", 4);     //max. 6 tokens, separated by semicolon
                   users.put(items[0], new String[] { items[1], items[2] });
                   if (items[2].matches("[Yy]"))
                        System.err.println("y");
                   else
                        System.err.println("n");
                br.close();
                fis.close();
          catch (IOException ex){
               JOptionPane.showMessageDialog(this, "Fatal Systems Error", "Email Forms: File Error 1",
               JOptionPane.INFORMATION_MESSAGE);
               System.exit(0);     
          catch (NullPointerException ex){
               JOptionPane.showMessageDialog(this, "Fatal Systems Error", "Email Forms: File Error 2",
               JOptionPane.INFORMATION_MESSAGE);
               System.exit(0);     
          setTitle("E-Forms: Login");
          JPanel jpLoginLabels = new JPanel();
          jpLoginLabels.setLayout(new GridLayout(2, 1));
          jpLoginLabels.add(new JLabel("Username:"));
          jpLoginLabels.add(new JLabel("Password:"));
          JPanel jpLoginText = new JPanel();
          jpLoginText.setLayout(new GridLayout(2, 1));
          jpLoginText.add(jtfUserName = new JTextField(10));
          jpLoginText.add(jpfPassword = new JPasswordField(10));
          JPanel p1 = new JPanel();
          p1.setLayout(new BorderLayout());     
          p1.add(jpLoginLabels, BorderLayout.WEST);
          p1.add(jpLoginText, BorderLayout.CENTER);
          JPanel p2 = new JPanel();
          p2.setLayout(new FlowLayout(FlowLayout.CENTER));     
          p2.add(jbtLogin = new JButton("Login"));
          p2.add(jbtCancel = new JButton("Cancel"));     
          getContentPane().setLayout(new BorderLayout());
          getContentPane().add(p1, BorderLayout.CENTER);
          getContentPane().add(p2, BorderLayout.SOUTH);
          jbtLogin.addActionListener(this);
          jbtCancel.addActionListener(this);
     public void actionPerformed(ActionEvent e) {
          String arg = e.getActionCommand();
          int index = find(jtfUserName.getText().trim(), new String(jpfPassword.getPassword()));
          if (arg == "Cancel") {
               System.exit(0);
               arg = "";
          if (arg == "Login") {
               if (index == -1) {
                    JOptionPane.showMessageDialog(this, "Username/Password Not Found", "Email Forms: Login Error",
                    JOptionPane.INFORMATION_MESSAGE);
               else {
                    if (index == 1 ){
                         JOptionPane.showMessageDialog(this, "Username and Password Found: Admin", "Email Forms: Good",
                         JOptionPane.INFORMATION_MESSAGE);
                    else {
                         JOptionPane.showMessageDialog(this, "Username and Password Found: User", "Email Forms: Good",
                         JOptionPane.INFORMATION_MESSAGE);          
          arg = "";
     public int find(String UName, String PWord) {
          String [] creds = users.get(UName);
          if (creds!=null && creds[0].matches(PWord)) {
               System.out.println("ok");
               if (creds[1].matches("[Yy]"))
                    return 1;
               else
                    return 0;
          System.err.println("not ok");
          return -1;
}

Similar Messages

  • Searching a Vector of objects

    I'm embarassed to ask this question but I haven't figured out the answer myself yet so I need help.
    I need to be able to search a Vector (it could be an Array just as easily) by only certain parts of the objects in the vector. So for example I have vector v that contains 10 objects o. Objects o are a very small custom class that each have a name and a number. How do I search the vector for the object o that contains name x?
    I tried overriding the equals method of object o and using the IndexOf method of vector v but that did not work.

    I'm embarassed to ask this question but I haven't
    figured out the answer myself yet so I need help.
    I need to be able to search a Vector (it could be an
    Array just as easily) by only certain parts of the
    objects in the vector. So for example I have vector
    v that contains 10 objects o. Objects o are a very
    small custom class that each have a name and a
    number. How do I search the vector for the object o
    that contains name x?Iterate over the Vector and ask each element whether its name is x.
    I tried overriding the equals method of object o and
    using the IndexOf method of vector v but that did not
    work.What does "did not work" mean?

  • Search inside vector?

    help please.
    public class items
      String a;
      int b;
      Vector storageVector = new Vector();
    public void wootwoot();
      items weee = new items();
      a=wootest;
      b=100;
      storageVector.add(weee);
    public void search();
      //How could i search the content of 'string a' inside vector v?
      //In array, i could simply search for array[0].a but it's not compatible with vector.
    }

    _helloWorld_ wrote:
    Loop over the Vector and use elementAt(). Then check the contents using the equals() method.Or just override the equals(Object) method in the items class(and preferably the hashCode() as well) and use Vector's get(Object) to get an item from your Vector.

  • Searching a Vector of SimpleDateFormat objects

    Hi everyone,
    I have implemented a vector of vector structure. Each vector contains a list of objects which have been parserd from a log file. I need to write a method which searches one of the inner vectors containing SimpleDateFormat Objects. Two Dates will be entered by the user and the positons of the date objects found within these two dates needs to be returned. If anyone could help that would be great.
    Jonny

    Hi everyone,
    I have implemented a vector of vector structure. Each
    vector contains a list of objects which have been
    parserd from a log file. I need to write a method
    which searches one of the inner vectors containing
    SimpleDateFormat Objects. Two Dates will be entered
    by the user and the positons of the date objects found
    within these two dates needs to be returned. If
    anyone could help that would be great.
    JonnyWhat? Is it me, or is this a little confused?
    Do the inner vectors really contain instances of java.text.SimpleDateFormat?
    Could you re-state the problem with an example?

  • Search a Vector

    How do I search the objects inside a Vector?

    Have you tried Collections.binarySearch( List list,
    Object key, Comparator c )?That will work but only if the Vector is sorted.

  • In Search of Vector Drawing Tablet Advice

    Hello All,
    I have been using CS4 for a while now (mostly in my spare time) and have gotten quite into drawing cartoon versions of friends, family, etc. I have just worked from photographs in the past and have generally used Illustrator to accomplish this.
    My results so far look something like this: http://crockstarlimited.com/blog/about/ (sorry those are the only examples I have online at the moment). I have been wondering about ways to improve my technique for this and thus my question is two-fold:
    1. Has anyone used a drawing tablet (like this one: http://www.amazon.com/Wacom-UPTZ431W-Intuos-3-Digital-Writing/dp/B001NANLOI)? If so, do you have any recommendations about what to look for or which ones are particularly good?
    2. Does anyone have any tips for this style of drawing?
    i.e. Use Photoshop instead of Illustrator?
    Thanks very much for any help you can provide!
    Crock

    Illustrator by far. You have far more control over your drawing in a vector program. Edits are easier. You can always bring into PS later to add effects. All the digital illustrators I've ever contracted with have worked in AI without exception. The master file is always vector though they may bring an image into PS for some added effects. But the top of the line illustrators can do incredible effects in AI without ever going into PS.

  • How do you search for a partial match in a vector table?

    Hi,
    I have a program that parses some table of mine into a vector table. It has a search function in the program that is intended to search the vector table for a specified keyword that the user enters. If a match is found, it returns true. If no match is found, false is returned.
    That part works great. However, I would like my program to search the vector table to try and find a PARTIAL match of the users entry, instead of looking for a complete match.
    Currently my program uses the Vector method 'contains(Object elem)' to find the complete matches and that part works great. It doesn't seem to work with partial matches. Either the exact syntax of the user's entry is in the table or it isn't.
    Hope I was clear enough. Any thoughts?
    Cheers,
    the sherlock

    You might find this code of interest. It uses the same commands as mentioned previously, but wraps them into a Comparator object. Note that you can't store elements with '*' in the Vector 'v' and that you must sort the elements with Collections.sort() beforehand.
    import java.util.*;
    class WildcardComparator implements Comparator
        public int compare(Object o1, Object o2)
         String string1 = (String)o1;
         String string2 = (String)o2;
         if(string2.indexOf("*") != -1) {
             // take off asterik
             return wildcardCompare(string1,
                           string2.substring(0, string2.length()-1));
         return string1.compareTo(string2);
        public int wildcardCompare(String s1, String key_s) {
         String s1substring = s1.substring(0, key_s.length());
         return s1substring.compareTo(key_s);
    public class wildcard
        public static void main(String[] args)
         Vector v = new Vector();
         v.add("coke");
         v.add("pepsi");
         v.add("7-up");
         v.add("a&w root beer");
         v.add("a&w cream");
         Collections.sort(v, new WildcardComparator());
         String key = "a&w*";
         int index = Collections.binarySearch(v,
                                  key,
                                  new WildcardComparator());
         if(index > 0)
             System.out.println("elem: " + v.get(index));
         else
             System.out.println("item not found");
         key = "c*";
         index = Collections.binarySearch(v,
                                  key,
                                  new WildcardComparator());
         if(index > 0)
             System.out.println("elem: " + v.get(index));
         else
             System.out.println("item not found");
    }

  • Searching Vectors

    If I add several of these objects:
         //A customer
         public PGVideoCust(String first, String last, String address, String address2, String phone, String custID)
              firstName = first;
              lastName = last;
              streetAddress = address;
              cityStateZip = address2;
              phoneNumber = phone;
              ID = custID;
              videosOut.addElement("None");
         } //end customer
    to a vector.. How can i go about searching the vector for ID not just searching for an object in the vector. I tried (vector is customers) customers.indexOf(12432) where 12432 is a valid ID of one of the objects in the vector but it returns -1 everytime.. Understand what I'm trying to do?

    I understand. You need to look at each entry, cast as the object you expect it to be, then test the ID...
    Vector stuff = new Vector(0);
    for(int a = 0; a < stuff.size(); a++){
      // Will throw classCastException if not the right type.
      myObject X = (myObject)stuff.get(a);
      if(X.ID == mySearch){
        // You found it.
    }In similar cases where I know that I'll be storing things based on some known criteria, like an ID, I prefer to use a Hashtable instead. The hashtable stores the goods and all you have to do is ask for the ID like this....
    Hashtable HT = new Hashtable();
    // Store your goodies...
    HT.put(
      myCustomer.ID, // must be an Object so Integer not int
      myCustomer);
    // get the goodies...
    myCustomer = HT.get(theID // Again.  Integer);

  • Vector searching .. ohh my.

    This is really not working I'm trying to search a vector which contains 30 elements of 'all strings'.
    I'm looking for the following string within a vector.
    <Color=5>Except that I don't know what the Color is equal to so I can't use (which would in fact work):
    System.out.println ("Found at: " + dataFile.indexOf("<Color=5>")); and ...
    System.out.println ("Found at: " + dataFile.indexOf("<Color"));does not work.. it returns '-1'
    Any ideas on how I'm to return the line where "<Color=" is located?

    Another alternative, which is simpler, if efficiency isn't a major issue:
    Create a custom Comparator that will match strings the way you want.
    Then, call vector.toArray, sort the list and perform a binary search using your new comparator, using the methods Arrays.sort and Arrays.binarySearch.
    Saves you from implementing the iteration and search logic, although there is a much higher overhead.
    You could also try various tricks on the comparator to make the sorting and searching faster. For example,
    Write a custom Comparator where by you classify Strings into two sets: Those that match the string you're looking for, and those that don't. Those that don't are larger than those that do, and all strings in the same group are "equal".
    If you sort using this "ordering," then, if there was a string matching your criteria, it would now be in the fist position of your list. And, as a guess (since I don't know the EXACT algorithm that Arrays.sort uses), I would expect that a quick sort on a list of elements with only two effective values would be very fast (possibly completing in only two passes through the list, if the pivot is placed in the right position).
    On the other hand, if you're going to have to search for multiple different strings, but the commonality is that all strings that match are matched based on the beginning of the string, you could sort based on the natural ordering of Strings, and then do the binary search with the new comparator.
    Lots of options exist. You just need to find the best one for your purposes. Once again, this method isn't as efficient as searching the list yourself, but it's cleaner, in that, it separates the comparison code (in the Comparator) from the iteration code (in the binary search, or in the sorting). Another alternative with the same effect would be to set up a visitor design, again using a customized comparator. This method, however, requires more effort, as the standard java libraries don't provide a visitor architecture (at least, not that I'm aware of).
    It's a shame that the collections class don't already provide a "contains" method that accepts a customized comparator. That sort of thing could be handy in any number of situations. It's also a shame that there doesn't seem to be visitor construct to go with the collections framework. Oh, well. Maybe someday.
    - Adam

  • Where is the Vector class? Can't use it.

    Hello!
    I've downloaded Flex Builder 3 Trial from Adobe's website.
    Now I want to use the Vector class, but this code for example:
      var v:Vector.<String>;
      v = new Vector.<String>();
    Gives me this error:
    1046: Type was not found or was not a compile-time constant: Vector.
    At the IDE, going to
      Window -> Preferences -> Flex -> Installed Flex SDKs
    I can see that I have Flex 3.2 SDK.
    Even more than that: When I search for "Vector" in the help ("Adobe® Flex™ 3 Language Reference") I can see all the details about Vector.
    What can I do?
    I'd like to avoid installing any newer SDKs due to all the bugs I see listed here in the forums.
    Thank you!

    It looks like you are trying to type Java code in Flex Builder.  Flex applications are generally built using ActionScript.
    These docs might help you learn ActionScript:
    http://www.flexafterdark.com/docs/ActionScript-Language
    http://www.flexafterdark.com/docs/ActionScript-vs-Java
    I hope that helps...
    Ben Edwards

  • Array of vectors

    if I have an array of vectors how would I got about add elements
    to one of the vectors in the array, also how would I search a specific vectors object for equality on another object.
    example: Vector [] lists = new Vector[61];
    how would I add an ID object to on of the vectors.
    also how would a search a vector for equality with a specific ID
    object.
    thanks

    To add an object to (say) the 20th vector use
    ID id = new ID();
    lists.add(id);
    Searching for equality is similar; use the contains method in the vector class.
    I have not tried this, but it should work I think.

  • URGENT: Removing element from a vector?

    ok I have a text database where the lines look something like this:
    5876,Tigger,50.00
    7892,Piglet,25.00
    my problem is I have to remove an element that I don't know the index of, so I figured I have to search the vector for the number(eg, 5876) and return the index so I can remove it, but I don't know how to do this. Please help me

    Try this:
    public class Parser
    public Vector read(InputStream in) throws IOException
       Vector structures = new Vector();
       StringBuffer buffer = new StringBuffer(128);
       int n = -1;
       while((n = in.read()) != -1)
          char c = (char)n;
          if(c == '\n')
             structures.add(getDataStructure(buffer.toString()));
             buffer.delete(0, buffer.length());
          } else
             buffer.append(c);
       if(buffer.length() > 0)
          structures.add(getDataStructure(buffer.toString()));
       return structures;
    protected DataStructure getDataStructure(String string)
       DataStructure structure = new DataStructure();
       StringTokenizer st = new StringTokenizer(string, String.valueOf(','));
       structure.id = (String)st.nextElement();
       structure.name = (String)st.nextElement();
       structure.price = Float.parseFloat((String)st.nextElement());
       return structure;
    public class DataStructure
       String id;
       String name;
       float price;
       public DataStructure() {}
       public boolean equals(Object o)
          if(o instanceof DataStructure)
             return id.equals(((DataStructure)o).id);
          } else if(o instanceof String)
             return id.equals((String)id);
          return false;
    }Now you can keep track of the info in a better way.
    If you have
    5876,Tigger,50.00
    5876,Tigger,50.00
    5876,Tigger,50.00
    5876,Tigger,50.00
    5876,Tigger,50.00
    Stored in a file, you can do this:
    Vector v = new Parser().read(new FileInputStream("..."));
    Structure s = (Structure)v.elementAt(0);
    System.out.println(s.name);
    v.remove("5876");Isn't that nice?
    Note that the code may or may not compile.
    Hope it helps,
    Nille

  • Can't get vector indexOf working

    I have a small little method that is trying to search a vector for a specific string to get its index in the vector. Below is the code for the method...
    public String getMinRoundTrip(){
              String min = "Minimum";
              int minIndex = -1;
              minIndex = received.indexOf(min);
              System.out.println("DEBUG: " + minIndex);
              String outLine = (String) received.get(minIndex);
              int firstIndex = outLine.indexOf("Minimum");
              int secondIndex = outLine.indexOf(", Maximum");
              minRoundTrip = outLine.substring(firstIndex, secondIndex);
              return minRoundTrip;
    I know that "Minimum" exists in the vector, but the index is always coming out with -1, so it is not being found. What am I doing wrong here? Any help would be appreciated.
    Thanks in advance!
    _george                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    No, it is definitely there. I have printed the vector out and could see it in the output. I have also tried searching for other words in the vector and still get -1 returned as the index value.
    This is how I am populating the vector...
    BufferedReader in = new BufferedReader(new InputStreamReader(proc.getInputStream()));
    String line;
    received = new Vector();
    while((line = in.readLine()) != null) {
    System.out.println("DEBUG: " + line);
    received.add(line);
    It seems to populate just fine. I don't get this?
    _george

  • How do i compare each vector value to find  a match with curent value

    My select statement contain more that one value .So I strore it in vector .But currently it does not compare each value .So I dont know wrong .How to search entire vector and find the matching one.
    Below are the coding I used :
    <%String sql_query3 = "SELECT DISTINCT (ir_tran_typ) "+
                                              "  FROM intrcd ";
                               System.out.println("trans type"+sql_query3 );           
                                try{
                                    rset = db.execSQL(sql_query3);
                                catch(SQLException e) {
                                    System.err.println("Error in query - intrcd - transaction_main.jsp " +e +" sql " +sql_query3);
                                while(rset.next()){
                                    tran_cde = rset.getString("ir_tran_typ");
                                            tran_typ.addElement(rset.getString("ir_tran_typ"));
                                            System.out.println("trans type 34 "+tran_typ );%>
                                            <% }%>
                                          alert(obj.value);
                                  <%for(int i=0 ;i<tran_typ.size();i++){
                                     System.out.println("trans type 222  "+ tran_typ.size());
                                       tran_cde =tran_typ.elementAt(index).toString();%>
                                       <%System.out.println("trans type before "+ tran_cde);%> 
                                        eval(document.all.tran_cde.option
                                      if(D == <%=tran_cde%> ){
                                       <%System.out.println("trans type D"+ tran_cde);%>     
                                       <%String sql_query2 = "SELECT ir_rea_cde,ir_rea_desc"+
                                              "  FROM intrcd"+
                                              " WHERE ir_tran_typ = 'D' " +
                                                        " ORDER BY ir_rea_cde ";
                               System.out.println("query"+ sql_query2);           
                                try{
                                    rset = db.execSQL(sql_query2);
                                catch(SQLException e) {
                                    System.err.println("Error in query - emmast2 - transaction_main.jsp " +e +" sql " +sql_query2);
                                        index = 1;
                                while(rset.next()){
                                        rea_cde = rset.getString("ir_rea_cde");
                                        rea_desc =  rset.getString("ir_rea_desc");
                                       tran_typ.removeAllElements();
                                       }%>
                                  if( R == obj.value){
                                       alert(R)
                                      if(R== <%=tran_cde%> ){
                                       <%System.out.println("trans type R"+ tran_cde);%>     
                                       <% sql_query2 = "SELECT ir_rea_cde,ir_rea_desc"+
                                              "  FROM intrcd"+
                                              " WHERE ir_tran_typ = 'R' " +
                                                        " ORDER BY ir_rea_cde ";
                               System.out.println("query 2"+ sql_query2 );           
                                try{
                                    rset = db.execSQL(sql_query2);
                                catch(SQLException e) {
                                    System.err.println("Error in query - intrcd - transaction_main.jsp " +e +" sql " +sql_query2);
                                        index = 1;
                                while(rset.next()){
                                        rea_cde = rset.getString("ir_rea_cde");
                                        rea_desc =  rset.getString("ir_rea_desc");
                                       }%>
              <%}%>
                }

    Dude, your code is a MESS! Learn to use spacing and nicer indentation...
    My select statement contain more that one value .So I strore it in
    vector .But currently it does not compare each value .So I dont know
    wrong .How to search entire vector and find the matching one.What???? Can you please try and explain yourself again? What is it you are trying to do/achieve?

  • Vector.contains (using a custom object)...

    hi!
    This is probably a simple question, but I just dont know the answer...
    I have created a vector that contains objects; those objects contain (1) String and (2) int.
    What i want to do is create a custom .contains function to search the vector for only the string, rather than the string and the number wrapped in the object.
    So.. If I were to write myVector.contains("Java") - I would want to know if the word "Java" existed in the vector
    already, while ignoring the integer value associated with it.
    Any ideas? -- code below
    Vector myVector = new Vector<myObject>();
    myObject{
    String text;
    int num;
    }

    As suggested, use a different data structure. Is the String unique? Then a Map is a perfect fit.
    [http://java.sun.com/docs/books/tutorial/collections/index.html]

Maybe you are looking for

  • Problem with decode function while dispaly the data ( urgent )

    Hi friends , I want the output like this. sample: CLIENT CODE: 00027 PLAN CODE: 01 SSN Last Name First Name TYPE Frequency Amount 123-45-6036 Perrault Julia D M 250.00 123-45-6036 Perrault Julia D Q 400.00 CLIENT CODE: 00027 PLAN CODE: 02 SSN Last Na

  • WPF Treeview Drag and Drop

    Hi All, I faced an when using WPF Treeview Drag and Drop function. Firstly, I can achieve Drag and Drop in a general TreeViewItem. I followed this article in CodeProject: http://www.codeproject.com/Articles/55168/Drag-and-Drop-Feature-in-WPF-TreeView

  • Replacing MacBook Air Screen

    I think I killed my screen. There is now what looks like a 2 inch wide streak going down the screen starting at the top where the WiFi, bluetooth icons are located. Any idea how much it costs to replace a screen?

  • FM to display Selection screen on report output??

    Hi Experts, Is there an FM to display Selection screen on report output. Thanks In Advance.

  • How to view web service definition details using Netweaver ?

    Hi, I have installed Netweaver 7.01 trial version, and I have seen using the Web Service Browser, that all BAPI's are exposed as web services already. I would like to view the web service details for some of these BAPI's, in order to understand the a