ProcedureTo add a JNDI connection to a MySQL DB in Tomcat application server for TIBCO JasperReports® Server web application to use, please do the following: | [toc] |
Add a resource entry to JasperReports Server Context configuration file ( jasperserver-proMETA-INFcontext.xml ). For example:
<Resource name="jdbc/mysqldbname" auth="Container" type="javax.sql.DataSource" maxActive="100" maxIdle="30" maxWait="10000" username="jasperdb" password="password" driverClassName="com.mysql.jdbc.Driver" validationQuery="select 1" testOnBorrow="true" url="jdbc:mysql://127.0.0.1:3306/<database_name>?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&autoReconnectForPools=true" />
The driver class name above is for the standard MySQL Driver. JasperReports Server v5.5 now ships with the Mariadb client, "org.mariadb.jdbc.Driver".
Add a reference in JasperReports Server web configuration (jasperserver-proWEB-INFweb.xml file) to the newly created JNDI entry to make it available to the web application:
<resource-ref> <description>MySQL JasperServer repository</description> <res-ref-name>jdbc/mysqldbname</res-ref-name> <res-type>javax.sql.ConnectionPoolDataSource</res-type> <res-auth>Container</res-auth> </resource-ref>
Put the JDBC driver referenced in the connection into the apache-tomcatlib directory
Clean up apache-tomcatconfCatalinalocalhost directory (see JNDI datasource update trouble: Cannot create JDBC driver of class '' for connect URL 'null' for details)
Restart the server
Log in to JasperReports Server through the web UI and add/test JNDI connection using "jdbc/mysqldbname" as the resource
After upgrading to Tomcat 8 JNDI connection should be updated. Please refer to following article for more info:
http://stackoverflow.com/questions/22518748/classnotfoundexception-when-upgraded-to-tomcat-8
References
- Documentation » JasperReports Server Administration Guide Beta
- Wiki » Connecting JasperReports Server to your Database » Acquire the Database Driver Package
- MariaDB Foundation » MariaDB Java Client
- Apache Tomcat 7 JNDI Resources How-To
TTC-20130720
Recommended Comments
There are no comments to display.