asa_nka Posted June 29, 2010 Share Posted June 29, 2010 i want 2 fill the jrxml using sql satement resultset & procdure call resultset, but how i can use only one Resultset objecet for JRResultSetDataSource jrResultSetDataSource= ........................wht should i do??Code:import net.sf.jasperreports.engine.*;import net.sf.jasperreports.engine.data.JRMapArrayDataSource;import net.sf.jasperreports.engine.data.JRMapCollectionDataSource;import java.sql.*;import java.util.*;import oracle.jdbc.driver.OracleTypes;public class testall { int id = 13647; java.sql.Date sDate = java.sql.Date.valueOf("2009-08-09"); java.sql.Date fDate = java.sql.Date.valueOf("2009-08-10"); int Decimals = 3; Connection connection = null; JRResultSetDataSource resultSetDataSource; public static void main(String args[]) throws SQLException { testall test = new testall(); test.connect(); ResultSet rs1 = test.excute(); ResultSet rs2 = test.port(); ArrayList<ResultSet> contaner = new ArrayList<ResultSet>(); test.genpdf(rs1,rs2); } public void connect() { try { Class.forName("oracle.jdbc.driver.OracleDriver"); connection = DriverManager.getConnection("jdbc:oracle:thin:@192.168.0.47:1521:MFS01", "MUBASHER_OMS", "password"); } catch (ClassNotFoundException classNotFoundException) { classNotFoundException.printStackTrace(); } catch (SQLException sqlException) { sqlException.printStackTrace(); } } public ResultSet excute() throws SQLException { ResultSet resultS = null; try { Statement statement = connection.createStatement(); try { String query = "select CustName,M01_C1_CUSTOMER_ID,T03_ACCOUNT_ID,u05_accountno,U05_PORTFOLIO_NAME " + "from M01_CUSTOMER_V7 " + "where M01_C1_CUSTOMER_ID='160526168'"; resultS = statement.executeQuery(query); } catch (SQLException e) { e.printStackTrace(); } } catch (Exception e) { System.out.println(e); } return resultS; } public ResultSet port() { ResultSet resultSet = null; try { String dataQuery = "{CALL t06_holdings_log_pkg.cust_statement(?,?,?,?,?) } "; CallableStatement cs = connection.prepareCall(dataQuery); cs.registerOutParameter(1, OracleTypes.CURSOR); cs.setInt(2, id); cs.setDate(3, sDate); cs.setDate(4, fDate); cs.setInt(5, Decimals); cs.execute(); resultSet = (ResultSet) cs.getObject(1); Statement statement = connection.createStatement(); try { resultSet.close(); } catch (SQLException e) { e.printStackTrace(); } } catch (SQLException sqlException) { sqlException.printStackTrace(); } return resultSet; } public void genpdf(ResultSet result1,ResultSet result2) { try { /*what 2 do in this */ JRResultSetDataSource resultSetDataSource = new JRResultSetDataSource(result1); JRResultSetDataSource resultSetDataSource1 = new JRResultSetDataSource(result2); JRResultSetDataSource resultSetDataSource2=resultSetDataSource; JRResultSetDataSource resultSetDataSource3=resultSetDataSource2; JasperReport jasperReport = JasperCompileManager.compileReport("src/resources/testall.jrxml"); JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, new HashMap(), resultSetDataSource3); JasperExportManager.exportReportToPdfFile(jasperPrint, "test.pdf"); } catch (JRException jrException) { jrException.printStackTrace(); } }} Link to comment Share on other sites More sharing options...
balajicrb Posted June 29, 2010 Share Posted June 29, 2010 Hi, You can create two sub reports in a report and each sub report can take one JRResultDataSource to fill.-- Balaji C R B Link to comment Share on other sites More sharing options...
asa_nka Posted June 29, 2010 Author Share Posted June 29, 2010 can giv me more info abt it, thanx Link to comment Share on other sites More sharing options...
balajicrb Posted June 29, 2010 Share Posted June 29, 2010 This thread can help you...http://www.jasperassistant.com/forum/topic/823/simple_subreport_example_using_several?p3 --Balaji CRB 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