Jump to content
Changes to the Jaspersoft community edition download ×

retrieve datasource problem..?

Recommended Posts

By: mubasyir ahmad anwar - mubasyir

retrieve datasource problem..?

2003-07-29 02:43



I already run webapp samples and it works...


But please somebody explain me how datasource in

demo/samples/webapp/WEB_INF/classes/datasource work...?(Why we don't have to call it from jdbc)


Because i need to create new datasource from my own database,


Is it any way to make connection with our database in order to run in webapp?











By: David Hardwick - dhardwick

RE: retrieve datasource problem..?

2003-07-29 07:25

That's just an example of running a custom Datasource. You can see how much easier it is for T to use that as an out-of-the-box example then it would be to actually connect to a datasource from within the Application Server. Even if he use the free database he uses, that would still require the additional step of adding that driver to the correct class path for the Application Server.


All you need to do is implement javax.sql.Connection object (i'm sure you'll be grabbing that from your database pool that is managed by the Application Server) and pass that to reference into the JasperRunManager method call instead of the customer datasource.


Here's my example (without all the try/catch blocks) using a connction from the connection pool that I setup in JRun:




Connection conn = null;


String dataSource = Constants.DATA_SOURCE;


InitialContext ctx = new InitialContext();


DataSource ds = (DataSource)ctx.lookup (Constants.JNDI_JDBC_PATH + dataSource);


conn = ds.getConnection();


bytes = JasperRunManager.runReportToPdf

(reportFile.getPath(), parameters, conn );



Link to comment
Share on other sites

  • Replies 0
  • 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...