dcsimg
www.webdeveloper.com
Results 1 to 2 of 2

Thread: Solution Help

  1. #1
    Join Date
    Feb 2005
    Location
    Middle Village, NY
    Posts
    203

    Solution Help

    hey guys, im am doing a project for my own intrests, and im having a bit of a problem with coming up with a soltion for how to build this app. im not sure how many class' to have and what those class' should contain, i mean i have an idead of what they should do, but not a great one.

    ok, i am gonna design a small application, not an applet that will connect to my database. now for this, should i make a seperate connection class? also, when the user clicks connect, should i leave the connection to the db open, or should i close it after every operation the user does? ok next, the user will be able to places an order, lets say for instance a cd. artist, album, tracks, etc. should i make a seperate orders class, if so, should i extend it from the Connection class, you know Public class Orders extends Connection{? i have a couple more methods for the the orders like insert, retrieve, remove. i have more questions, but ill ask them later when i get this portion working.

    thanks

  2. #2
    Join Date
    May 2004
    Location
    Perth, WA
    Posts
    171
    Your "Order" class (not the plural "Orders" as you can simply have an array or other collection of Order Objects) is usually considered part of the business tier sometimes called the "model". The datatbase access class or classes that obtain a connection to the database should definately be separate from your model. Some methodologies allow the bean classes such as your order to perform database operation (ie order.update(); and the update method will call <yourDatabaseClass.getConnection(); or something like that to obtain a connection)

    As for keeping database connections open, I think it depends on how busy your database is (i.e. how many users are using the application concurrently?) If its just one or two then I think it would be ok but if there are lots then you will have to find a way to manage the connections.

    These days for larger applications people use libraries that have already been developed to achieve this such as Ibatis, Hibernate, EJB etc. but it may not be worth putting in so much infrastructure for a simple app like yours. I think if you are just starting out with jdbc you should probably just get a new connection each time you need one as you wont notice the performance difference anyway.

    Here is some basic information that will probably be enough to get you through.

    All the best.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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



Recent Articles