JSP SQL

I have the following SQL Statement. I use to use it in my ASP page, and it worked fine, but now that I try to use it in my JSP page, it give an error, what may be wrong?

SELECT DISTINCT CONVERT(CHAR(11), R_Date, 111) + SUBSTRING(CONVERT(CHAR(19), R_Date, 100), 13, 19) AS Expr1 FROM Rates Where R_DATE > '2004' ORDER BY Expr1 DESC

ERROR

HTTP ERROR: 500

ERROR: syntax error at or near ","

[423 byte] By [Reniera] at [2007-10-1 23:41:26]
# 1

> what may be wrong?

well first of all you should remove the database access code from your JSP

IMHO, JSP's shouldn't have any code inside of them

that said, take the SQL and put it into a SQL command interpreter and try it there, once you get it working right, then move it over to Java

SoulTech2012a at 2007-7-15 15:31:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
We would need to know:The Database.Which driver are you using.What does your exception stack trace look like?
linxpdaa at 2007-7-15 15:31:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

I am using PostgreSQL and JDBC / JNDI, using JSTL

The error says >

javax.servlet.jsp.JspException:

SELECT DISTINCT CONVERT(CHAR(11), R_Date, 111) + SUBSTRING(CONVERT(CHAR(19), R_Date, 100), 13, 19) AS Expr1 FROM Rates Where R_DATE > '2004' ORDER BY Expr1 DESC

: ERROR: syntax error at or near ","

Reniera at 2007-7-15 15:31:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
thanks for the advice, but I am using JSTL, and sometimes it is appropriate to use the <sql:datasource> and <sql:query> tags inside your JSP
Reniera at 2007-7-15 15:31:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...