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: Oracle 10g Express jdbc thin driver setString() problem

Re: Oracle 10g Express jdbc thin driver setString() problem

From: <joeNOSPAM_at_BEA.com>
Date: Wed, 11 Jul 2007 15:30:26 -0000
Message-ID: <1184167826.563505.77320@x35g2000prf.googlegroups.com>


On Jul 10, 5:39 pm, Srini <srini.veniga..._at_gmail.com> wrote:
> Hi
>
> I installed Oracle 10g Express and created a simple table and added
> data.
>
> LOGIN{
> LOGIN_ID Char (10)
> PASSWORD Char (10)
>
> }
>
> I am connecting to the database through Oracle thin jdbc driver.
>
> In Java, I create a PreparedStatement (not OraclePreparedStatement)
> like this:
>
> PreparedStatement ps = con.preparestatement ("Select PASSWORD from
> Login where LOGIN_ID=?");
>
> When I bind the param like this:
> ps.setString (1,"DEMO");
> ResultSet rs = ps.executeQuery();
>
> The query return 0 rows.
>
> If I use the parameter directly in the query like this, it works:
> PreparedStatement ps = con.preparestatement ("Select PASSWORD from
> Login where LOGIN_ID='DEMO'");
>
> The database NLS Character Set is showing UNICODE, not Default. I am
> suspecting this is the problem. Is there any way to make the parameter
> binding work?
>
> I do not care for Unicode. Is there anyway to change the charset to
> DEFAULT, assuming parameter binding would work on DEFAULT?
>
> Any help is appreciated. I am using the latest jdbc thin driver.

Hi. The issue is your DDL. If you change the column definitions to VARCHAR2,
your JDBC will work. Otherwise, make sure you blank-pad your parameter values to be the exact length of your fixed-length columns.

   If you send the SQL with the values written in, the DBMS will silently
assume you want to pad out the quoted values, and will make matches, but once you ask the DBMS to make a compiled query plan with parameter markers, such as with a PreparedStatement, the values you send will be used as they are, no padding.
HTH,
Joe Weinstein at BEA Systems Received on Wed Jul 11 2007 - 10:30:26 CDT

Original text of this message

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