View Single Post

   
  #3 (permalink)  
Old 04-16-2008, 12:35 AM
Chris Gamache
 
Posts: n/a
Default Re: stringtype=unspecified problem

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("jdbcostgresql://10.10.0.1:5432/data/public?stringtype=unspecified","postgres","passwor d");
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
>


---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

Reply With Quote