BUG #1005: JDBC cancelRowUpdates() sets column values to null

From: "PostgreSQL Bugs List" <pgsql-bugs(at)postgresql(dot)org>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #1005: JDBC cancelRowUpdates() sets column values to null
Date: 2003-12-11 19:43:49
Message-ID: 20031211194349.829FACF4913@www.postgresql.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-jdbc


The following bug has been logged online:

Bug reference: 1005
Logged by: Lars Tetzlaff
Email address: lars(dot)tetzlaff(at)gmx(dot)net
PostgreSQL version: 7.4
Operating system: linux 2.4.23 i686
Description: JDBC cancelRowUpdates() sets column values to null
Details:

this sequence sets all but "plz" and "kategorie" to null, "kategorie" is changed to 0

rs.first();
rs.updateInt( "plz", 99999 );
rs.cancelRowUpdates();
rs.updateInt( "plz", 66666 );
rs.updateRow();
rs.beforeFirst();

Output before update:

Kunde Lars Tetzlaff
PLZ/Ort 51702 Bergneustadt
Strae Bahnhofstr. 32 E
Kategorie 1

Output after Update

Kunde null
PLZ/Ort 66666 null
Strae null
Kategorie 0

If i comment out the second updateInt, the data is OK.

java version "1.4.2_02"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_02-b03)
Java HotSpot(TM) Client VM (build 1.4.2_02-b03, mixed mode)

Table:

create table kunde
(
name varchar( 30 ) not null primary key,
plz integer,
ort varchar(30),
strasse varchar( 30 ),
kategorie integer not null
);

insert into kunde values ( 'Lars Tetzlaff', 51702, 'Bergneustadt', 'Bahnhofstr. 32 E', 1 );

Programm:

import java.sql.*;

public class connect
{
public static void main( String argv[] )
{
try {

//Class.forName("org.postgresql.Driver");
Connection db = DriverManager.getConnection( "jdbc:postgresql:tetzlaff",
"tetzlaff", "");

db.setAutoCommit( false );

// PreparedStatement pst = db.prepareStatement("insert into kunde values ( ?, " +
// "?, ?, ?, ? )");

// pst.setString( 1, "Thomas Friese" );
// pst.setInt( 2, 51580 );
// pst.setString( 3, "Reichshof-Eckenhagen" );
// pst.setString( 4, "Landwehrstr. 7" );
// pst.setInt( 5, 3 );

// pst.executeUpdate();

Statement st = db.createStatement( ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE );

ResultSet rs = st.executeQuery("SELECT * FROM kunde");

if( rs.isBeforeFirst() ) {
System.out.println( "Alles klar" );
}
else{
System.out.println( "Wo bin ich denn?" );
}

while (rs.next()) {
//System.out.print("Column 1 returned ");
System.out.println( "Kunde " + rs.getString(1)
+ "\nPLZ/Ort "
+ rs.getInt(2) + " " + rs.getString(3)
+ "\nStrae " +rs.getString( "STRASSE" )
+ "\nKategorie " + rs.getInt( "kategorie" )
);
}

rs.first();
rs.updateInt( "plz", 99999 );
rs.cancelRowUpdates();
rs.updateInt( "plz", 66666 );
rs.updateRow();
rs.beforeFirst();

while (rs.next()) {
//System.out.print("Column 1 returned ");
System.out.println( "Kunde " + rs.getString(1)
+ "\nPLZ/Ort "
+ rs.getInt(2) + " " + rs.getString(3)
+ "\nStrae " +rs.getString( "STRASSE" )
+ "\nKategorie " + rs.getInt( "kategorie" )
);
}

rs.close();
st.close();
}
catch( Exception ex ){
System.out.println( "Exception" + ex );
}

}
}

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Peter Eisentraut 2003-12-11 19:58:13 Re: postmaster.pid in version 7.4
Previous Message denise 2003-12-11 19:40:43 Problems with initdb

Browse pgsql-jdbc by date

  From Date Subject
Next Message Patrick Higgins 2003-12-11 20:17:03 Patch for some bugs/annoyances
Previous Message milton Leite 2003-12-11 19:35:25 PostgreSQL & DB2 !!!