Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: strange results from JDBC query

Re: strange results from JDBC query

From: Dave Penn <djpenn3_at_hotmail.com_spammenot>
Date: Tue, 31 Aug 2004 10:27:32 -0500
Message-ID: <T8udna0x5oMtBancRVn-gg@comcast.com>


Alex,

I have that aspect covered - the variable "pagename" is a String that has had single quotes prepended and appended by a method in one of the application's String manipulation classes. I omitted that method call from the code snippet for the sake of clarity. Sorry for the confusion. You are correct in suggesting that the query would fail without these single quotes, but that's not the problem. The problem is the seeming data type mismatch or implicit conversion to some unknown type.

Thanks, though. Any other suggestions?

Regards,
Dave Penn

"Alex Filonov" <afilonov_at_yahoo.com> wrote in message news:336da121.0408310712.6fa96bf0_at_posting.google.com...
> "Dave Penn" <djpenn3_at_hotmail.com_spammenot> wrote in message
news:<sMmdnQjyxO3TsancRVn-qw_at_comcast.com>...
> > Here's one for you experts:
> >
> > I have a 9i release 2 db set up, to which I connect via the JDBC thin
> > driver. I have a JavaServer Pages application that needs to read a
VARRAY
> > from a table and then use the contents of the VARRAY. Here's the code
in
> > the JSP that does that:
> >
> > resultset=db.executeQuery
> > ("SELECT IMAGE_lIST FROM PAGE_IMAGE_ARRAY WHERE PAGENAME = " +
> > pagename);
> >
>
> I assume pagename is varchar2, right?
>
> In this case, you need your literals quoted in the query string, like
this:
>
> ("SELECT IMAGE_lIST FROM PAGE_IMAGE_ARRAY WHERE PAGENAME = " + "'" +
> pagename + "'");
>
>
> > oracle.sql.ARRAY array =
> > ((oracle.jdbc.driver.OracleResultSet)resultset).getARRAY(1);
> > imageList = (String[])array.getArray();
> > for(int count=0; count<imageList.length; count++)
> > {
> > out.println("<p>The image at position " + count + " in the array
is
> > the image titled: " + imageList[count]);
> > }
> >
> > The JSP compiles and runs fine, but the output is as follows:
> >
> > The image at position 0 in the array is the image titled: 0x7465737431
> > The image at position 1 in the array is the image titled: 0x7465737432
> >
> > The image at position 2 in the array is the image titled: 0x7465737433
> >
> > The image at position 3 in the array is the image titled: 0x7465737436
> >
> > A query using SQL*Plus verifies that the actual values of the elements
of
> > the array are 'test1', 'test2', 'test3', 'test6'. Notice that the last
> > digit in the hex(?) output matches the last digit of the actual string.
> >
> > What's causing this? It looks like a data type mismatch, but I would
have
> > thought that such an error would have triggered a compile-time error.
> >
> > Any help is greatly appreciated.
> >
> > Regards,
> >
> > Dave Penn
Received on Tue Aug 31 2004 - 10:27:32 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US