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();
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
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.
or, to put some code to mikes suggestion:
you are using an object input stream and reading the objects back in in the exact order you exported them, arent you?
System.out.print("that username is in use, please choose another");
why dont you just use a small, simple, Access database ?
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?
not knowing how to use jdbc shouldnt stop you from using access... how else will you learn?
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.
Do you have some example code I can plough through?
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL