How to Set tidb_isolation_read_engines Isolation in JDBC

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: 如何在JDBC中设置tidb_isolation_read_engines隔离

| username: 健康的腰间盘

How to add the tidb_isolation_read_engines isolation configuration in the JDBC connection? The official documentation only provides the usage of set @@session.tidb_isolation_read_engines = “tiflash” in SQL queries, but I couldn’t find the specific syntax for implementing it in JDBC.

| username: 小龙虾爱大龙虾 | Original post link

Reference: https://dev.mysql.com/doc/connector-j/en/connector-j-connp-props-session.html

| username: 洪七表哥 | Original post link

Learned.

| username: 健康的腰间盘 | Original post link

Can the teachers provide an example? Referring to the above document, adding connectionString += “tidb_isolation_read_engines=tiflash” results in an error that does not recognize the tidb_isolation_read_engines parameter.

| username: 有猫万事足 | Original post link

It’s not about directly appending strings to the JDBC connection string, but about using the sessionVariables variable to pass them.

To see how to set this variable, refer to the link above.

| username: 有猫万事足 | Original post link

I just realized that another post was also made by you, and they have already put it together. You just need to add this directly to your connectionString.

Also, in another post you asked whether you can have two connections, one accessing TiKV and the other accessing TiFlash.
You can set up two connection pools, using JDBC to control one to access only TiKV and the other to access only TiFlash.

| username: 健康的腰间盘 | Original post link

Okay, thank you, teacher.

| username: TiDBer_7S8XqKfl | Original post link

Thank you for your selfless sharing!