Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Result Set Problem

Status
Not open for further replies.

zeero

Programmer
Aug 4, 2004
60
US
Hi all, I'm having a problem displaying my result set in a jsp file. Here's what I have:

Code:
<html>
<head>
<title>Result Set</title>
</head>
<%@ page import="java.sql.*" %>
<body>
<table border="1">
<tr><th>Pet ID<th>Pet Name<th>Description</tr>

<%
Class.forName("com.mysql.jdbc.Driver");
String url = "jdbc:mysql://localhost/petdb";
Connection con = DriverManager.getConnection(url,"","");

Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM pet");

while (rs.next())
{
String petid=rs.getString("petid");
String petname=rs.getString("petname");
String description=rs.getString("description");

out.print("<tr>");
out.print("<td>" +petid+ "</td>");
out.print("<td>" +petname+ "</td>");
out.print("<td>" +description+ "</td>");
out.print("</tr>");
}
stmt.close();
con.close();
%>

</table>
</body>
</html>

it displays the tables, but it's not pulling the data from the mysql database.
 
Hi,

Every thing looks good. Just make sure that your query returns data and the colomn names are correct.

Cheers
Venu
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top