new.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP List Users Records</title>
</head>
<body>
<sql:setDataSource
var="headway"
driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost:3306/headway"
user="root" password="toor"
/>
<sql:query var="listUsers" dataSource="$ {headway}">
SELECT * FROM head;
</sql:query>
<div align="center">
<table border="1" cellpadding="5">
<caption><h2>List of users</h2></caption>
<tr>
<th>ID</th>
<th>Name</th>
<th>Email</th>
<th>Profession</th>
</tr>
<c:forEach var="user" items="${listUsers.rows}">
<tr>
<td><c:out value="${user.id}" /></td>
<td><c:out value="${user.name}" /></td>
<td><c:out value="${user.salary}" /></td>
<td><c:out value="${user.designation}" /></td>
</tr>
</c:forEach>
</table>
</div>
</body>
</html>
hi
I am trying to display the data from the database. but it shows error like that:
org.apache.jasper.JasperException: An exception occurred processing JSP page /new.jsp at line 20
user="root" password="toor"
/>
<sql:query var="listUsers" dataSource="$ {headway}">
SELECT * FROM head;
</sql:query>
Unable to get connection, DataSource invalid: "java.sql.SQLException: No suitable driver found for $ {headway}"
but actually there is database name is headway
table name is head;
+----+-------+--------+-------------+
| id | name | salary | designation |
+----+-------+--------+-------------+
| 1 | srinu | 50000 | test |
| 2 | srinu | 500000 | devel |
| 3 | pawan | 100000 | net |
| 4 | ravi | 2000 | .net |
| 5 | ramya | 22222 | tester |
| 6 | srinu | 0 | sql |
| 7 | srinu | 200000 | test |
| 8 | srinu | 1000 | java |
| 9 | srinu | 11111 | html |
| 10 | srinu | 11111 | html |
| 11 | vv | 29999 | hg |
| 12 | s | 147 | aa |
+----+-------+--------+-------------+