JDK-4674376 : ResultSet.updateRow() write all string columns that was access with getString()
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.sql:bridge
  • Affected Version: 1.4.1
  • Priority: P3
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2002-04-25
  • Updated: 2002-10-31
  • Resolved: 2002-10-31
Related Reports
Relates :  
Relates :  
Description
J2SE Version (please include all output from java -version flag):
java version "1.4.1-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-beta-b06)
Java HotSpot(TM) Client VM (build 1.4.1-beta-b06, mixed mode)



Does this problem occur on J2SE 1.3 or 1.4?  Yes / No (pick one)
Yes


Operating System Configuration Information (be specific):
Window 2000 Server


Hardware Configuration Information (be specific):
P3/800


Bug Description:
The method ResultSet.updateRow() write all string columns 
that was access with getString(). Thats the string columns are empty
after the update. It seems that this occur for all rows.
If call getString() on the first row and then update all rows then
the value for all columns is empty.

Only columns with updateXXX should be updated. thus should be reset after
updateRow() or insertRow().

This was tested with a MS ACCESS 2.0 and MS ACCESS 2000 database.


Steps to Reproduce (be specific):
execute the test Test5.java program

Test Program
----------------
import java.sql.*;

public class Test5 {

    static String url = "jdbc:odbc:pcbistro";

    public static void main(String argc[]) throws Exception{
        //DriverManager.setLogStream(System.out);
        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");


        // create test data
        Connection con = DriverManager.getConnection( url, "admin", "");
        try{
            con.createStatement().execute("DROP table inet_Corrupt_rs");
        }catch(Throwable e){}
        Statement st = con.createStatement();
        st.execute("CREATE TABLE inet_Corrupt_rs(LFD_NR Counter, ANR smallint, ANZ smallint, GESPREIS money, RNR int not null, DATUM datetime, BON bit, ZNR smallint, KNR_Buchung smallint, PreisKlasse byte, Computer varchar(32) NOT NULL, Gang byte, MwSt money )");
        for(int i=0; i<10; i++){
            st.execute("INSERT INTO  inet_Corrupt_rs( ANR, ANZ, GESPREIS, RNR, DATUM, BON, Computer) VALUES( 10, 1, 4, 24, now(), false, 'Computer1')" );
        }
        st.close();


        // begin test
        Statement pr = con.createStatement( ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE );
        ResultSet rs = pr.executeQuery("SELECT * FROM inet_Corrupt_rs");

        while(rs.next()){
            rs.updateBoolean( "BON", !rs.getBoolean("BON"));
            rs.updateRow();
            System.out.println("Computer:" + rs.getString("Computer"));
        }
        con.close();    }

}

More information from the customer:

A short description of the bug:
- the method getString() set a flag for this column
- on string columns the method getObject() is calling internally getString()
- next() and updateRow() not reset this flag.
- If this flag set then updateRow is binding the column (JDBC log)
- an empty value (null or empty string) is write to the db because there is no
  value set for this column with updateRow()
- if it a int value then the current value is save to the db

Comments
EVALUATION Need to reproduce, and then target for Mantis if there indeed exisits a problem. ###@###.### 2002-05-12 This bug has been fixed as part of the various bug fixes done on updatable resultsets for mantis (See related bugs). Closing as this is not re-producable after the bug fixes. ###@###.### 2002-10-31
31-10-2002