Found JDBC driver bug? PreparedStatement.setBoolean doesn't work
Posted in 2007
A user on IDS 9.21.HC4 with Informix JDBC 3.00.JC3 found that PreparedStatement.setBoolean() against a BOOLEAN column failed with SQLException 674 "Routine (equal) can not be resolved", apparently because the driver didn't send 't'/'f'. His workaround was setString(1, flag ? "t" : "f"), which worked. Fernando Nunes suggested checking the Java/Informix type-mapping appendix in the JDBC guide, but the poster argued setBoolean should simply map to setString. An IBM engineer could not reproduce the error using the newer 3.10.JC1 driver (shipped with IDS 11.10) and asked for a test case; the poster had no 11.10 available. No confirmed fix or bug resolution is recorded beyond the setString workaround.
Auto-generated by DrWatson from the posts below — may be imperfect; read the full thread.
Topics: Connectivity: ODBC / JDBC / .NET, Java & JDBC Development
Hi,
I'm using those products:
Java VM: Java HotSpot(TM) Client VM
Java Version: 1.6.0_01-b06
Java Vendor: Sun Microsystems Inc.
OS Name: Windows XP
Informix Dynamic Server 9.21.HC4
IBM Informix JDBC Driver for IBM Informix Dynamic Server 3.00.JC3
Suppose you have a table where you have a BOOLEAN attribute:
create table mytable (
...
a BOOLEAN not null,
...
);
You want to perform a query using a PreparedStatement, something like:
ps = connection.prepareStatement("select * from mytable where a=?");
setting the boolean parameter using the setBoolean method:
ps.setBoolean(1, true);
When executing the statement, I get an SQLException:
674: Routine (equal) can not be resolved
I guess that the JDBC driver is assigning an empty string to the
boolean parameter, instead of the 't' and 'f' strings.
This workaround works OK:
ps.setString(1, booleanVariable.booleanValue() ? "t" : "f");
Anyone has Informix support to report this bug?
Regards,
Gabriel
Gabriel Belingueres wrote:
> Hi,
>
> I'm using those products:
> Java VM: Java HotSpot(TM) Client VM
> Java Version: 1.6.0_01-b06
> Java Vendor: Sun Microsystems Inc.
> OS Name: Windows XP
> Informix Dynamic Server 9.21.HC4
> IBM Informix JDBC Driver for IBM Informix Dynamic Server 3.00.JC3
>
> Suppose you have a table where you have a BOOLEAN attribute:
> create table mytable (
> ...
> a BOOLEAN not null,
> ...
> );>
> You want to perform a query using a PreparedStatement, something like:
> ps = connection.prepareStatement("select * from mytable where a=?");
> setting the boolean parameter using the setBoolean method:
> ps.setBoolean(1, true);
>
> When executing the statement, I get an SQLException:
> 674: Routine (equal) can not be resolved>
> I guess that the JDBC driver is assigning an empty string to the
> boolean parameter, instead of the 't' and 'f' strings.
>
> This workaround works OK:
>
> ps.setString(1, booleanVariable.booleanValue() ? "t" : "f");
>
> Anyone has Informix support to report this bug?
>
> Regards,
> Gabriel
>
I'm very far from being a "java guy", but you should look at Appendix C in the
JDBC programmers guide...
Apparently, as far as I could understand in a quick look, the driver has no way
to be sure on how to map the Java/JDBC types into Informix types... So there
are some methods to do it in a way that avoids ambiguity...
Possibly it makes portability harder...
Please take a look a give us your feedback.
Regards.
--
Fernando Nunes
Portugal
http://informix-technology.blogspot.com
My email works... but I don't check it frequently...
Hi,
Based on your pointers, I have created a repro. The repro does the
following:
1) Creation of a table - "CREATE TABLE TEST_BOOLEAN (COL1 BOOLEAN NOT
NULL)"
2) Insertion into the table -
PreparedStatement stmt1 = null;
"INSERT INTO TEST_BOOLEAN VALUES (?)";
boolean value = true;
stmt1 = conn.prepareStatement(sql1);
stmt1.setBoolean(1, value);
The value "true" gets inserted.
3) Selection from table -
PreparedStatement stmt = conn.prepareStatement("Select * from
TEST_BOOLEAN where COL1 = ?");
stmt.setBoolean(1, true);
ResultSet rs = stmt.executeQuery();
I was able to successfully do a selection, and did not get the error that
you had mentioned.
I am using the latest Informix JDBC drivers 3.10 JC1.
Can you provide me a small test case (if it is different from the lines of
what I am doing). It will help me to look into it further (if the problem
exists).
Rgds,
Ramesh
Fernando Nunes <spam@domus.online.pt>
Sent by: informix-list-bounces@iiug.org
10/10/2007 03:34
To
informix-list@iiug.org
cc
Subject
Re: Found JDBC driver bug? PreparedStatement.setBoolean doesn't work
Gabriel Belingueres wrote:
> Hi,
>
> I'm using those products:
> Java VM: Java HotSpot(TM) Client VM
> Java Version: 1.6.0_01-b06
> Java Vendor: Sun Microsystems Inc.
> OS Name: Windows XP
> Informix Dynamic Server 9.21.HC4
> IBM Informix JDBC Driver for IBM Informix Dynamic Server 3.00.JC3
>
> Suppose you have a table where you have a BOOLEAN attribute:
> create table mytable (
> ...
> a BOOLEAN not null,
> ...
> );>
> You want to perform a query using a PreparedStatement, something like:
> ps = connection.prepareStatement("select * from mytable where a=?");
> setting the boolean parameter using the setBoolean method:
> ps.setBoolean(1, true);
>
> When executing the statement, I get an SQLException:
> 674: Routine (equal) can not be resolved>
> I guess that the JDBC driver is assigning an empty string to the
> boolean parameter, instead of the 't' and 'f' strings.
>
> This workaround works OK:
>
> ps.setString(1, booleanVariable.booleanValue() ? "t" : "f");
>
> Anyone has Informix support to report this bug?
>
> Regards,
> Gabriel
>
I'm very far from being a "java guy", but you should look at Appendix C in
the
JDBC programmers guide...
Apparently, as far as I could understand in a quick look, the driver has
no way
to be sure on how to map the Java/JDBC types into Informix types... So
there
are some methods to do it in a way that avoids ambiguity...
Possibly it makes portability harder...
Please take a look a give us your feedback.
Regards.
--
Fernando Nunes
Portugal
http://informix-technology.blogspot.com
My email works... but I don't check it frequently...
_______________________________________________
Informix-list mailing list
Informix-list@iiug.org
http://www.iiug.org/mailman/listinfo/informix-list
On 10 oct, 01:05, Ramesh G Srinivasan <rames...@in.ibm.com> wrote:
> Hi,
>
> Based on your pointers, I have created a repro. The repro does the
> following:
>
> 1) Creation of a table - "CREATE TABLE TEST_BOOLEAN (COL1 BOOLEAN NOT
> NULL)"
> 2) Insertion into the table -
>
> PreparedStatement stmt1 = null;
> "INSERT INTO TEST_BOOLEAN VALUES (?)";
> boolean value = true;
> stmt1 = conn.prepareStatement(sql1);
> stmt1.setBoolean(1, value);
>
> The value "true" gets inserted.
>
> 3) Selection from table -
>
> PreparedStatement stmt = conn.prepareStatement("Select * from
> TEST_BOOLEAN where COL1 = ?");
> stmt.setBoolean(1, true);
> ResultSet rs = stmt.executeQuery();
>
> I was able to successfully do a selection, and did not get the error that
> you had mentioned.
>
> I am using the latest Informix JDBC drivers 3.10 JC1.
>
> Can you provide me a small test case (if it is different from the lines of
> what I am doing). It will help me to look into it further (if the problem
> exists).
>
> Rgds,
>
> Ramesh
>
> Fernando Nunes <s...@domus.online.pt>
> Sent by: informix-list-boun...@iiug.org
> 10/10/2007 03:34
>
> To
> informix-l...@iiug.org
> cc
>
> Subject
> Re: Found JDBC driver bug? PreparedStatement.setBoolean doesn't work
>
>
>
>
>
> Gabriel Belingueres wrote:
> > Hi,
>
> > I'm using those products:
> > Java VM: Java HotSpot(TM) Client VM
> > Java Version: 1.6.0_01-b06
> > Java Vendor: Sun Microsystems Inc.
> > OS Name: Windows XP
> > Informix Dynamic Server 9.21.HC4
> > IBM Informix JDBC Driver for IBM Informix Dynamic Server 3.00.JC3
>
> > Suppose you have a table where you have a BOOLEAN attribute:
> > create table mytable (
> > ...
> > a BOOLEAN not null,
> > ...
> > );>
> > You want to perform a query using a PreparedStatement, something like:
> > ps = connection.prepareStatement("select * from mytable where a=?");
> > setting the boolean parameter using the setBoolean method:
> > ps.setBoolean(1, true);
>
> > When executing the statement, I get an SQLException:
> > 674: Routine (equal) can not be resolved>
> > I guess that the JDBC driver is assigning an empty string to the
> > boolean parameter, instead of the 't' and 'f' strings.
>
> > This workaround works OK:
>
> > ps.setString(1, booleanVariable.booleanValue() ? "t" : "f");
>
> > Anyone has Informix support to report this bug?
>
> > Regards,
> > Gabriel
>
> I'm very far from being a "java guy", but you should look at Appendix C in
> the
> JDBC programmers guide...
> Apparently, as far as I could understand in a quick look, the driver has
> no way
> to be sure on how to map the Java/JDBC types into Informix types... So
> there
> are some methods to do it in a way that avoids ambiguity...
> Possibly it makes portability harder...
> Please take a look a give us your feedback.
>
> Regards.
>
> --
> Fernando Nunes
> Portugal
>
> http://informix-technology.blogspot.com
> My email works... but I don't check it frequently...
> _______________________________________________
> Informix-list mailing list
> Informix-l...@iiug.orghttp://www.iiug.org/mailman/listinfo/informix-list- Ocultar texto de la cita -
>
> - Mostrar texto de la cita -
3.10 JC1?? Wow, I didn't know that a newer driver version did exist!
If you go to
http://www-306.ibm.com/software/data/informix/tools/jdbc/
and follow the "Informix JDBC Driver downloads" link you will not find
it! (nobody will in any case)
Is it a beta version? Is it ready for production?
Please post the download URL of it.
Gabriel Belingueres wrote: > > 3.10 JC1?? Wow, I didn't know that a newer driver version did exist! > > If you go to > http://www-306.ibm.com/software/data/informix/tools/jdbc/ > and follow the "Informix JDBC Driver downloads" link you will not find > it! (nobody will in any case) > Is it a beta version? Is it ready for production? > Please post the download URL of it. > It comes with IDS server 11.10.
On 10 oct, 17:29, Frank Langelage <fr...@lafr.de> wrote: > Gabriel Belingueres wrote: > > > 3.10 JC1?? Wow, I didn't know that a newer driver version did exist! > > > If you go to > >http://www-306.ibm.com/software/data/informix/tools/jdbc/ > > and follow the "Informix JDBC Driver downloads" link you will not find > > it! (nobody will in any case) > > Is it a beta version? Is it ready for production? > > Please post the download URL of it. > > It comes with IDS server 11.10. Hmm we don't have v11.10. We are working with IDS 10.00.FC4XD and 9.21.HC4. Should I suppose it is NOT backward compatible with those IDS server versions? In that case, I can not upgrade the JDBC driver and the bug still remains.
On 10 oct, 01:05, Ramesh G Srinivasan <rames...@in.ibm.com> wrote:
> Hi,
>
> Based on your pointers, I have created a repro. The repro does the
> following:
>
> 1) Creation of a table - "CREATE TABLE TEST_BOOLEAN (COL1 BOOLEAN NOT
> NULL)"
> 2) Insertion into the table -
>
> PreparedStatement stmt1 = null;
> "INSERT INTO TEST_BOOLEAN VALUES (?)";
> boolean value = true;
> stmt1 = conn.prepareStatement(sql1);
> stmt1.setBoolean(1, value);
>
> The value "true" gets inserted.
>
> 3) Selection from table -
>
> PreparedStatement stmt = conn.prepareStatement("Select * from
> TEST_BOOLEAN where COL1 = ?");
> stmt.setBoolean(1, true);
> ResultSet rs = stmt.executeQuery();
>
> I was able to successfully do a selection, and did not get the error that
> you had mentioned.
>
> I am using the latest Informix JDBC drivers 3.10 JC1.
>
> Can you provide me a small test case (if it is different from the lines of
> what I am doing). It will help me to look into it further (if the problem
> exists).
>
> Rgds,
>
> Ramesh
>
> Fernando Nunes <s...@domus.online.pt>
> Sent by: informix-list-boun...@iiug.org
> 10/10/2007 03:34
>
> To
> informix-l...@iiug.org
> cc
>
> Subject
> Re: Found JDBC driver bug? PreparedStatement.setBoolean doesn't work
>
>
>
>
>
> Gabriel Belingueres wrote:
> > Hi,
>
> > I'm using those products:
> > Java VM: Java HotSpot(TM) Client VM
> > Java Version: 1.6.0_01-b06
> > Java Vendor: Sun Microsystems Inc.
> > OS Name: Windows XP
> > Informix Dynamic Server 9.21.HC4
> > IBM Informix JDBC Driver for IBM Informix Dynamic Server 3.00.JC3
>
> > Suppose you have a table where you have a BOOLEAN attribute:
> > create table mytable (
> > ...
> > a BOOLEAN not null,
> > ...
> > );>
> > You want to perform a query using a PreparedStatement, something like:
> > ps = connection.prepareStatement("select * from mytable where a=?");
> > setting the boolean parameter using the setBoolean method:
> > ps.setBoolean(1, true);
>
> > When executing the statement, I get an SQLException:
> > 674: Routine (equal) can not be resolved>
> > I guess that the JDBC driver is assigning an empty string to the
> > boolean parameter, instead of the 't' and 'f' strings.
>
> > This workaround works OK:
>
> > ps.setString(1, booleanVariable.booleanValue() ? "t" : "f");
>
> > Anyone has Informix support to report this bug?
>
> > Regards,
> > Gabriel
>
> I'm very far from being a "java guy", but you should look at Appendix C in
> the
> JDBC programmers guide...
> Apparently, as far as I could understand in a quick look, the driver has
> no way
> to be sure on how to map the Java/JDBC types into Informix types... So
> there
> are some methods to do it in a way that avoids ambiguity...
> Possibly it makes portability harder...
> Please take a look a give us your feedback.
>
> Regards.
>
> --
> Fernando Nunes
> Portugal
>
> http://informix-technology.blogspot.com
> My email works... but I don't check it frequently...
> _______________________________________________
> Informix-list mailing list
> Informix-l...@iiug.orghttp://www.iiug.org/mailman/listinfo/informix-list- Ocultar texto de la cita -
>
> - Mostrar texto de la cita -
Hi,
I've been reading appendix C and I don't think it is a problem of how
to map Java types to informix types. After all, the driver must work
with all datatypes defined in the PreparedStatement interface to
comply with the JDBC standard, and if NOT, it should be documented at
least. I found no documentation that the setBoolean won't work.
The thing is that for an Informix BOOLEAN type, the 2 allowed values
are the 't' and 'f' strings, and when calling
PreparedStatement.setString it works, but when calling
PreparedStatement.setBoolean it does not! this is strange since you
can easily implement the setBoolean method in terms of setString:
public void setBoolean(int post, boolean value) throws SQLException {
setString(post, value ? "t" : "f");
}
and all will work as a charm, but for some reason it doesn't.