Re: stringtype=unspecified problem - Mailing list pgsql-jdbc

From Chris Gamache
Subject Re: stringtype=unspecified problem
Date
Msg-id 9cc55f600702141129l152d6e68i8c32fa0bb11bc788@mail.gmail.com
Whole thread Raw
In response to Re: stringtype=unspecified problem  (Oliver Jowett <oliver@opencloud.com>)
Responses Re: stringtype=unspecified problem
List pgsql-jdbc
Here's a test case... Since I'm handling these UUIDs as Strings
throughout the java code, they are indistinguishable from an actual
string.

/*
 * CREATE TABLE bomb_test (uuid uniqueidentifier);
 */

try {
       DriverManager.registerDriver(new org.postgresql.Driver());
       Connection conn =

DriverManager.getConnection("jdbc:postgresql://10.10.0.1:5432/data/public?stringtype=unspecified","postgres","password");
       PreparedStatement bombOnNull = conn.prepareStatement("INSERT INTO
bomb_test (uuid) values (?)");
       //bombOnNull.setString(1, UUID.randomUUID().toString()); //this works
       //bombOnNull.setString(1, null); //this works
       //bombOnNull.setNull(1, java.sql.Types.NULL); //this works
       //bombOnNull.setNull(1, java.sql.Types.OTHER); //this works
       bombOnNull.setNull(1, java.sql.Types.VARCHAR); //this bombs
       bombOnNull.executeUpdate();
       bombOnNull.close();
       conn.close();
} catch (Exception e) {
       e.printStackTrace();
}

Thank you for taking a look!

On 2/11/07, Oliver Jowett <oliver@opencloud.com> wrote:
> Chris Gamache wrote:
>
> > I'm running into a problem when I want to explicitly set one of those
> > unspecified types to NULL.
>
> How exactly are you doing this, in terms of JDBC API calls? A testcase
> showing the problem would be useful.
>
> -O
>

pgsql-jdbc by date:

Previous
From: Floyd Shackelford
Date:
Subject: bug report: preparedStatement.setObject(indx,"2004-August-15",java.sql.Types.DATE) generates number format exception
Next
From: Kris Jurka
Date:
Subject: Re: bug report: preparedStatement.setObject(indx,"2004-August-15",java.sql.Types.DATE) generates number format exception