List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:January 28 2002 5:04pm
Subject:Re: ? in primary key
View as plain text  
At 8:52 -0800 1/28/02, Tiffany C. wrote:
>Hello,
>
>It seems that the following preparedStatement is
>changing the character ? to null. 
>
>PreparedStatement selectLocation =
>conn.prepareStatement("select location, addressLine1,
>addressLine2, addressLine3, addressLine4,
>addressLine5, addressLine6, addressLine7,
>addressLine8, addressLine9, addressLine10,
>uniqueNumber from location WHERE region = "testing?"
>order by location ASC");
>ResultSet resultLocation =
>selectLocation.executeQuery();
>
>The region "testing" will become "testingnull" before
>the preparedStatement is executed.  How can I reform
>this preparedStatement to work?

? signifies a placeholder.  Either use a Statement object instead
of a PreparedStatement object, or rewrite your code like this:

PreparedStatement selectLocation =
conn.prepareStatement("select location, addressLine1,
addressLine2, addressLine3, addressLine4,
addressLine5, addressLine6, addressLine7,
addressLine8, addressLine9, addressLine10,
uniqueNumber from location WHERE region = ?
order by location ASC");

selectLocation.setString(1, "testing?");

ResultSet resultLocation =
selectLocation.executeQuery();


>
>Thanks.
>
>Sincerely,
>Tiffany

Thread
? in primary keyTiffany C.28 Jan
  • Re: ? in primary keyPaul DuBois28 Jan
    • Re: ? in primary keyTiffany C.28 Jan
      • Re: ? in primary keyPaul DuBois28 Jan
        • Re: ? in primary keyTiffany C.28 Jan