mercredi 9 mai 2018

Table-Data-Gateway with RecordSet: How to get from ResultSet to RecordSet

for university i am doing a task using Table-Data-Gateway Pattern. I read a Tutorial and understand the Principle but i do not get how this guy came from ResultSet to RecordSet without extending the ResultSet in his RecordSet-Interface.

The Interface:

public interface RecordSet {
/* 
 * Looks like a java.sql.ResultSet,
 * but isn't.
 * */

public boolean next() throws RecordSetException
public java.lang.String getString(java.lang.String arg0) throws RecordSetException
public boolean getBoolean(java.lang.String arg0) throws RecordSetException
public byte getByte(java.lang.String arg0) throws RecordSetException
public short getShort(java.lang.String arg0) throws RecordSetException
public int getInt(java.lang.String arg0) throws RecordSetException
public long getLong(java.lang.String arg0) throws RecordSetException
public float getFloat(java.lang.String arg0) throws RecordSetException
public double getDouble(java.lang.String arg0) throws RecordSetException
public java.math.BigDecimal getBigDecimal(java.lang.String arg0, int arg1) throws RecordSetException
public java.math.BigDecimal getBigDecimal(java.lang.String arg0) throws RecordSetException
public boolean first() throws RecordSetException
public boolean last() throws RecordSetException
public boolean previous() throws RecordSetException;

}

is used in:

public static synchronized Student findByGuId(UUID uniqueID) throws DataMapperException {
    try {

        RecordSet rs = StudentGateway.findByGuId(uniqueID); // No longer a java.sql.ResultSet

        while(rs.next()) {

.....

I think he forgot to extend or is there any other chance to get the Data in the ResultSet to a RecordSet?

Except this it is a great tutorial:Table-Data-Gateway

Sorry if this is a stupid logical failure of myself...

Aucun commentaire:

Enregistrer un commentaire