Jump to content
We've recently updated our Privacy Statement, available here ×
  • How to apply NOLOCK to generated queries for MS SQL Server


    stasp
    • Version: v6.3 Product: JasperReports® Server

    Use case

    User needs the select statements to be generated as below to make sure none of them create lock on the DB table:

    Select * from company with (NOLOCK) where ...

    Solution

    Such effect can be achieved by using JNDI connection, and applying the READ_UNCOMMITTED transaction isolation on the connection level. The JNDI connection definition should look something like this: 

    <Resource name="jdbc/databaseName"
              auth="Container"
              type="javax.sql.DataSource"
              maxActive="100"
              maxIdle="30"
              maxWait="10000"
              username="xxxx"
              password="xxxx"
              defaultTransactionIsolation="READ_UNCOMMITTED"
              driverClassName="net.sourceforge.jtds.jdbc.Driver"
              url="jdbc:jtds:sqlserver://localhost:1433/databaseName" />
    

    You can also find more info about the READ_UNCOMMITED isolation level here:  https://msdn.microsoft.com/en-us/library/ms173763.aspx

     


    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...