title: Java Connection String - Embedding pentaho Report Engine in Java Aplication
body: <p>I'm having difficulty connecting to a db2 database in my java application.  I have found some examples online but have been unable to apply them successfully being new to java.  My attempt is below.  Basically my program simply extracts data from the database within the datafactory method then produces an html report.</p>
  
  <pre><code>package org.pentaho.reporting.engine.classic.samples;
  
  import java.io.File;
  import java.io.IOException;
  import java.util.Map;
  
  import org.pentaho.reporting.engine.classic.core.DataFactory;
  import org.pentaho.reporting.engine.classic.core.MasterReport;
  import org.pentaho.reporting.engine.classic.core.ReportProcessingException;
  import org.pentaho.reporting.engine.classic.core.PageDefinition;
  import org.pentaho.reporting.engine.classic.core.wizard.RelationalAutoGeneratorPreProcessor;
  import org.pentaho.reporting.engine.classic.core.modules.misc.datafactory.sql.SQLReportDataFactory;
  import org.pentaho.reporting.engine.classic.core.modules.misc.datafactory.sql.DriverConnectionProvider;
  
  public class report2013HTML extends AbstractReportGenerator
  {
    private static final String QUERY_NAME = "ReportQuery";
  
    /**
     * Default constructor for this sample report generator
     */
    public report2013HTML()
    {
    }  
      * @return the loaded and parsed report definition to be used in report generation.
         */
        public MasterReport getReportDefinition()
        {
          final MasterReport report = new MasterReport();
          report.setQuery(QUERY_NAME);
          report.addPreProcessor(new RelationalAutoGeneratorPreProcessor());
          return report;
        }
  
            public DataFactory getDataFactory()
            {
              final DriverConnectionProvider sampleDriverConnectionProvider = new DriverConnectionProvider();
              sampleDriverConnectionProvider.setDriver("com.ibm.db2.jcc.DB2Driver");
              sampleDriverConnectionProvider.setUrl("jdbc:db2://hostname:1000/database");
              sampleDriverConnectionProvider.setProperty("user", "user");
              sampleDriverConnectionProvider.setProperty("password", "pass");
  
              final SQLReportDataFactory dataFactory = new SQLReportDataFactory(sampleDriverConnectionProvider);
              dataFactory.setQuery(QUERY_NAME,
                  "select project_name FROM fact_table");
  
              return dataFactory;
            }
  </code></pre>
  
  <p>After that there is one last method that produces the HTML file.  I'm getting a report processed failed error among some connectivity errors obviously.</p>
  
  <pre><code>    Exception in thread "main" org.pentaho.reporting.engine.classic.core.ReportProcessingException: Unable to initialize the report
      at org.pentaho.reporting.engine.classic.core.layout.output.AbstractReportProcessor.prepareReportProcessing(AbstractReportProcessor.java:563)
      at org.pentaho.reporting.engine.classic.core.layout.output.AbstractReportProcessor.processReport(AbstractReportProcessor.java:1412)
      at org.pentaho.reporting.engine.classic.samples.AbstractReportGenerator.generateReport(AbstractReportGenerator.java:218)
      at org.pentaho.reporting.engine.classic.samples.AbstractReportGenerator.generateReport(AbstractReportGenerator.java:128)
      at org.pentaho.reporting.engine.classic.samples.mira2013HTML.main(mira2013HTML.java:103)
  ParentException: 
  org.pentaho.reporting.engine.classic.core.ReportDataFactoryException: Failed at query: select project_name FROM fact_table
      at org.pentaho.reporting.engine.classic.core.modules.misc.datafactory.sql.SimpleSQLReportDataFactory.queryData(SimpleSQLReportDataFactory.java:270)
      at org.pentaho.reporting.engine.classic.core.modules.misc.datafactory.sql.SQLReportDataFactory.queryData(SQLReportDataFactory.java:95)
      at org.pentaho.reporting.engine.classic.core.states.CachingDataFactory.queryInternal(CachingDataFactory.java:176)
      at org.pentaho.reporting.engine.classic.core.states.CachingDataFactory.queryData(CachingDataFactory.java:144)
      at org.pentaho.reporting.engine.classic.core.states.CascadingDataFactory.queryData(CascadingDataFactory.java:110)
      at org.pentaho.reporting.engine.classic.core.states.datarow.ReportDataRow.createDataRow(ReportDataRow.java:97)
      at org.pentaho.reporting.engine.classic.core.states.datarow.DefaultFlowController.performQuery(DefaultFlowController.java:189)
      at org.pentaho.reporting.engine.classic.core.states.process.ProcessState.&lt;init&gt;(ProcessState.java:279)
      at org.pentaho.reporting.engine.classic.core.layout.output.AbstractReportProcessor.prepareReportProcessing(AbstractReportProcessor.java:463)
      at org.pentaho.reporting.engine.classic.core.layout.output.AbstractReportProcessor.processReport(AbstractReportProcessor.java:1412)
      at org.pentaho.reporting.engine.classic.samples.AbstractReportGenerator.generateReport(AbstractReportGenerator.java:218)
      at org.pentaho.reporting.engine.classic.samples.AbstractReportGenerator.generateReport(AbstractReportGenerator.java:128)
      at org.pentaho.reporting.engine.classic.samples.report2013HTML.main(report2013HTML.java:103)
  ParentException: 
  java.sql.SQLException: Unable to load the driver: com.ibm.db2.jcc.DB2Driver
      at org.pentaho.reporting.engine.classic.core.modules.misc.datafactory.sql.DriverConnectionProvider.createConnection(DriverConnectionProvider.java:102)
      at org.pentaho.reporting.engine.classic.core.modules.misc.datafactory.sql.SimpleSQLReportDataFactory.getConnection(SimpleSQLReportDataFactory.java:184)
      at org.pentaho.reporting.engine.classic.core.modules.misc.datafactory.sql.SimpleSQLReportDataFactory.queryData(SimpleSQLReportDataFactory.java:255)
      at org.pentaho.reporting.engine.classic.core.modules.misc.datafactory.sql.SQLReportDataFactory.queryData(SQLReportDataFactory.java:95)
      at org.pentaho.reporting.engine.classic.core.states.CachingDataFactory.queryInternal(CachingDataFactory.java:176)
      at org.pentaho.reporting.engine.classic.core.states.CachingDataFactory.queryData(CachingDataFactory.java:144)
      at org.pentaho.reporting.engine.classic.core.states.CascadingDataFactory.queryData(CascadingDataFactory.java:110)
      at org.pentaho.reporting.engine.classic.core.states.datarow.ReportDataRow.createDataRow(ReportDataRow.java:97)
      at org.pentaho.reporting.engine.classic.core.states.datarow.DefaultFlowController.performQuery(DefaultFlowController.java:189)
      at org.pentaho.reporting.engine.classic.core.states.process.ProcessState.&lt;init&gt;(ProcessState.java:279)
      at org.pentaho.reporting.engine.classic.core.layout.output.AbstractReportProcessor.prepareReportProcessing(AbstractReportProcessor.java:463)
      at org.pentaho.reporting.engine.classic.core.layout.output.AbstractReportProcessor.processReport(AbstractReportProcessor.java:1412)
      at org.pentaho.reporting.engine.classic.samples.AbstractReportGenerator.generateReport(AbstractReportGenerator.java:218)
      at org.pentaho.reporting.engine.classic.samples.AbstractReportGenerator.generateReport(AbstractReportGenerator.java:128)
      at org.pentaho.reporting.engine.classic.samples.report2013HTML.main(report_HTML.java:103)
  </code></pre>