1 Reply Latest reply on Jul 28, 2009 9:33 AM by Imran Ahamed Ahamed

    Coonection in jasper report

    Sudha Perumal Newbie
      Hi, I have to pass Connection to generate Jasper report...

      So that
      I used
      //Connection dcCon= DriverManager.getConnection("jdbc:mysql://localhost:3306/hrms","root","root");
      it's working...

      But I'm already setting database connection Seam-gen.properties file..
      How to get connection from this?

      Please Help me?
        • 1. Re: Coonection in jasper report
          Imran Ahamed Ahamed Newbie
          public class DataSourceService {

          private Connection con =null;
          public DataSourceService() {  }

          public DataSource getDataSource() throws NamingException, SQLException {

            InitialContext ic = new InitialContext();
            DataSource ds = (DataSource) ic.lookup("java:/crsDatasource");
            System.out.println("Getting datasource...."+ds);
            return ds;

          public Connection getConnection() throws Exception {
                DataSource ds = this.getDataSource();
                try {
                    con = ds.getConnection();
                 } catch (Exception e) {
                  return con;


          protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
            Connection connection=null;
            OutputStream ouputStream = response.getOutputStream();
            try {
               try {
                  connection = d.getConnection();
                  } catch (Exception e) {
                    // TODO Auto-generated catch block