1 18 19 package org.apache.beehive.controls.system.jdbc; 20 21 import com.sun.rowset.CachedRowSetImpl; 22 import org.apache.beehive.controls.api.ControlException; 23 import org.apache.beehive.controls.api.context.ControlBeanContext; 24 import org.apache.beehive.controls.system.jdbc.JdbcControl.SQL; 25 26 import javax.sql.RowSet ; 27 import java.lang.reflect.Method ; 28 import java.sql.ResultSet ; 29 import java.sql.SQLException ; 30 import java.util.Calendar ; 31 32 35 public class DefaultRowSetResultSetMapper extends ResultSetMapper { 36 37 private static final TypeMappingsFactory _tmf = TypeMappingsFactory.getInstance(); 38 39 48 public RowSet mapToResultType(ControlBeanContext context, Method m, ResultSet resultSet, Calendar cal) { 49 final SQL methodSQL = (SQL) context.getMethodPropertySet(m, SQL.class); 50 final int maxrows = methodSQL.maxRows(); 51 52 try { 53 CachedRowSetImpl rows = new CachedRowSetImpl(); 54 55 if (maxrows > 0) { 56 rows.setMaxRows(maxrows); 57 } 58 59 rows.populate(resultSet); 60 return rows; 61 } catch (SQLException e) { 62 throw new ControlException(e.getMessage(), e); 63 } 64 } 65 66 71 public boolean canCloseResultSet() { return false; } 72 } 73 | Popular Tags |