Hi all, I'm having a problem displaying my result set in a jsp file. Here's what I have:
it displays the tables, but it's not pulling the data from the mysql database.
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.