Skip site navigation (1) Skip section navigation (2)

Re: stringtype=unspecified problem

From: "Chris Gamache" <cgamache(at)gmail(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: stringtype=unspecified problem
Date: 2007-02-14 19:29:06
Message-ID: 9cc55f600702141129l152d6e68i8c32fa0bb11bc788@mail.gmail.com (view raw or flat)
Thread:
Lists: 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(at)opencloud(dot)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
>

In response to

Responses

pgsql-jdbc by date

Next:From: Kris JurkaDate: 2007-02-14 19:36:15
Subject: Re: bug report: preparedStatement.setObject(indx,"2004-August-15",java.sql.Types.DATE) generates number format exception
Previous:From: Floyd ShackelfordDate: 2007-02-14 19:03:28
Subject: bug report: preparedStatement.setObject(indx,"2004-August-15",java.sql.Types.DATE) generates number format exception

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group