Two Laptop Bag*
The moose likes JSP and the fly likes JSP JSTL to Oracle Connectivity Error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "JSP JSTL to Oracle Connectivity Error" Watch "JSP JSTL to Oracle Connectivity Error" New topic
Author

JSP JSTL to Oracle Connectivity Error

Kailash karayat
Greenhorn

Joined: Jun 22, 2012
Posts: 10
Hi,

I am using oracle 10g as database and i want to use jstl for database access.

i have the following program which is giving error message.

The exception is : javax.servlet.jsp.JspException: SELECT * from EMPLOYEES; : ORA-00911: invalid character
There is an exception: SELECT * from EMPLOYEES; : ORA-00911: invalid character

the program is

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page import="java.io.*,java.util.*,java.sql.*"%>
<%@ page import="javax.servlet.http.*,javax.servlet.*" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>

<sql:setDataSource var="db"
driver="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@localhost:1521:xe"
user="scott"
password="tiger"
scope="session"/>
<c:catch var ="catchException">
<sql:query var="result" dataSource="${db}" >
SELECT * from EMPLOYEES;
</sql:query>
</c:catch>
The exception is : ${catchException} <br />
There is an exception: ${catchException.message}
<html>
<head>
<title>JSTL sql:query Tag</title>
</head>
<body>



<table border="1" width="100%">
<tr>

<th>First Name</th>
<th>Last Name</th>

</tr>
<c:forEach var="row" items="${result.rows}">
<tr>

<td><c:out value="${row.first}"/></td>
<td><c:out value="${row.last}"/></td>

</tr>
</c:forEach>
</table>

</body>
</html>
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1018
my guess on the invalid character would be the ';'
Try removing that and see if it works.

Having said that though, running sql queries through a JSP is not the best approach.
Using JSTL is better than using scriptlets, I'll grant you that, but even in the JSTL specification they state that these tags should only be used from demos and small projects.
You would be better off writing a data access layer in java.

 
 
subject: JSP JSTL to Oracle Connectivity Error