JSTL, MYSQL, Tomcat <sql:query> error (desperate)


Web tier: servlets, JSP, Web frameworks: JSTL, MYSQL, Tomcat <sql:query> error (desperate)

  1. Hi to everyone...
    This is my first post, but since im employed now as a java developer ill be here regulary.
    Right now im trying to use the JSTL to make some simple sql selects in my JSPs....

    Here´s the JSP code:
    <%@ page language="java" import="java.lang.*,java.util.*" %>
    <%@ taglib uri="/jstl-core" prefix="c" %>
    <%@ taglib uri="/jstl-sql" prefix="sql" %>
         <title> A first JSP database </title>
    <sql:setDataSource scope="session" var="dataSource"
        url="jdbc:mysql://" driver="com.mysql.jdbc.Driver"
        user="root" password="root"/>

    <!-- The following UPDATE works fine.. -->
    <sql:update var="users" dataSource="${dataSource}" scope="session">
        INSERT INTO test VALUES (7,'Paul Oakenfold')

    <!-- But the select screws up.... -->
    <sql:query var="users" dataSource="${dataSource}" scope="session">
        SELECT * FROM test WHERE 1

    ...and the error message:
    exception :

        SELECT * FROM test WHERE 1
    : null
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:254)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)

    root cause

        SELECT * FROM test WHERE 1
    : null
    at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:531)
    at org.apache.jsp.index_jsp._jspService(index_jsp.java:84)

    ...and just for completion the importent part of my web.xml:

    i am using the jboss 3.2.3 tomcat bundle (tomcat 4.1.29)
    and mysql 4.0.18 on W32 System....
    the JSTL is installed and working - i can make <sql:update>Inserts without any problems, but any <sql:query>selects result in that error... so i guess the setDataSource is okay...

    Any idea would be appreciated....



    Threaded Messages (7)

  2. Your select syntax is messy.

    Try "SELECT * FROM test" if you want to select all the records in the table.
  3. already did[ Go to top ]

    originally i had
    SELECT * FROM test
    ... i just added the "WHERE 1" because someone suggested a WHERE would be expected .... none of the two statements worked.

    I also played around with the scope already.... no difference.

    I really run out of ideas already.... every tutorial i find and every example writes similiar code - so whats wrong with mine ?

    Thx for the try already
  4. already did[ Go to top ]

    I have to admit, I am at a loss. I would guess that the problem is with your JDBC drivers, except that the update is working.

    Try putting the select logic in a different JSP from the update. Maybe the connection is somehow being lost before the select and the update. That could be an indication that there is a problem with the way the connection is being managed.
  5. hu ?[ Go to top ]

    i will try now, but honestly i wouldnt understand, cause the update alone works, but the query alone screws, so i wouldnt understand why the connection is being handled well if followed by an update but screwed if followed by a query....

    but thx anyway, ill pass the result of my desperation here when im done ;o)
  6. i love you[ Go to top ]

    THX !
    That really made my day!
    replacing the taglib uris alone worked, though i dont fully understand why, cause the taglib WAS there and WAS working (cause of the insert....)...

    I saw that kind of uri in another tut.

    End of story: Dont believe everything a tut says ;o)

    Thx again...
  7. i love you[ Go to top ]

    I'm glad its working now :)
  8. Please help me[ Go to top ]

    HI there,
    I've got exactly the same problem as yours and have no clue how to solve it. Could you please teach me the solution?