Jump to content

Can we use javax.sql.DataSource instead of java.sql.connection in JasperPrint() call


priyankdev

Recommended Posts

Hi,

I am making a call to jrxml to generate report like this

            JasperReport jasperReport = JasperCompileManager.compileReport(reportSource);
            JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, paramSMap, conn);   

But I have to create the conn object using

conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/mydb", connectionProps);

The thing is at other pages I use the Datasource object which we have specified in our DataSource.groovy , like:

 javax.sql.DataSource dataSource

def myappsql = new Sql(dataSource)

myappsql.rows(queryString)

So I need to reuse the datasource so that I donot need to create the connection object with all the url, userid and pwd values specially in the reportsservice page as we need to remove all hardcoded sql connections from each file

 

Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

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...