File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Java project Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java project" Watch "Java project" New topic
Author

Java project

Preeti Yarla
Ranch Hand

Joined: Sep 08, 2007
Posts: 69
I appreciate some help regarding a personal java project I am doing. (This is actually slightly modified version of Video Store at javaranch cattle drive)

Some intro to that:
I have a small application with one JTable, two buttons and few text fields for data entry. Table displays list of videos from database (MySql). And the buttons, one to add a new video to the video store and one to remove video.

Now I want to expand this application by introducing users to the Video store (this idea - courtesy of Ulf Dittmer). New users should be able to register and old users should be able to login with id/pwd.
And every user should be able to check out selected videos .
So I should create an account for each user.

This is where I am stuck. Where to store user information other than than id/pwd? Like user-borrowed videos etc. How is this usually done in commercial apps? I browsed the web but did not find specific design issues. Can someone please point to a resource that explains such things?

Thanks!


SCJP
Rodrigo Tomita
Ranch Hand

Joined: Apr 28, 2008
Posts: 70
Preeti,

A common way of doing that is using a relational database system (such as Oracle, MS SQL Plus or IBM DB2). MySQL and PostgreSQL are free database systems that you can download and install on your machine. In order to have your application "talking" to those systems, you will need to study SQL and JDBC.

There are frameworks that can be used, so you have the abstration of storing objects inside the database, such as Hybernate.

Well... as you can see that will involve a lot of homework for you

If you want to focus on your Java learning (and will not sell your application), perhaps you can consider simplifying it like having a helper class that receives your objects and is responsible for storing it. A first version can do nothing... a second one stores the values in a text file (or properties file)... and you can enhance as you feel comfortable to do bigger steps.

Hope it helps.
[ June 09, 2008: Message edited by: Rodrigo Tomita ]
Preeti Yarla
Ranch Hand

Joined: Sep 08, 2007
Posts: 69
A common way of doing that is using a relational database system (such as Oracle, MS SQL Plus or IBM DB2). MySQL and PostgreSQL are free database systems that you can download and install on your machine. In order to have your application "talking" to those systems, you will need to study SQL and JDBC.


I am done with that first part.

perhaps you can consider simplifying it like having a helper class that receives your objects and is responsible for storing it. A first version can do nothing... a second one stores the values in a text file (or properties file)... and you can enhance as you feel comfortable to do bigger steps.


I am trying to clarify: does that mean getting the userinfo to an object and then write it to the database? Can you elaborate that in some more steps please?
[ June 09, 2008: Message edited by: Preeti Yarla ]
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42360
    
  64
It sounds like you would need at least 3 tables:

- videos (primary key video_id) - it sounds as if you have that already

- users (primary key user_id, with fields like "login_name", "first_name", "last_name", "password")

- loaned_videos - basically an n:m mapping between video_id and user_id, possibly with additional fields like "date_loaned" and "date_due_back"

Whether you use straight JDBC -or some object wrapper between the application logic and the database- isn't important for getting the application logic right. If this project is a Java learning opportunity, I'd suggest to use just JDBC, and not bother with more advanced ways of accessing databases.

Does that help?
[ June 10, 2008: Message edited by: Ulf Dittmer ]

Ping & DNS - my free Android networking tools app
Rodrigo Tomita
Ranch Hand

Joined: Apr 28, 2008
Posts: 70
Originally posted by Preeti Yarla:

I am trying to clarify: does that mean getting the userinfo to an object and then write it to the database? Can you elaborate that in some more steps please?


Yes... you probably already have a class like User or Person. I think the simplest way would be to do something like getting the user info (each attribute value) from the objects of that class and store it in the database, one attribute per field - as Ulf has mentioned.

You will need methods to store the values to the database and to fetch the data from the database and "re-assemble" the objects.
Preeti Yarla
Ranch Hand

Joined: Sep 08, 2007
Posts: 69
loaned_videos - basically an n:m mapping between video_id and user_id, possibly with additional fields like "date_loaned" and "date_due_back"


This is what I am missing. I will go ahead with this approach first and then try the object wrapper in between as a next step. Thanks Ulf and Rodrigo!
 
 
subject: Java project