|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object quick.dbtable.ResultSetMap
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();
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 |
public static final int UNICODE_DATA_TYPE
Constructor Detail |
public ResultSetMap()
Method Detail |
public java.lang.Object getObject(java.sql.ResultSet rs, int column) throws java.sql.SQLException
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); }
rs
- the resultset object for the current querycolumn
- the column for which we have to get the data. Index starts from 1,2,3
java.sql.SQLException
public void setObject(java.sql.PreparedStatement pStmt, int column, java.lang.Object value) throws java.sql.SQLException
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); }
pStmt
- the prepared statement object for the current update querycolumn
- the column for which we have to set the data. Index starts from 1,2,3value
- the object that in Quicktable which should be converted to the database format
java.sql.SQLException
public static ResultSetMap createResultSetMap(int dataType)
Currently this supports only ResultSetMap.UNICODE_DATA_TYPE Example yourColumn.setResultSetMap( ResultSetMap.createResultSetMap( ResultSetMap.UNICODE_DATA_TYPE ) );
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |