Technical Question HELP


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 8 of 8

Thread: Technical Question HELP

  1. #1
    Join Date
    Apr 2004
    Posts
    28

    Technical Question HELP

    I would really appreciate if someone followed this through. Is this feasable or does someone have a better solution?

    From a JFrame displaying text boxes and checkboxes for a user details form, read in 7 String fields and 7 boolean values. One of the string fields is a userID field (not sure how to guarantee uniqueness does anyone know?) I am then using the UserID field as the key and the remainder of the data I am storing in an ArrayList.

    I then combine the two by using a Hashtable ie
    Hashtable hashtablename = new Hashtable();
    hashtablename.put(UserID,ArrayListname);

    The last line stores the ArrayList at the location depicted by the UserID.

    I am then writing this out to an ObjectOutputStream using the "true" switch to append the data. I can then add another users details and repaet the process above.

    My problem is that I cant get the data back from the file in the manner I want it. Before going into the file it seems ok ie 1=[Jones,SM,Clerk,etc] I have not had any success in reading from the file and on top of that how do I iterate through the file to get all the data back out.

    All suggestions welcome Thanks

    GM

  2. #2
    Join Date
    Feb 2004
    Posts
    541
    to ensure the uniqueness of the usernames, when the user clicks the submit button get the username string and check it against all other username strings. If it is the same as any of them then don't submit the details, instead pop up some kind of warning box and ask the user to pick a new username. If it isn't the same then continue with submitting the details.

  3. #3
    Join Date
    Feb 2004
    Posts
    808
    or, to put some code to mikes suggestion:

    Code:
    if(hashtable.containsKey(username))
      System.out.print("that username is in use, please choose another");
      return;
    }
    you are using an object input stream and reading the objects back in in the exact order you exported them, arent you?

    why dont you just use a small, simple, Access database ?
    The 6th edict:
    "A thing of reference thing can hold either a null thing or a thing to any thing whose thing is assignment compatible with the thing of the thing" - ArchAngel, www.dictionary.com et al.
    JAR tutorial GridBag tutorial Inherited Shapes Inheritance? String.split(); FTP?

  4. #4
    Join Date
    Apr 2004
    Posts
    28
    I would use an access databse but I dont know how to use JDBC. Also how easy is it to put this into a hashtable for use elsewhwere in my program?

  5. #5
    Join Date
    Feb 2004
    Posts
    808
    not knowing how to use jdbc shouldnt stop you from using access... how else will you learn?
    The 6th edict:
    "A thing of reference thing can hold either a null thing or a thing to any thing whose thing is assignment compatible with the thing of the thing" - ArchAngel, www.dictionary.com et al.
    JAR tutorial GridBag tutorial Inherited Shapes Inheritance? String.split(); FTP?

  6. #6
    Join Date
    Feb 2004
    Posts
    541
    it really is quite simple to use access, writing code to interface with the database is simple and short. Once you've learned how you can write a class with one method to query the database, one method to update the database and use the constructor to connect to it. SQL isn't all that hard either. If you have an hour you could probably learn anything you need to know for simple cases.

  7. #7
    Join Date
    Apr 2004
    Posts
    28
    Do you have some example code I can plough through?

  8. #8
    Join Date
    Feb 2004
    Posts
    808
    search the forum
    The 6th edict:
    "A thing of reference thing can hold either a null thing or a thing to any thing whose thing is assignment compatible with the thing of the thing" - ArchAngel, www.dictionary.com et al.
    JAR tutorial GridBag tutorial Inherited Shapes Inheritance? String.split(); FTP?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center