2001 JI Open Discussion Posted August 14, 2006 Share Posted August 14, 2006 By: zhangyuxiang - zhangyuxang JRResultSetDataSource read data error, help!! 2002-06-04 19:09Result set columns within each row should be read in left-to-right order, but my jasper read column random, so there is a sql exception. Can any one tell me why? By: Teodor Danciu - teodord RE: JRResultSetDataSource read data error, help!! 2002-06-05 01:03 Hi, In the API documentation for the ResultSet interface, they say: "For maximum portability, result set columns within each row should be read in left-to-right order, and each column should be read only once." The provided JRResultSetDataSource implementation does not follow this recommendation and retrieves the fields values in no particular order and repeatedly. A solution would be to create a different implementation of this class or to improve it such as that it would read all the fields values in the correct order and only once and keep them in some sort of a cache to supply them from there when required. It is not too difficult to do that. I'll consider it for a future version. Thank you, Teodor By: zhangyuxiang - zhangyuxang RE: JRResultSetDataSource read data error, he 2002-06-05 19:32HI. Thanks. I have create a implementation of JRDatasource to solve this problem. Does JasperReprt will support JDK1.4? By: zhangyuxiang - zhangyuxang Another way fix this problem 2002-06-05 23:15Modify JRBaseFiller.java can fix this problem. public JasperPrint fill( Map parameters, Connection conn ) throws JRException { if (parameters == null) { parameters = new HashMap(); } parameters.put("REPORT_CONNECTION", conn); ResultSet rs =JRQueryExecuter.executeQuery( query, parametersMap, parameters, conn ); //add these code to sort fields try{ java.sql.ResultSetMetaData meta = rs.getMetaData(); JRFillField[] newFields = new JRFillField[fields.length]; for(int i=0; i<meta.getColumnCount(); i++){ for(int m=0; m<fields.length; m++){ if(fields[m].getName().equals(meta.getColumnName(i+1))) newFields = fields[m]; } } fields = newFields; } catch(SQLException exception){ throw new JRException("Error sort fileds : " + name, exception); } //end modify code JRDataSource ds = new JRResultSetDataSource(rs); JasperPrint jasperPrint = this.fill(parameters, ds); try { rs.close(); } catch (SQLException e) { throw new JRException("Error closing ResultSet for report data source : " + name, e); } return jasperPrint; } By: Teodor Danciu - teodord JDK 1.4 2002-06-05 23:59 Hi, JasperReports already supports JDK1.4 as far as I have tested it. Thanks, Teodor Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now