Crystal Reports for Eclipse Developer Guide

Creating a Java class that specifies a custom data source

To use a JavaBean (or a Java class that does not extend the bean type) to specify a custom data source, you need to create a class that serves as a Java Beans Connectivity data source for creating Crystal reports.
This class needs to conform to the JavaBean standard by defining private properties that are accessible only through get and set methods. In this way, Crystal Reports can introspect the class as a Bean. The JavaBean connectivity classes require the following:
  • The constructor must have no parameters.
  • Methods that are used as "tables" must have a return type of ResultSet.
  • Statement objects must be created using the ResultSet.TYPE_SCROLL_SENSITIVE and ResultSet.CONCUR_READ_ONLY arguments.

Note: Methods returning ResultSet can take arguments. These arguments are treated as Stored Procedure parameters by Crystal Reports.
Example: 
The example below is a class that serves as a Java Beans Connectivity data source for creating Crystal reports. The Xtreme Sample Database 10 sample database is used in the DSN as the data source connection.
import java.sql.*;

public class JavaBeanConnectivityTest
{
	private Connection m_Connection;
	private ResultSet m_CustomerResultSet;

	public JavaBeanConnectivityTest() throws Exception
	{
		Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
		String sJdbcURL = "jdbc:odbc:Xtreme Sample Database 10";
		m_Connection = DriverManager.getConnection(sJdbcURL);
	}
	
	public Connection getConnection()
	{
		return m_Connection;
	}
	
	public ResultSet getCustomerResultSet() throws SQLException
	{
		Statement oStatement;
		String sQuery;
		
		sQuery = "Select [Customer ID], [Customer Name], [Last Year's Sales] from Customer";
	
		oStatement = m_Connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);
		m_CustomerResultSet = oStatement.executeQuery(sQuery);
		
		return m_CustomerResultSet;
	public void setCustomerResultSet(java.sql.ResultSet newResultSet)
	{
		m_CustomerResultSet = newResultSet;
	}
	
	public void setOrdersResultSet(ResultSet newResultSet)
	{
		m_OrdersResultSet = newResultSet;
	}
}



SAP BusinessObjects
http://www.sap.com/sapbusinessobjects/
Support services
http://service.sap.com/bosap-support/
Product Documentation on the Web
http://help.sap.com/