1 package org.apache.ojb.broker.accesslayer; 2 3 17 18 import java.sql.ResultSetMetaData ; 19 import java.sql.SQLException ; 20 21 import org.apache.ojb.broker.PersistenceBrokerException; 22 import org.apache.ojb.broker.core.PersistenceBrokerImpl; 23 import org.apache.ojb.broker.metadata.JdbcTypesHelper; 24 25 31 public class SqlBasedReportQueryRsIterator extends SqlBasedRsIterator 32 { 33 private ResultSetMetaData rsMetaData; 34 private int columnCount; 35 36 39 public SqlBasedReportQueryRsIterator(RsQueryObject queryObject, PersistenceBrokerImpl broker) 40 throws PersistenceBrokerException 41 { 42 43 super(queryObject, broker); 44 try 45 { 46 rsMetaData = getRsAndStmt().m_rs.getMetaData(); 47 columnCount = rsMetaData.getColumnCount(); 48 } 49 catch (SQLException e) 50 { 51 throw new PersistenceBrokerException(e); 52 } 53 } 54 55 60 protected Object getObjectFromResultSet() throws PersistenceBrokerException 61 { 62 Object [] result = new Object [columnCount]; 63 for (int i = 0; i < columnCount; i++) 64 { 65 try 66 { 67 int jdbcType = rsMetaData.getColumnType(i + 1); 68 Object item = JdbcTypesHelper.getObjectFromColumn(getRsAndStmt().m_rs, new Integer (jdbcType), i + 1); 69 result[i] = item; 70 } 71 catch (SQLException e) 72 { 73 throw new PersistenceBrokerException(e); 74 } 75 } 76 return result; 77 } 78 79 } 80 | Popular Tags |