quick.dbtable
Class ResultSetMap

java.lang.Object
  extended byquick.dbtable.ResultSetMap

public class ResultSetMap
extends java.lang.Object

QuickTable uses getObject() , setObject method in resultset to read the data. But in some special cases you have to handle it differently. This class helps to do that.

  Example :
    If the data type in database is nvarchar, then you have to use getString() ( getObject() doesn't work)
    If data is stored as stream in database, instead of using getObject() , you have to use getBinaryStream()

 Sample implementation
public class StreamResultSetMap extends ResultSetMap
{

   public Object getObject(ResultSet rs, int column) throws SQLException
   {
      InputStream in = rs.getBinaryStream(column);
      String value = createStringFromStream(in);
      return value;
   }

   public void setObject(PreparedStatement pStmt, int column, Object value) throws SQLException
   {
      rs.setBinaryStream(column,getStreamFromString(value), getLengthOfStreamFromValue(value));
   }
}

 //for a new select sql for dbtable, setResultSetMap should be called after createColumnModelFromQuery() and
 //before calling refresh()
 dbtable.createColumnModelFromQuery();
 yourColumn.setResultSetMap( new StreamResultSetMap() );
 dbtable.refresh();

Since:
2.0.4
See Also:
Column.setResultSetMap(ResultSetMap)

Field Summary
static int UNICODE_DATA_TYPE
          For NCHAR, NVARCHAR and NTEXT datatype
 
Constructor Summary
ResultSetMap()
           
 
Method Summary
static ResultSetMap createResultSetMap(int dataType)
          Utility method to create ResultSetMap.
 java.lang.Object getObject(java.sql.ResultSet rs, int column)
          Gets the data from the resulset and converts to a object which is displayable by the cell renederer/edito
 void setObject(java.sql.PreparedStatement pStmt, int column, java.lang.Object value)
          Updates the data to Prepared statment , in the database format
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNICODE_DATA_TYPE

public static final int UNICODE_DATA_TYPE
For NCHAR, NVARCHAR and NTEXT datatype

See Also:
Constant Field Values
Constructor Detail

ResultSetMap

public ResultSetMap()
Method Detail

getObject

public java.lang.Object getObject(java.sql.ResultSet rs,
                                  int column)
                           throws java.sql.SQLException
Gets the data from the resulset and converts to a object which is displayable by the cell renederer/edito
  Example :
    If the data in database is stream, read the stream and create a object
    which is displayable by the cell renederer/editor

   public Object getObject(ResultSet rs, int column) throws SQLException
   {
      InputStream in = rs.getBinaryStream(column);
      String value = createStringFromStream(in);
      return value;
   }

 Default Implementation:
   public Object getObject(ResultSet rs, int column) throws SQLException
   {
      return rs.getObject(column);
   }

 

Parameters:
rs - the resultset object for the current query
column - the column for which we have to get the data. Index starts from 1,2,3
Returns:
the final data which will be used by QuickTable
Throws:
java.sql.SQLException

setObject

public void setObject(java.sql.PreparedStatement pStmt,
                      int column,
                      java.lang.Object value)
               throws java.sql.SQLException
Updates the data to Prepared statment , in the database format
  Example :
    If the data in database is stream, convert the Quicktable data into stream

   public void setObject(PreparedStatement pStmt, int column, Object value) throws SQLException
   {
      rs.setBinaryStream(column,getStreamFromString(value), getLengthOfStreamFromValue(value));
   }

 Default Implementation:
   public void setObject(PreparedStatement pStmt, int column, Object value) throws SQLException
   {
      pStmt.setObject(column, value);
   }

 

Parameters:
pStmt - the prepared statement object for the current update query
column - the column for which we have to set the data. Index starts from 1,2,3
value - the object that in Quicktable which should be converted to the database format
Throws:
java.sql.SQLException

createResultSetMap

public static ResultSetMap createResultSetMap(int dataType)
Utility method to create ResultSetMap.
 Currently this supports only ResultSetMap.UNICODE_DATA_TYPE
 Example
   yourColumn.setResultSetMap( ResultSetMap.createResultSetMap( ResultSetMap.UNICODE_DATA_TYPE ) );