Jump to content
We've recently updated our Privacy Statement, available here ×
  • How to change driver for a JNDI data source


    Friendly User
    • Features: JasperReports Server Product: JasperReports® Server

    Scenario:

    You have a JNDI connection that is using one driver but want to change the connection to another driver, how to do that?


    Solution:

    Driver changes need to be done on the JNDI definition level in META-INF/context.xml (or alternative for your application server). For example:

    <Resource name="jdbc/jasperserver" auth="Container" type="javax.sql.DataSource" 
              maxActive="100" maxIdle="30" maxWait="10000" username="jasperdb" password="password" 
              driverClassName="org.postgresql.Driver" accessToUnderlyingConnectionAllowed="true" 
              validationQuery="SELECT 1" testOnBorrow="true" 
              url="jdbc:postgresql://127.0.0.1:5432/jasperserver?useUnicode=true&amp;characterEncoding=UTF-8&amp;autoReconnect=true&amp;amp;autoReconnectForPools=true"
              factory="com.jaspersoft.jasperserver.tomcat.jndi.JSCommonsBasicDataSourceFactory"/>
    

    Here you can see that the driver defined is driverClassName="org.postgresql.Driver". You will need to change it to the classname of your driver of choice. After you change the classname, you'll need not to forget to change the URL as well as many drivers have different JDBC connection string templates.

    You can re-use the URL and Port however the jdbc:{vendor}:// part will most likely be different and the parameters can differ.

    Once you've done the change, a restart of application server is in order to make sure all the values are picked up correctly


    User Feedback

    Recommended Comments

    There are no comments to display.



    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

×
×
  • Create New...