aspose file tools*
The moose likes JDBC and the fly likes Need Help With Accessing Multiple Access Database Tables Using JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Need Help With Accessing Multiple Access Database Tables Using JSP" Watch "Need Help With Accessing Multiple Access Database Tables Using JSP" New topic
Author

Need Help With Accessing Multiple Access Database Tables Using JSP

Nishant Vashisth
Greenhorn

Joined: Jun 27, 2011
Posts: 23
Guys i need to feed in data from multiple tables on a jsp page..
please help me !!
i know how to do it using one table by using the use bean property and then using the snipplet but i don't know how to do it using multiple tables !!
Rinkit Shah
Greenhorn

Joined: Aug 16, 2011
Posts: 26
Open database connection once and then try using ResultSet(rs),Statement(stmt)
rs.stmt.executequery("Query");
or rs.stmt.executeUpdate("Query")
and while you want to retrieve from that table use while(rs.next)
and finally close database connection
I hope this works !!!
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61233
    
  66

You should not be doing any database access, or even have any Java code at all, in a modern JSP. Do this type of thing in a Java class where it belongs.

In any case, this is not a JSP questions so it's been moved to the JDBC forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Nishant Vashisth
Greenhorn

Joined: Jun 27, 2011
Posts: 23
if its so then how to use data base in a jsp page ??
it not like we can work around without database !!!

please share any other modern way if you have i'd be obliged to learn it !!
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

The "modern" way -- which has been the professional way for about eight years now -- is to collect and prepare the data in a servlet, or some other similar component, before forwarding the collected data to a JSP to be made into HTML.

Doing it that way allows you to use ordinary Java/JDBC code to access the database, so you don't have to concern yourself about "how to access the database from a JSP".

As for accessing multiple tables, you might want to use an SQL join or something like that. But the question is far too lacking in detail for anybody to provide a useful answer.
Rinkit Shah
Greenhorn

Joined: Aug 16, 2011
Posts: 26
As it is said that it is not a "good practice" to open connection in a jsp page can anyone please help us how to get data into jsp from Servlet.

I am able to save data from jsp to database wih help of data helper class and servlet by help of request.getparameter attribute and setting beans. But I am unable to find a solution of how to display data from servlet to jsp or html file can anyone help in this.
Glisic Slavko
Greenhorn

Joined: May 17, 2008
Posts: 5
Rinkit Shah wrote:As it is said that it is not a "good practice" to open connection in a jsp page can anyone please help us how to get data into jsp from Servlet.

I am able to save data from jsp to database wih help of data helper class and servlet by help of request.getparameter attribute and setting beans. But I am unable to find a solution of how to display data from servlet to jsp or html file can anyone help in this.


Well I'm not sure what is your app architecture, and how do you handle request/response, but just to answer your question(even there are many mvc framework out there that is preferred to use it):


And in request or session object you can store whatever you want.

Regards
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61233
    
  66

Please read this article.
Nishant Vashisth
Greenhorn

Joined: Jun 27, 2011
Posts: 23
guys you are miss understanding me !!

i am not making connections on a jsp page i am well aware of the way !!

i am making a connection on a java class and forwarding the resultset to the jsp page !!

what i wanted to ask was that i can use data of one table easily but using multiple tables is creating problems !!
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30548
    
152

Nishant,
They are not misunderstanding. The problem is still that you are trying to use the JDBC ResultSet on the JSP page. This is causing problems because you want multiple resultsets open at the same time. (and you probably also have a connection link from not closing the connection probably.)

With MVC architecture, you read from the database/resultset storing the result in Java objects completely disconnected from the database. You place those in request.setAttribute() and the JSP reads those beans without any database interaction at all.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Nishant Vashisth
Greenhorn

Joined: Jun 27, 2011
Posts: 23
Okay !!
getting your point to some extent !!
can you send me a link to a tutorial for this ??
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need Help With Accessing Multiple Access Database Tables Using JSP