Can I set the JDBC isolation level from a Tomcat Context?

谁说我不能喝 提交于 2019-12-01 08:25:45

Yes, you can set that with defaultTransactionIsolation attribute in the Resource element.

<Context antiResourceLocking="false" privileged="true">
        <Resource 
            defaultTransactionIsolation="READ_UNCOMMITTED"
            name="jdbc/Connection" 
            auth="Container" 
            type="javax.sql.DataSource"
            maxActive="100" 
            maxIdle="30" 
            maxWait="10000"
            driverClassName="net.sourceforge.jtds.jdbc.Driver"
            url="jdbc:jtds:sqlserver://...etc..."
        />

From the docs:

defaultTransactionIsolation¨

TransactionIsolation state of connections created by this pool. One of the following: (see javadoc )

  • NONE
  • READ_COMMITTED
  • READ_UNCOMMITTED
  • REPEATABLE_READ
  • SERIALIZABLE

I was looking for snapshot isolation level. The setting which was reported correctly by the database server was

defaultTransactionIsolation="4096"

You may confirm by a query to sys.dm_exec_sessions which should report transaction_isolation_level = 5. Hope it helps someone.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!