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 Display each results from database in their own row Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Display each results from database in their own row" Watch "Display each results from database in their own row" New topic
Author

Display each results from database in their own row

Annemarie McKeown
Ranch Hand

Joined: Nov 07, 2003
Posts: 47
Hello,
I have the following code implemented which connects to my database and retrieves data corresponding to my query using a while loop in ResultSet.
I have printed the output in a table although, all records are printed in the same row, after one complete record has been read, I want to place a carriage return and display the next row after the first, how to I stop all the records from displayin in one complete row across my browser.
JSP Code
--------
...
...
ResultSet rs = stmt.executeQuery("SELECT * from fileuploads where project_cat='"+category+"' && project_subject='english' && project_type='course_notes'");

if (rs != null)
{
while(rs.next())
{
String projectid = rs.getString("projectid");
String project_title= rs.getString("project_title");
String project_type = rs.getString("project_type");
String project_cat = rs.getString("project_cat");
String project_subject = rs.getString("project_subject");
String url_path = rs.getString("url_path");
%>
<table>
<tr><td><%=projectid%></td>
<td><%=project_title%></td>
<td><%=project_type%></td>
<td><%=project_cat%></td>
<td><%=project_subject%></td>
<td><a href="<%=url_path%>">Download</a></td></tr></table>
It will print something like:
1 Title1 Type1 Cat1 Subject1 Download 2 Title2 Type2.

and so I...I want to it to return to a new row when a new row is being read in the database.
Let me know if you can help, please. Probably something really simple, just cant figure out how to implement a loop of some sort.
leo donahue
Ranch Hand

Joined: Apr 17, 2003
Posts: 327
Hi Annemarie,
Your question looks almost identical to a project I had in school. So, since you have already done most of the legwork, I'm just going to show you how I did mine. As I recall, we used a sample mdb file that was included wiht MS Access.

Grrr! Instant Graemlins!
[ March 04, 2004: Message edited by: leo donahue ]

Thanks, leo
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Display each results from database in their own row