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

前端 未结 2 1779
孤城傲影
孤城傲影 2021-01-14 09:25

I have a web application running in Tomcat 6, and I\'ve managed to configure it to use the built-in DBCP connection pooling, and all is working very well, however I suspect

相关标签:
2条回答
  • 2021-01-14 09:47

    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
    0 讨论(0)
  • 2021-01-14 09:51

    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.

    0 讨论(0)
提交回复
热议问题