Advertisement
Guest User

Untitled

a guest
Apr 7th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. <%@ page contentType="text/html;charset=UTF-8" language="java" %>
  2. <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
  3. <%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
  4. <html>
  5. <head>
  6. <title>Hello, SQL!</title>
  7. </head>
  8. <body>
  9. <sql:setDataSource var="dataSource" driver="com.mysql.jdbc.Driver"
  10. url="jdbc:postgresql://localhost/some_database"
  11. user="username" password="password"/>
  12.  
  13. <sql:query dataSource="${dataSource}" var="resultSet">
  14. select * from some_table;
  15. </sql:query>
  16.  
  17. <select>
  18. <c:forEach var="row" items="${resultSet.rows}">
  19. <option value="${row.id}">${row.name}</option>
  20. </c:forEach>
  21. </select>
  22. </body>
  23. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement