RFE - add generic accessors to SQLInput, SQLOutput

Ulf Ulf.Zibis at CoSoCo.de
Sun Jan 13 05:20:29 PST 2013


Hi,

because bugparade is not working, I post this here :-(

There could be:

public <T> T read() throws SQLException;
public <T> void write(T obj) throws SQLException;

Alternatively, maybe readObject(), writeObject() could be re-engineered with generic API.

All other methods then could be deprecated !

E.g. in javax.sql.rowset.serial.SQLInputImpl the code simply could be:
(private getNextAttribute() could be dropped)

     // rename Object[] attrib to attribs !!!

     public <T> T readObject() throws SQLException {
         if (++idx >= attribs.length) {
             throw new SQLException("SQLInputImpl exception: Invalid read " +
                                    "position");
         }
         Object attrib = attribs[idx];
         lastValueWasNull = attrib == null;
         if (attrib instanceof Struct) {
             ...
             ...
             ...
         }
         return (T)attrib;
     }


-Ulf



More information about the jdbc-spec-discuss mailing list