<h2 dir="auto">Feature Request</h2>
<p dir="auto"><strong>For English only</strong>, other languages will not accept.</p>
<p dir="auto">Please pay attention on issues you submitted, because we maybe need more details.<br>
If no response anymore and we cannot make decision by current information, we will <strong>close it</strong>.</p>
<p dir="auto">Please answer these questions before submitting your issue. Thanks!</p>
<h3 dir="auto">Is your feature request related to a problem?</h3>
<p dir="auto">NO</p>
<h3 dir="auto">Describe the feature you would like.</h3>
<h4 dir="auto">First of all, we can use DistSQL create two READWRITE_SPLITTING RULE in one logic schema.</h4>
<p dir="auto">eg:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="CREATE READWRITE_SPLITTING RULE ms_group_0 (
WRITE_RESOURCE=write_ds,
READ_RESOURCES(read_ds_0,read_ds_1),
TYPE(NAME=random)
);
CREATE READWRITE_SPLITTING RULE ms_group_1(
WRITE_RESOURCE=write_ds,
READ_RESOURCES(read_ds_0,read_ds_1),
TYPE(NAME=random)
);
"><pre class="notranslate"><code class="notranslate">CREATE READWRITE_SPLITTING RULE ms_group_0 (
WRITE_RESOURCE=write_ds,
READ_RESOURCES(read_ds_0,read_ds_1),
TYPE(NAME=random)
);
CREATE READWRITE_SPLITTING RULE ms_group_1(
WRITE_RESOURCE=write_ds,
READ_RESOURCES(read_ds_0,read_ds_1),
TYPE(NAME=random)
);

</code></pre></div>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/86462784/178705641-fbc56d1e-07e9-48a6-af7a-8e8328cda378.png"><img width="665" alt="image" src="https://user-images.githubusercontent.com/86462784/178705641-fbc56d1e-07e9-48a6-af7a-8e8328cda378.png" style="max-width: 100%;"></a></p>
<h4 dir="auto">But when we use select in this logic schema,we can't figure out how to route,because of we have same table in two rules.</h4>
<p dir="auto">And it is not legal, because we cant't have two same table in one schema.</p>
<h4 dir="auto">So,can we verify dataSource in ReadWrite-splitting rules? Ensures that a logical schema does not exist the same table and cannot be routed.</h4>
<p dir="auto">Please answer these questions before submitting your issue. Thanks!</p>
<h3 dir="auto">2.0.0.M1</h3>
<h3 dir="auto">各节点都更新成功</h3>
<h3 dir="auto">执行操作后,无响应</h3>
<h3 dir="auto">表t_order</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="(
  ORDER_ID INTEGER not null,
  USER_ID  INTEGER not null,
  STATUS   VARCHAR2(50)
)"><pre lang="create" class="notranslate"><code class="notranslate">(
  ORDER_ID INTEGER not null,
  USER_ID  INTEGER not null,
  STATUS   VARCHAR2(50)
)
</code></pre></div>
<p dir="auto">分片键使用USER_ID，切分至2个数据库实例中，并在2个数据库实例中分别插入order_id=1234数据记录。<br>
并开启多个线程进行更新操作,语句如下</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="update t_order set status='11111' where order_id='1234'"><pre class="notranslate"><code class="notranslate">update t_order set status='11111' where order_id='1234'
</code></pre></div>
<h3 dir="auto">实例代码</h3>
<h4 dir="auto">SpringMybatisShardingDatabaseOnlyMain2</h4>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="/*
 * Copyright 1999-2015 dangdang.com.
 * &lt;p&gt;
 * Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * &lt;/p&gt;
 */

package io.shardingjdbc.example.spring.namespace.mybatis;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

/**
 *请求1
 1、node1 update test set a=1 where user_id='1'

 4、node2 update test set a=1 where user_id='1'
 请求2
 2、node1  update test set a=1 where user_id='1'
 3、node2  update test set a=1 where user_id='1'
 *
 * 如果按照以上顺序执行时,会不会发生死锁现象
 */
public final class SpringMybatisShardingDatabaseOnlyMain2 {

    public static void main(final String[] args) throws SQLException, InterruptedException {
        final ApplicationContext applicationContext = new ClassPathXmlApplicationContext(&quot;META-INF/mybatisShardingDatabaseOnlyContext.xml&quot;);
        ExecutorService executors = Executors.newFixedThreadPool(10);
        for (int i = 0; i &lt; 2; i++) {
            executors.execute(new UpdateRunable(applicationContext));
        }
        TimeUnit.SECONDS.sleep(10);
        executors.shutdown();
        while (!executors.isTerminated()){
        }
        System.out.println(&quot;程序结束&quot;);


    }


    public static class UpdateRunable implements Runnable {
        ApplicationContext applicationContext;

        public UpdateRunable(ApplicationContext applicationContext) {
            this.applicationContext = applicationContext;
        }

        @Override
        public void run() {
                DataSource dataSource = (DataSource) applicationContext.getBean(&quot;shardingDataSource&quot;);
                Connection connection = null;
                PreparedStatement pre = null;
                try {
                    connection = dataSource.getConnection();
                    connection.setAutoCommit(false);
                    pre = connection.prepareStatement(&quot;update t_order set status='11111' where order_id='1234'&quot;);
                    int c = pre.executeUpdate();
                    System.out.println(&quot;t-name:&quot; + Thread.currentThread().getName() + &quot;  c1:&quot; + c);
                    connection.commit();
                } catch (Exception e) {
                    e.printStackTrace();
                } finally {
                    try {
                        connection.close();
                    } catch (SQLException e) {
                        e.printStackTrace();
                    }
                }
        }
    }

}
"><pre class="notranslate"><code class="notranslate">/*
 * Copyright 1999-2015 dangdang.com.
 * &lt;p&gt;
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * &lt;/p&gt;
 */

package io.shardingjdbc.example.spring.namespace.mybatis;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

/**
 *请求1
 1、node1 update test set a=1 where user_id='1'

 4、node2 update test set a=1 where user_id='1'
 请求2
 2、node1  update test set a=1 where user_id='1'
 3、node2  update test set a=1 where user_id='1'
 *
 * 如果按照以上顺序执行时,会不会发生死锁现象
 */
public final class SpringMybatisShardingDatabaseOnlyMain2 {

    public static void main(final String[] args) throws SQLException, InterruptedException {
        final ApplicationContext applicationContext = new ClassPathXmlApplicationContext("META-INF/mybatisShardingDatabaseOnlyContext.xml");
        ExecutorService executors = Executors.newFixedThreadPool(10);
        for (int i = 0; i &lt; 2; i++) {
            executors.execute(new UpdateRunable(applicationContext));
        }
        TimeUnit.SECONDS.sleep(10);
        executors.shutdown();
        while (!executors.isTerminated()){
        }
        System.out.println("程序结束");


    }


    public static class UpdateRunable implements Runnable {
        ApplicationContext applicationContext;

        public UpdateRunable(ApplicationContext applicationContext) {
            this.applicationContext = applicationContext;
        }

        @Override
        public void run() {
                DataSource dataSource = (DataSource) applicationContext.getBean("shardingDataSource");
                Connection connection = null;
                PreparedStatement pre = null;
                try {
                    connection = dataSource.getConnection();
                    connection.setAutoCommit(false);
                    pre = connection.prepareStatement("update t_order set status='11111' where order_id='1234'");
                    int c = pre.executeUpdate();
                    System.out.println("t-name:" + Thread.currentThread().getName() + "  c1:" + c);
                    connection.commit();
                } catch (Exception e) {
                    e.printStackTrace();
                } finally {
                    try {
                        connection.close();
                    } catch (SQLException e) {
                        e.printStackTrace();
                    }
                }
        }
    }

}

</code></pre></div>
<h4 dir="auto">mybatisShardingDatabaseOnlyContext.xml</h4>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;
    xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
    xmlns:context=&quot;http://www.springframework.org/schema/context&quot; 
    xmlns:tx=&quot;http://www.springframework.org/schema/tx&quot; 
    xmlns:sharding=&quot;http://shardingjdbc.io/schema/shardingjdbc/sharding&quot;
    xsi:schemaLocation=&quot;http://www.springframework.org/schema/beans
                        http://www.springframework.org/schema/beans/spring-beans.xsd 
                        http://www.springframework.org/schema/tx 
                        http://www.springframework.org/schema/tx/spring-tx.xsd
                        http://www.springframework.org/schema/context 
                        http://www.springframework.org/schema/context/spring-context.xsd
                        http://shardingjdbc.io/schema/shardingjdbc/sharding 
                        http://shardingjdbc.io/schema/shardingjdbc/sharding/sharding.xsd&quot;&gt;
    &lt;context:component-scan base-package=&quot;io.shardingjdbc.example.spring.namespace.mybatis&quot; /&gt;

    &lt;bean id=&quot;demo_ds_0&quot; class=&quot;org.apache.commons.dbcp.BasicDataSource&quot; destroy-method=&quot;close&quot;&gt;
        &lt;property name=&quot;driverClassName&quot; value=&quot;oracle.jdbc.driver.OracleDriver&quot;/&gt;
        &lt;property name=&quot;url&quot; value=&quot;jdbc:oracle:thin:@127.0.0.1:1521:orcl&quot;/&gt;
        &lt;property name=&quot;username&quot; value=&quot;t2&quot;/&gt;
        &lt;property name=&quot;password&quot; value=&quot;t2&quot;/&gt;
        &lt;property name=&quot;maxActive&quot; value=&quot;50&quot;/&gt;
    &lt;/bean&gt;

    &lt;bean id=&quot;demo_ds_1&quot; class=&quot;org.apache.commons.dbcp.BasicDataSource&quot; destroy-method=&quot;close&quot;&gt;
        &lt;property name=&quot;driverClassName&quot; value=&quot;oracle.jdbc.driver.OracleDriver&quot;/&gt;
        &lt;property name=&quot;url&quot; value=&quot;jdbc:oracle:thin:@127.0.0.1:1521:orcl&quot;/&gt;
        &lt;property name=&quot;username&quot; value=&quot;t1&quot;/&gt;
        &lt;property name=&quot;password&quot; value=&quot;t1&quot;/&gt;
        &lt;property name=&quot;maxActive&quot; value=&quot;50&quot;/&gt;
    &lt;/bean&gt;
    &lt;sharding:standard-strategy id=&quot;databaseShardingStrategy&quot; sharding-column=&quot;user_id&quot; precise-algorithm-class=&quot;io.shardingjdbc.example.spring.namespace.mybatis.algorithm.PreciseModuloDatabaseShardingAlgorithm&quot;/&gt;
    
    &lt;sharding:data-source id=&quot;shardingDataSource&quot;&gt;
        &lt;sharding:sharding-rule data-source-names=&quot;demo_ds_0, demo_ds_1&quot;&gt;
            &lt;sharding:table-rules&gt;
                &lt;sharding:table-rule logic-table=&quot;t_order&quot; database-strategy-ref=&quot;databaseShardingStrategy&quot; generate-key-column=&quot;order_id&quot; /&gt;
            &lt;/sharding:table-rules&gt;
        &lt;/sharding:sharding-rule&gt;
    &lt;/sharding:data-source&gt;
    
    &lt;bean id=&quot;transactionManager&quot; class=&quot;org.springframework.jdbc.datasource.DataSourceTransactionManager&quot;&gt;
        &lt;property name=&quot;dataSource&quot; ref=&quot;shardingDataSource&quot; /&gt;
    &lt;/bean&gt;
    &lt;tx:annotation-driven transaction-manager=&quot;transactionManager&quot; /&gt;
    
    &lt;bean id=&quot;sqlSessionFactory&quot; class=&quot;org.mybatis.spring.SqlSessionFactoryBean&quot;&gt;
        &lt;property name=&quot;dataSource&quot; ref=&quot;shardingDataSource&quot;/&gt;
        &lt;property name=&quot;mapperLocations&quot; value=&quot;classpath*:META-INF/mappers/*.xml&quot;/&gt;
    &lt;/bean&gt;
    
    &lt;bean class=&quot;org.mybatis.spring.mapper.MapperScannerConfigurer&quot;&gt;
        &lt;property name=&quot;basePackage&quot; value=&quot;io.shardingjdbc.example.spring.namespace.mybatis&quot;/&gt;
        &lt;property name=&quot;sqlSessionFactoryBeanName&quot; value=&quot;sqlSessionFactory&quot;/&gt;
    &lt;/bean&gt;

&lt;/beans&gt;
"><pre class="notranslate"><code class="notranslate">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:context="http://www.springframework.org/schema/context" 
    xmlns:tx="http://www.springframework.org/schema/tx" 
    xmlns:sharding="http://shardingjdbc.io/schema/shardingjdbc/sharding"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
                        http://www.springframework.org/schema/beans/spring-beans.xsd 
                        http://www.springframework.org/schema/tx 
                        http://www.springframework.org/schema/tx/spring-tx.xsd
                        http://www.springframework.org/schema/context 
                        http://www.springframework.org/schema/context/spring-context.xsd
                        http://shardingjdbc.io/schema/shardingjdbc/sharding 
                        http://shardingjdbc.io/schema/shardingjdbc/sharding/sharding.xsd"&gt;
    &lt;context:component-scan base-package="io.shardingjdbc.example.spring.namespace.mybatis" /&gt;

    &lt;bean id="demo_ds_0" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"&gt;
        &lt;property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/&gt;
        &lt;property name="url" value="jdbc:oracle:thin:@127.0.0.1:1521:orcl"/&gt;
        &lt;property name="username" value="t2"/&gt;
        &lt;property name="password" value="t2"/&gt;
        &lt;property name="maxActive" value="50"/&gt;
    &lt;/bean&gt;

    &lt;bean id="demo_ds_1" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"&gt;
        &lt;property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/&gt;
        &lt;property name="url" value="jdbc:oracle:thin:@127.0.0.1:1521:orcl"/&gt;
        &lt;property name="username" value="t1"/&gt;
        &lt;property name="password" value="t1"/&gt;
        &lt;property name="maxActive" value="50"/&gt;
    &lt;/bean&gt;
    &lt;sharding:standard-strategy id="databaseShardingStrategy" sharding-column="user_id" precise-algorithm-class="io.shardingjdbc.example.spring.namespace.mybatis.algorithm.PreciseModuloDatabaseShardingAlgorithm"/&gt;
    
    &lt;sharding:data-source id="shardingDataSource"&gt;
        &lt;sharding:sharding-rule data-source-names="demo_ds_0, demo_ds_1"&gt;
            &lt;sharding:table-rules&gt;
                &lt;sharding:table-rule logic-table="t_order" database-strategy-ref="databaseShardingStrategy" generate-key-column="order_id" /&gt;
            &lt;/sharding:table-rules&gt;
        &lt;/sharding:sharding-rule&gt;
    &lt;/sharding:data-source&gt;
    
    &lt;bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"&gt;
        &lt;property name="dataSource" ref="shardingDataSource" /&gt;
    &lt;/bean&gt;
    &lt;tx:annotation-driven transaction-manager="transactionManager" /&gt;
    
    &lt;bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"&gt;
        &lt;property name="dataSource" ref="shardingDataSource"/&gt;
        &lt;property name="mapperLocations" value="classpath*:META-INF/mappers/*.xml"/&gt;
    &lt;/bean&gt;
    
    &lt;bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"&gt;
        &lt;property name="basePackage" value="io.shardingjdbc.example.spring.namespace.mybatis"/&gt;
        &lt;property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/&gt;
    &lt;/bean&gt;

&lt;/beans&gt;

</code></pre></div>
<h4 dir="auto">OrderMapper.xml</h4>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?&gt;
&lt;!DOCTYPE mapper PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot; &quot;http://mybatis.org/dtd/mybatis-3-mapper.dtd&quot;&gt;
&lt;mapper namespace=&quot;io.shardingjdbc.example.spring.namespace.mybatis.repository.OrderRepository&quot;&gt;
    &lt;update id=&quot;createIfNotExistsTable&quot;&gt;
        CREATE TABLE  t_order (order_id INT , user_id INT NOT NULL, status VARCHAR2(50), PRIMARY KEY (order_id))
    &lt;/update&gt;

    &lt;update id=&quot;truncateTable&quot;&gt;
        TRUNCATE TABLE t_order
    &lt;/update&gt;
    
    &lt;update id=&quot;dropTable&quot;&gt;
        DROP TABLE  t_order
    &lt;/update&gt;
    
    &lt;insert id=&quot;insert&quot; useGeneratedKeys=&quot;true&quot; keyProperty=&quot;orderId&quot;&gt;
        INSERT INTO t_order (
          user_id, status
        )
        VALUES (
        #{userId,jdbcType=INTEGER},
        #{status,jdbcType=VARCHAR}
        )
    &lt;/insert&gt;
    
    &lt;delete id=&quot;delete&quot;&gt;
        DELETE FROM t_order WHERE order_id = #{orderId,jdbcType=INTEGER}
    &lt;/delete&gt;
&lt;/mapper&gt;


"><pre class="notranslate"><code class="notranslate">&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
&lt;!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"&gt;
&lt;mapper namespace="io.shardingjdbc.example.spring.namespace.mybatis.repository.OrderRepository"&gt;
    &lt;update id="createIfNotExistsTable"&gt;
        CREATE TABLE  t_order (order_id INT , user_id INT NOT NULL, status VARCHAR2(50), PRIMARY KEY (order_id))
    &lt;/update&gt;

    &lt;update id="truncateTable"&gt;
        TRUNCATE TABLE t_order
    &lt;/update&gt;
    
    &lt;update id="dropTable"&gt;
        DROP TABLE  t_order
    &lt;/update&gt;
    
    &lt;insert id="insert" useGeneratedKeys="true" keyProperty="orderId"&gt;
        INSERT INTO t_order (
          user_id, status
        )
        VALUES (
        #{userId,jdbcType=INTEGER},
        #{status,jdbcType=VARCHAR}
        )
    &lt;/insert&gt;
    
    &lt;delete id="delete"&gt;
        DELETE FROM t_order WHERE order_id = #{orderId,jdbcType=INTEGER}
    &lt;/delete&gt;
&lt;/mapper&gt;



</code></pre></div>