Forum Stats

  • 3,816,058 Users
  • 2,259,135 Discussions
  • 7,893,375 Comments

Discussions

How to make the JSTL access my database and some syntax question.

User_DTTUY
User_DTTUY Member Posts: 5 Blue Ribbon
Hi,

I've been trying and trying to make my jstl work but still not working.

Have added the resource references in tomcat.

jdbc/WebApplication1 javax.sql.DataSource Container Shareable database for WebApplication1

Not sure what other things I must do in order for my jsp page to display a table using jstl.

Hope some one can share with me.

<jsp:useBean id="Tutors" scope="session" class="databaseAccess.TutorsBean"/>
<jsp:setProperty name ="Tutors" property="*"/>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
<%@ taglib prefix="x" uri="http://java.sun.com/jsp/jstl/xml" %>

<%@page language="java" import ="java.sql.*" %>

<sql:setDataSource driver="com.mysql.jdbc.Driver" url="jdbc:mysql://
localhost:3306/pract1" user="root" password="123"/>

<sql:query var="tutors" maxRows="5">
Select *, GROUP_CONCAT(subject.subjectName SEPARATOR \", \") AS Subj from tutors LEFT JOIN subinter ON subinter.tutorsID = tutors.id LEFT JOIN subject ON subinter.subjectID = subject.id GROUP BY tutors.id");

</sql:query>


In MySQL I have created 3 tables by the name of tutors, subject and subinter

But, netbean IDE gave me an error on <sql:query var="tutors" maxRows="5">

So, hope someone can advise me where have I gone wrong with the syntax or what?

Tks.

Answers

This discussion has been closed.