Jump to content
We've recently updated our Privacy Statement, available here ×
  • This documentation is an older version of JasperReports Server Administration Guide. View the latest documentation.

    Working With Data Sources

    When adding a data source to JasperReports Server, several things can cause errors. Start by looking at the following general connectivity issues:

    Check that your database server is available and accepting TCP/IP connections from the host where JasperReports Server is installed.
    Check in your RDBMS that the username and password you're using are correct and have access to the selected database.
    Check for firewalls or network connectivity errors.

    Many databases, including MySQL, also require the user grants to include the specific host from which connections are allowed. Otherwise, when testing the JDBC connection, a connection may not be allowed even though the username and password are correct. For more information, refer to the MySQL documentation for setting up users.

    An easy way to test connectivity from the server to the database with a particular user is to use a tool such as SQuirreL or another DB query tool to connect to the database from the host of your JasperReports Server instance.

    Logging JDBC Operations

    You can enable additional logging to help you find the cause of the error. Set any or all of the following loggers in the server settings interface or in the .../WEB-INF/log4j.properties file:


    JDBC Drivers

    As of JasperReports Server 5.1, JDBC driver management is automated and simplified. JasperReports Server ships with drivers for some databases, as listed in the dialog for creating data sources. If the JDBC driver for your database is not included, the system administrator can easily upload the driver and use it immediately in a data source.

    For instructions on updating JDBC drivers without restarting the server, see Managing JDBC Drivers. For instructions on adding JDBC drivers when using JBoss, see the next section.

    JDBC Drivers on JBoss

    For modularity reasons, the JBoss application server does not allow web applications such as JasperReports Server to change executable files, such as JDBC drivers, on the fly. In order for JDBC drivers to appear in the list of available drivers and be selectable, you must configure JBoss before you use the drivers to create a JDBC data source.

    To add JDBC drivers on JBoss:

    1. Download or copy the JDBC driver JAR file to the .../WEB-INF/lib/ directory.
    2. Edit the jboss-deployment-structure.xml file as described in the following table:

    Configuring JBoss for JDBC drivers

    Configuration File




    resource-root path="<driver>.jar"

    Locate the resource root element for the JDBC driver you added and uncomment it. The name of the JAR file must match exactly the name of the JDBC driver that you upload. You can add a new resource root element if the JDBC driver of your choice is not given in the commented list.

    3. Restart JBoss.

    Database Permissions

    When creating database users, you must ensure that they have the appropriate privileges to access data, as well as permission to connect from the server that JasperReports Server is running on.

    The database user that you specify in your data source definition should have the appropriate select permissions to query the tables within your database for the reports you want to generate.
    If you accept the defaults during installation of JasperReports Server on Linux from an RPM using apt-get, rpm, or yum, the bundled PostgreSQL allows only the user who owns PostgreSQL to connect. Enter the following commands to connect:
    Many databases, including MySQL, also require that the user permissions name the specific host from which connections are allowed. Otherwise, when testing the JDBC connection, a connection may not be allowed even though the user name and password are correct. For example, see the MySQL documentation for setting up users.

    A fairly easy way to test permissions and connectivity is to use a tool such as SquirrelSQL or another DB query tool to connect to the database from the same host as JasperReports Server and to run typical queries against your database.

    JDBC Database URLs

    When you choose a JDBC driver, the data source creation wizard prompts you for the elements of the URL that are required for your database. In some cases, you may need to add certain arguments to the JDBC URL. Ensure that the database URL you entered when defining your JDBC data source is consistent with what is required for your specific database and database driver. The following table gives the default URLs and port numbers and examples of optional arguments supported by the most common databases:


    Default JDBC Database URL



    MySQL and MariaDB






    SQL Server


    SQL Server jTDS driver










    SQL Functions with TIBCO JDBC Drivers

    As of JasperReports Server 5.6.1, TIBCO provides a set of JDBC drivers in the installed server. The TIBCO JDBC drivers are based on the Progress DataDirect Connect drivers and support a slightly different SQL syntax than the vendors' drivers. If you see errors like the one below when running reports or creating domains that use scalar functions, you'll need to modify your queries.

    For example, the following query does not work with the TIBCO JDBC drivers:

    The correct syntax for the TIBCO JDBC drivers is as follows:

    For more information, see the Progress DataDirect page on scalar functions.

    Salesforce JDBC Driver

    As of JasperReports Server 6.2.1, you can upload a Salesforce JDBC driver to create a Salesforce data source. Before installing the driver, you need to perform the following steps:

    1. Go to the <js_install>/buildomatic/tools directory and copy the TIsforce-5.14.jar file.


    For tomcat 7 and tc Server 2.9 users, copy the zzuTIsforce-5.14.jar file.

    2. Change to the <js_install>/WEB-INF/lib directory and paste the file.
    3. Restart the server.


    This driver is currently not supported on WebSphere Application Server and WebLogic.

    JNDI Services on Apache Tomcat

    If you have trouble with a JNDI connection, you need to look at the JNDI definition for your database on your application server. This section gives common issues with JNDI definitions on Apache Tomcat connecting to MySQL. If you use a different application server or database server, refer to its documentation.

    A JNDI connection on Tomcat is defined in two different files. Make sure both have the following information:


    Also check the following points:

    Ensure the driver for your database connection is in the <tomcat>/lib folder.
    If you installed JasperReports Server from a WAR file, Tomcat may have created a separate copy of context.xml in <tomcat>/conf/Catalina/Localhost/jasperserver-pro.xml. See the corresponding section in the troubleshooting appendix of the JasperReports Server Installation Guide.
    See the Apache Tomcat documentation for JNDI data sources.
    For Oracle databases, you may need to specify additional parameters in the context.xml file. For example, in order to support in Oracle, add the following line:

    JNDI Services on JBoss

    After defining JNDI Services on the JBoss application server, JasperReports Server does not automatically detect the new services. To use the new JNDI services as data sources in the server, follow these steps:

    1. Define and deploy a JNDI data source in the JBoss administrator console.
    2. Modify the file <jboss>/webapps/jasperserver-pro/WEB-INF/web.xml to include a data source reference to this new JNDI service.
    3. Modify jboss-web.xml to include a reference to this data source.
    4. Because the deployment configuration files such as web.xml were modified, redeploy the JasperReports Server application.

    Now you can define JNDI data source in the repository, as described in JNDI Data Sources.

    JNDI Services on WebLogic

    Follow these steps to configure JasperReports Server to use JNDI data sources with WebLogic:

    1. Append the following definition to the <reference-descriptor> node of .../WEB-INF/weblogic.xml:
    2. Append the following definition to .../WEB-INF/web.xml:
    3. In the WebLogic Admin Console, add a data source with TestDatabase as the JNDI name.
    4. Restart the jasperserver-pro instance using the WebLogic Admin Console.

    Creating a Data Source on SQL Server Using Windows Authentication

    If your database is Microsoft SQL Server and you use Windows Authentication (also called Integrated Security), use the following procedure to create a data source.

    1. Go to the download page for Microsoft SQL Server JDBC Driver 3.0.

    Do not use version 4.0 of this driver; it will not work.

    2. Download and run the self-extracting executable: 1033sqljdbc_3.0.1301.101_enu.exe
    3. Open the extracted folder sqljdbc_3.0enuauth, and then either the x64 or the x86 subfolder, depending on whether your version of Windows is 64-bit or 32-bit, respectively.
    4. Copy the file sqljdbc_auth.dll to the folder your app server automatically searches for DLLs.

    For Tomcat, this is the <tomcat>bin folder.

    5. Restart your app server.
    6. Log into JasperReports Server as and administrator.
    7. Select Create > Data Source from the main menu.
    8. In the Type field, select JDBC Data Source. The page refreshes to show the fields necessary for a JDBC data source.
    9. Enter a name and optional description for your data source.
    10. From the dropdown field, select com.microsoft.sqlserver.jdbc.SQLServerDriver.
    11. Enter the database hostname and database name of your SQL Server instance.
    12. In the URL field, add the following string to the end of the generated URL:


    13. In the User Name field, enter any non-blank string you want, for example none.
    14. In the Password field, enter any non-blank string you want, for example none.
    15. Set the Time Zone and Save Location fields if necessary.
    16. Click Test Connection and verify that the connection works.
    17. Click Save to save the data source in the repository.

    Upgrading Bean Data Sources

    There was a change in the Spring configuration for JasperReports Server 6.0 which changes how some of the existing Spring beans are made accessible for use by other beans. This can break existing custom data sources. This change specifically affects beans which implement the interface ReportDataSourceServiceFactory.

    Prior to release 6.0, if code in JasperReports Server accessed a bean of this type, it would get the actual instance of the Spring bean as configured in the Spring XML file, and it could be cast to the concrete class. In 6.0 and later, these beans were intercepted in order to implement the profile attributes feature, and instead of seeing the actual instance, other code would see a dynamic proxy instead of the actual bean.

    Dynamic proxies are a Java feature which allows classes to be generated at run time that implement any interface that can be loaded on the classpath. The resulting object can be cast to any of those interfaces, but doesn't correspond to any concrete class. For more information:


    Since proxies can only represent interfaces, existing code that tries to cast the bean to a concrete class will break. Casting is usually done to get access to methods on a more specific class or interface. As long as the code is not casting the bean to a concrete class, it will work, so there are two ways to get around this problem:

    If the code needs to access methods on an existing interface, just do a cast to that interface, or inject the property using the existing interface, so no cast is needed.
    If the code needs to access methods that are not on an existing interface, simply create an interface with the methods needed, and have the target object implement that interface.

    For example, let's say you have a bean with id myBean that needs to access the jdbcDataSourceServiceFactory, configured as follows:

    Where myBean has the following Spring configuration:

    The following code worked before but will now cause an error:

    Because the first call is a method which is part of the ReportDataSourceServiceFactory, the cast is unnecessary; to fix it, just leave it out:

    In this example, JdbcReportDataSourceServiceFactory has a method called doSomethingElse(). This method is not part of any interface, but you can create an interface that includes it:

    JdbcReportDataSourceServiceFactory would need modification so that itimplements this new interface:

    You don't have to change the declaration in MyBean because Spring will generate a dynamic proxy implementing MyDSSF, but if you change the declaration, the code will be easier to understand because no casts will be necessary:

    SQLFeatureNotSupportedException Using TIBCO Drivers

    When you use the TIBCO driver to connect to any database onWebSphere 7 or 8.5, you may see errors such as the following after a query, for examplein the Ad Hoc editor. The query still performs correctly:

    This is a known error with the WebSphere Adapter(RRA) component. The error message appears in the log file, but it has no impact on functionality. The fix is currently targeted for inclusion in WAS fix pack Please refer to IBM's Recommended Fixes for WebSphere Application Server page for delivery information.

    User Feedback

    Recommended Comments

    There are no comments to display.

    This is now closed for further comments

  • Create New...