retrieve datasource problem..?

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 );

2002 JI Open Discussion's picture
Joined: Aug 10 2006 - 3:28am
Last seen: 16 years 9 months ago

0 Answers:

No answers yet