Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
- <%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>
- <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
- <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
- <html>
- <head>
- <title>JSTL sql:query Tag</title>
- </head>
- <body>
- <sql:setDataSource var="snapshot" driver="com.mysql.jdbc.Driver"
- url="jdbc:mysql://localhost:3306/mydb"
- user="root" password="root"/>
- <sql:query dataSource="${snapshot}" var="result">
- SELECT * from dateinfo;
- </sql:query>
- <table border="1" width="100%">
- <tr>
- <th>Emp ID</th>
- <th>First Name</th>
- <th>Last Name</th>
- <th>Age</th>
- </tr>
- <c:forEach var="row" items="${result.rows}">
- <tr>
- <td><c:out value="${row.id}"/></td>
- <td><c:out value="${row.first}"/></td>
- <td><c:out value="${row.last}"/></td>
- <td><c:out value="${row.age}"/></td>
- </tr>
- </c:forEach>
- </table>
- </body>
- </html>
- javax.servlet.ServletException: javax.servlet.jsp.JspException: Unable to get
- connection, DataSource invalid: "java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/mydb"
Add Comment
Please, Sign In to add comment