Path: newssvr20.news.prodigy.com!newsmst01.news.prodigy.com!prodigy.com!in.100proofnews.com!in.100proofnews.com!cyclone.bc.net!newsfeed.stanford.edu!postnews1.google.com!not-for-mail
From: nelson.broat@mail.cuny.edu (Nelson Broat)
Newsgroups: comp.databases.oracle,comp.databases.oracle.tools,comp.databases.oracle.misc
Subject: executeQuery  Can't pass variable to SQL. :-(  Why?
Date: 8 Aug 2003 15:16:41 -0700
Organization: http://groups.google.com/
Lines: 37
Message-ID: <32159d9d.0308081416.7eadabe@posting.google.com>
NNTP-Posting-Host: 151.205.104.232
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Trace: posting.google.com 1060381001 22949 127.0.0.1 (8 Aug 2003 22:16:41 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: 8 Aug 2003 22:16:41 GMT
Xref: newssvr20.news.prodigy.com comp.databases.oracle:23029 comp.databases.oracle.tools:82489 comp.databases.oracle.misc:130389

In jsp land you can have the following:

<% 
String name = "Nelson";
%>

Hi, my name is <%= name %>.

Such that, in your browser you see:

Hi, my name is Nelson.

I am trying to do similiar with the executeQuery() method and it is
not working. Can anyone tell me what is wrong with the syntax I'm
using?
The jsp won't compile. It seems to not want to allow me to pass a
variable called recordkey, which in this example has a value of 999.
But in a loop structure which I'm looking to create, the value would
change. Thanks for any and all help.

<%@ page import="java.util.*, 
                 java.text.*, 
                 java.io.*, 
                 java.sql.*"
    contentType="text/html; charset=UTF-8"
%>
<%
Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
con = DriverManager.getConnection("jdbc:oracle:thin:@dsn:portnumber:dbinstance","userid","passwd");
stmt = con.createStatement();
int recordkey = 999;
String sql = "SELECT * FROM db.db WHERE db.column = <%= recordkey %>";
rs = stmt.executeQuery(sql);
%>

Nelson Broat
nelson.broat@mail.cuny.edu
