Jump to content
Changes to the Jaspersoft community edition download ×

how combine two result set into one,


asa_nka

Recommended Posts

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

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...