File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes General question about JDBC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "General question about JDBC" Watch "General question about JDBC" New topic
Author

General question about JDBC

jim gemlo
Greenhorn

Joined: Feb 24, 2004
Posts: 20
OK. Not sure if this is the correct form for this question, but here goes. If your trying to stick to a MVC model and are accessing a DB in a bean, how do you return the result set? do you pass a arrayList as a return value of the function that you called in the bean? If so how does this affect performance? Or do you use some other method? Thanks
Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
I would say that it really depends on how object-oriented you want your application to be. At a very basic level, you could return a javax.sql.RowSet. Or you can create actual objects that reflect the data being retrieved (Order, MailItem, etc).
MVC doesn't really say in what format you should pass data from the controller to the model, and from the model to the view--it just says that you should separate these areas with a clear interface so that things go better for you in the long run. So, whether you return your model as a giant array, or wrapped into objects, you will still have what we call a MVC application.
As for performance, things can go a little crazy with database calls, especially remoted, but that really depends on the behavior of your application. I would recommend going through some of the J2EE design patterns and see if any apply to what you are doing. I think they have some that apply to database issues.
I'm going to stop rambling. I hope this helps you some. Feel free to expound on your inquiry for some additional help.


Nathaniel Stodard<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS, ICAD, ICSD, ICED
brad balmer
Ranch Hand

Joined: Mar 08, 2004
Posts: 57
Answers you receive on this really will depend on the individual. A lot of taglibs out there take ResultSet and the like as parameters. You can pass back this kind of object to completely decouple your db from your business logic.
My preference is when I am returning multiple rows from a database, I prefer to return ArrayLists of Beans.
jim gemlo
Greenhorn

Joined: Feb 24, 2004
Posts: 20
so let me see if I have this right. In a bean you query you DB. The results are then put in a arrayList which is then returned to app where you handle the display? Also what are some good sites/books to learn more about MVC. I just started writing JSP pages and discovered that I am not following best practices. I want to learn more about MVC and taglibs but am having a hard time finding good info geared for a beginner.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: General question about JDBC