SAP Knowledge Base Article - Public

1527666 - How to connect to a database using a JDBC connection in Crystal Reports? [Video]

Symptom

  • How to configure a JDBC connection?
  • How to create a report using a JDBC connection in Crystal Reports?
  • How to connect to a database via a JDBC Connection in Crystal Reports?
  • How to configure the crconfig.xml file to connect to a database using a JDBC connection, in Crystal Reports?
        
        
  • Note: Images, video, and data in this SAP Knowledge Base Article is from SAP internal systems, sample data, or demo systems. Any resemblance to real data is purely coincidental.

Environment

  • SAP Crystal Reports 2013
  • SAP Crystal Reports 2016
  • SAP Crystal Reports 2020

Resolution

  • To connect to a database using a JDBC connection in Crystal Reports:
       
    1. First confirm a JDBC connection to your database is supported for the version of Crystal Reports used, by looking at the Supported Platforms document:
          
           2859510 - Supported Platforms documents for Crystal Reports
              
         
    2. Download a supported JDBC driver from your database vendor website.
         
         
    3. Install the JDBC driver to the default path, or copy the JDBC driver .jar file to a folder of your choice. For example:
        
          C:\Database Name\JDBC Driver
        
         
    4. Add the path of the JDBC driver .jar file, to the classpath of the Crystal Reports configuration file: crconfig.xml: 
        
      1. 4.1 Navigate to the following folder:  

                 C:\Program Files (x86)\SAP BusinessObjects\SAP BusinessObjects Enterprise XI 4.0\java

             Note: This is the default installation folder, if you installed Crystal Reports in a custom location, the start of the path will be different.
               
      2. 4.2 Open in a Text Editor the file: crconfig.xml
          
      3. 4.3 Under the section: <DataDriverCommon>, add the path and the name of the JDBC .jar file to the section: <Classpath>  

             <DataDriverCommon>
                  <JavaDir32>C:\Program Files (x86)\SAP BusinessObjects\SAP BusinessObjects Enterprise XI 4.0\win32_x86\sapjvm/bin</JavaDir32>
                  <JavaDir64>C:\Program Files (x86)\SAP BusinessObjects\SAP BusinessObjects Enterprise XI 4.0\win64_x64\sapjvm\bin</JavaDir64>
                  <Classpath><INSERT YOUR .JAR FILE PATH & NAME HERE>;C:\Program Files (x86)\MS SQL Server JDBC Driver\sqljdbc_6.0\sqljdbc42.jar</Classpath>
                  <UseProxy>FALSE</UseProxy>
                  <ProxyAddress></ProxyAddress>
                  <ProxyPort></ProxyPort>
             </DataDriverCommon>

           
             For example:

             If the JDBC Driver .jar file for your database is: DatabaseJDBC.jar 
             and it is located in: 
        C:\Database Name\JDBC Driver  
             Then add the path and .jar file to the Classpath section, like:

            <DataDriverCommon>
                  <JavaDir32>C:\Program Files (x86)\SAP BusinessObjects\SAP BusinessObjects Enterprise XI 4.0\win32_x86\sapjvm/bin</JavaDir32>
                  <JavaDir64>C:\Program Files (x86)\SAP BusinessObjects\SAP BusinessObjects Enterprise XI 4.0\win64_x64\sapjvm\bin</JavaDir64>
                  <Classpath>C:\Database Name\JDBC Driver\DatabaseJDBC.jar;C:\Program Files (x86)\MS SQL Server JDBC Driver\sqljdbc_6.0\sqljdbc42.jar</Classpath>
                  <UseProxy>FALSE</UseProxy>
                  <ProxyAddress></ProxyAddress>
                  <ProxyPort></ProxyPort>
             </DataDriverCommon>
          

      4. 4.4 Save the change made in the file: crconfig.xml
          
          
    5. Start Crystal Reports, and create a new report.   ( Under the menu "File" select "New – Blank Report" )
          
        
    6. In the "Database Expert", under "Create New Connection", double click on: JDBC (JNDI)
       
          
    7. In the JDBC (JNDI) window, enter the following information, corresponding to the database and JDBC driver used.
      - Connection URL
      - Database Classname

      Important Note: Consult your Database documentation, or Database Administrator to obtain the Connection URL, and Database Classname.

      For you convenence, the following table contains connection URL for different database: 

      Database Name Connection URL Database Classname
      ODBC jdbc:odbc:DSN-name sun.jdbc.odbc.JdbcOdbcDriver
      Oracle jdbc:oracle:thin:@<server-name>:[port]:<service-name> oracle.jdbc.driver.OracleDriver
      SQL Server 2008     jdbc:sqlserver://<server-name>:[port] com.microsoft.sqlserver.jdbc.SQLServerDriver
      Derby jdbc:derby:/test;create=true org.apache.derby.jdbc.EmbeddedDriver
      DB2 jdbc:db2://<server-name>:<port-number>/<database_name>

      com.ibm.db2.jcc.DB2Driver

      MySQL jdbc:mysql://<server_name>:[port]/<database_name> com.mysql.jdbc.Driver
      Informix jdbc:informix-sqli://<server-name>:<port-numer>/<database-name>:INFORMIXSERVER=MyServerName com.informix.jdbc.IfxDriver
      Sybase jdbc:datadirect:sybase://<server-name>:<port-number>; databaseName=name com.ddtek.jdbc.sybase.SybaseDriver
      Sybase TDS

      jdbc:sybase:Tds:<server_name>:<port>?ServiceName=<TDS service name>

      com.sybase.jdbc4.jdbc.SybDriver

      PostgreSQL

      jdbc:postgresql://<server-name>:[port]/<database_name>

      org.postgresql.Driver


          
        
    8. Click Next, and enter your database user name and password.

 

  • Video demonstrating how to create a JDBC connection to a database in Crystal Reports:

Media not computed.

Keywords

Crystal Reports, XI R2/XI, JDBC Connectivity, JRC, CRJ, JDBC Connection, CR, Crystal Reports 2011, Crystal Reports 2013, Connection U , KBA , BI-RA-CR , Crystal Reports designer or Business View Manager , How To

Product

SAP Crystal Reports 2013 ; SAP Crystal Reports 2016 ; SAP Crystal Reports 2020