Skip to Content
author's profile photo Former Member
Former Member

Can't get JRC to connect to Oracle DB

We just purchased Crystal Reports XI R2 and I'm trying to get a JSP page to connect via JRC to a Crystal Report that connects to an Oracle Database. I keep getting a "JNDI not found" error, when I'm not even trying to use JNDI. I just want to make a plain JDBC connection via JRC to my report and have it display. I've been working for three days trying to configure this and it's hopelessly difficult. My report I'm calling, runs fine within Crystal XI and uses a JDBC connection to my Oracle datasource. Here's a snippet of my JSP code:

ReportClientDocument reportClientDoc = new ReportClientDocument();

reportClientDoc.open(REPORT_NAME, 0);
reportSource = reportClientDoc.getReportSource();
session.setAttribute("reportSource", reportSource);
Fields oFields = new Fields();
Date fromDate = new Date((String)session.getAttribute("fromDate"));
Date toDate = new Date((String)session.getAttribute("toDate"));
setDiscreteParameterValue(oFields, "FROM_DATE", "", fromDate);
setDiscreteParameterValue(oFields, "TO_DATE", "", toDate);
session.setAttribute("parameterFields", oFields);
ConnectionInfos oConnectionInfos = new ConnectionInfos();
IConnectionInfo oIconnectionInfo = new ConnectionInfo();
PropertyBag propertyBag = new PropertyBag();

// Overwrite any existing properties with updated values
propertyBag.put("Database Class Name", "oracle.jdbc.driver.OracleDriver");
propertyBag.put("Connection URL", "jdbc:oracle:thin:@pabaix07:1521:D007");

PropertyBag bag = new PropertyBag();
bag.put(PropertyBagHelper.CONNINFO_CRQE_LOGONPROPERTIES, propertyBag);
bag.put(PropertyBagHelper.CONNINFO_DATABASE_DLL, "crdb_jdbc.dll");
oIconnectionInfo.setUserName("CSPUSER");
oIconnectionInfo.setPassword("CSPUSER1");
oIconnectionInfo.setAttributes(bag);
oConnectionInfos.add(oIconnectionInfo);
session.setAttribute("oConnectionInfos", oConnectionInfos);
response.sendRedirect(request.getContextPath() + "/jsp/CrystalReportViewer.jsp");

And here's my display code from my CrystalReportViewer.jsp file:

IReportSource reportSource = (IReportSource)session.getAttribute("reportSource");
viewer.setReportSource(reportSource);
viewer.setOwnPage(true);
viewer.setOwnForm(true);
viewer.setPrintMode(CrPrintMode.ACTIVEX);
viewer.setPrintMode(CrPrintMode.PDF);
Fields parameterFields = (Fields)session.getAttribute("parameterFields");
viewer.setParameterFields(parameterFields);
ConnectionInfos connections = (ConnectionInfos)session.getAttribute("oConnectionInfos");
viewer.setDatabaseLogonInfos(connections);
if (session.getAttribute("refreshed") == null)
{
viewer.refresh();
session.setAttribute("refreshed", "true");
}
} catch (Exception e)
{
e.printStackTrace(System.out);
}
viewer.processHttpRequest(request, response, getServletConfig().getServletContext(), null);

Any help would be greatly greatly greatly appreciated!!

MIke Brubaker

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Posted on Feb 03, 2007 at 12:30 PM

    By the error message that you are receiving it sounds like the report was originally designed to use an ODBC or native connection. The JRC will automatically attempt to look for a JNDI name of the same data source when it encounters one of these types of data sources.

    If this is the case then you cannot use the viewer object to pass in the ConnectionInfos. The viewer object can only be used to login to the same data source, not change the location.

    What you need to do is follow the code snippet included in the following sample:

    http://diamond.businessobjects.com/files/jrc_change_database_connection_0.zip

    That should help you out.

    Regards,
    Sean Johnson (CR4E Product Manager)

    Rate" target="_blank">http://www.eclipseplugincentral.com/Web_Links-index-req-ratelink-lid-639.html">Rate this plugin @ Eclipse Plugin Central

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Well, I tried your example code and when it gets to the line:

      Â Â Â Â Â Â Â Â Â Â Â Â databaseController.setTableLocation(table, tables.getTable(i));
      Â

      I throws this exception:

      com.crystaldecisions.sdk.occa.report.lib.ReportSDKException: Logon Error: invalid arguments in call---- Error code:-2147467259 Error code name:failed

      Do I need any kind of configuration information in any of my XML files(Web.xml, Context.xml, etc. etc.)? My report has a JDBC datasource defined within the report itself, not an ODBC source. And if I don't use any database calls, the JRC prompts me for username/password and it displays fine. I'm just trying to get rid of the prompting for user/password and have it log on automatically for me behind the scenes. Any other suggestions?

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.